-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.js
More file actions
67 lines (57 loc) · 1.6 KB
/
runtime.js
File metadata and controls
67 lines (57 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
66
67
(function() {
$(".runtime-embedded-box").each(function() {
let editorElement = $(this).find('.runtime-ace-editor')[0];
let editor = ace.edit(editorElement.id);
editor.setTheme("ace/theme/chrome");
editor.session.setMode("ace/mode/runtime");
editor.setFontSize(13);
/* Console */
let jqconsole = $(this).find('#runtime-console').jqconsole(
//welcomeString, promptLabel, continueLabel, disableAutoFocus
'', '', '', true
);
jqconsole.Write('Runtime Script\n', 'console-gray');
jqconsole.SetPromptLabel(' ');
/* control buttons */
let runBtn = $(this).find("#run-btn");
let restartBtn = $(this).find("#restart-btn");
let stepBtn = $(this).find("#step-btn");
let clearBtn = $(this).find("#clear-canvas-btn");
let controls = {
run: runBtn,
restart: restartBtn,
stepBtn: stepBtn,
clearBtn: clearBtn
};
let options = {};
let runtime = runtimeExecuter();
let canvas = runtimeCanvas();
let evaluator = runtimeEvaluator();
let parser = runtimeParser();
canvas.init($(this).find('#runtime-canvas')[0]);
runtime.config(parser, evaluator, editor, jqconsole, canvas, controls, options);
let startPrompt = function () {
// Start the prompt with history enabled.
jqconsole.Prompt(true, function (input) {
switch (input) {
case 'clear':
jqconsole.Reset();
break;
}
startPrompt();
});
}
startPrompt();
/* listener */
runBtn.click(function() {
try {
runtime.executeAll();
} catch(err) {
jqconsole.Write(`${err}\n`, 'console-error');
}
});
restartBtn.click(function() {
runtime.restart();
});
});
})();