-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.gbt
More file actions
65 lines (58 loc) · 1.6 KB
/
playground.gbt
File metadata and controls
65 lines (58 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
layout: default
title: gbeta Playground
---
<notextile>
<div id="container" style="text-align: center; margin: 3em 5em 2em 5em">
<div style="width: 100%; text-align: left;" >
<textarea id="playground">ORIGIN 'gbetaenv'
--universe:descriptor--
{
'Hello, World'|stdio
}</textarea>
<div class="buttons">
<input id="compile" class="compile" type="submit" value="Compile & Run" style="text-transform: uppercase; font-weight: bold;" />
</div>
<div id="output" class="output ok"></div>
<div id="error" class="output error"></div>
</div>
<script type="text/javascript">
var playground = CodeMirror.fromTextArea(document.getElementById('playground'), {
lineNumbers: true,
mode: 'gbeta'
});
$('#compile').unbind('click').bind('click', function() {
compile(playground.getValue());
});
$('#output').hide();
$('#error').hide();
function compile(program) {
display("Compiling and running...", true);
$.ajax({
url: '/cgi-bin/gbeta.cgi',
processData: false,
data: 'program='+encodeURIComponent(program),
type: 'POST',
success: function(data) {
var iOf = data.indexOf('#');
var stat = data.substring(0, iOf);
var out = data.substring(iOf+1, data.length);
display(out, (stat == 'true'));
},
});
}
function display(text, success) {
var output = $('#output'), error = $('#error');
if (success) {
error.hide();
output.html('<pre>'+text+'</pre>');
output.show();
} else {
output.hide();
error.html('<pre>'+text+'</pre>');
error.show();
}
}
</script>
</div>
</notextile>