-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.html
More file actions
85 lines (79 loc) · 2.41 KB
/
Copy pathindex.html
File metadata and controls
85 lines (79 loc) · 2.41 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<title>Piethon online</title>
<script src="grammar/piethon.js"></script>
<script src="main.js"></script>
<script src="examples.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="styles.css">
</head>
<body>
<div id="editor"># Say hello!
x = "Hello, piethon"
print x
</div>
<div id="navbar">
<button id="runbtn">Run</button>
<select id="examples" name="Examples">
<option value="-1">Examples</option>
</select>
</div>
<div id="console">
<button id="clearbtn">Clear</button>
</div>
<script src="lib/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jqconsole.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
// Set up the console
var jqconsole = $('#console').jqconsole('', '>>>');
var startPrompt = function () {
// Start the prompt with history enabled.
jqconsole.Prompt(true, function (input) {
// Output input with the class jqconsole-output.
jqconsole.Write(input + '\n', 'jqconsole-output');
// Restart the prompt.
startPrompt();
});
};
//startPrompt();
jqconsole.Write('>> ','jqconsole-output');
// Set up the editor
var editor = ace.edit("editor");
editor.setTheme("ace/theme/idle_fingers");
editor.getSession().setMode("ace/mode/python");
// Handle run button interaction
$( "#runbtn" ).click(function() {
resetForRun();
try {
// Grammar is not perfect, have to have it end with a line break
var output = piethon.parse(editor.getValue()+'\n')
if(output == true) {
jqconsole.Write('piethon\nSyntactically correct program: '+output+'\nRunning program:\n', 'jqconsole-output');
eval(finalprogram);
jqconsole.Write('\n', 'jqconsole-output');
}
} catch(exception) {
jqconsole.Write(exception + '\n\n', 'jqconsole-output');
}
jqconsole.Write('>> ','jqconsole-output');
});
// Clear console button
$( "#clearbtn" ).click(function() {
jqconsole.Reset();
});
// Populate the dropdown examples select
var select = $('#examples');
for(var i =0;i<examples.length;i++) {
select.append('<option value="'+i+'">--'+examples[i].name+'</option>');
}
select.change(function() {
var selectedndx = parseInt($( "#examples option:selected" ).attr('value'), 10);
if(selectedndx > -1) {
editor.setValue(examples[selectedndx].code);
editor.gotoLine(1);
}
});
</script>
</body>
</html>