-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
97 lines (88 loc) · 4.16 KB
/
index.html
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
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Time Out Interpreter</title>
<link type="text/css" rel="stylesheet" href="TimeOut.css" />
<script type="text/javascript" src="jquery-1.11.2.js"></script>
<script type="text/javascript" src="TimeOut.js"></script>
<script type="text/javascript" src="Display.js"></script>
<script type="text/javascript">
var timeOut;
$(document).ready(function () {
TimeOut.OFFSET_MIN = 30.0;
timeOut = new TimeOut();
timeOut.mode = $('#runMode').val();
});
function execute() {
var speed = $('#speed').val();
TimeOut.COMMAND_LENGTH = speed;
var lines = $('#codeBlock').val().split('\n');
for (var lineCount = 0; lineCount < lines.length; lineCount++)
{
var reDigits = /timeOut\.Set\(\d+\);/;
var reForv = /timeOut\.Set\(forever\);/;
if (lines[lineCount].trim() == '') {
} else if (lines[lineCount].search(reDigits) > -1 || lines[lineCount].search(reForv) > -1) {
var re = /timeOut\.Set\((.*)\);/;
var found = lines[lineCount].match(re);
eval("timeOut.Set(" + found[1] + ");");
} else {
$('#console').append("<span class=\"bad\">Invalid command on line " + (lineCount + 1).toString() + "</span><br/>");
return;
}
}
}
function clearAll() {
$('#console').html('');
$('#output').html('OUTPUT<br />');
$('#programList').html('');
$('#dataStack').html('');
for (var i = 0; i < timeOut.handleList.length; i++) {
clearTimeout(timeOut.handleList[i]);
}
timeOut = new TimeOut();
}
</script>
</head>
<body>
<div id="container">
<div id="leftCol">
<b>TIME OUT INTERPRETER</b>
<div class="smallDesc">
TIME OUT is a language where the action of the program occurs between the lines of code.
The interpreter cycles through every command; the code tells it how long to wait, thereby
skipping over those commands we don't want to fire.
If other processes (or a slow browser) cause the "time out" to last too long,
we might miss the command we want and execute a different one.
More about TIME OUT here.
</div>
Load Program:
<select id="programLoader" onchange="loadProgram();">
<option value="none"></option>
<option value="HelloWorld">Hello, World!</option>
<option value="99Bottles">99 Bottles of Beer</option>
</select>
<br />
<textarea id="codeBlock" rows="30"></textarea><br />
SPEED: <input type="text" id="speed" value="30" style="width: 30px;" maxlength="5" /> milliseconds / command<br />
<div style="display: none;"><!-- nice to have -->
<input type="radio" name="runMode" checked="checked" value="debug" id="easyMode" /><label for="easyMode">Debug Mode</label><span class="small">(interpreter tries to catch up)</span>
<input type="radio" name="runMode" value="regular" id="runReg" /><label for="runReg">Regular Mode</label>
</div>
<div style="width: 100%; text-align: center; padding-top: 20px;">
<input type="button" id="runButton" value="RUN" onclick="execute();" />
<input type="button" id="clearButton" value="reset" onclick="clearAll();" />
</div>
<br /><br />
<a href="Translate.html">Translate pseudo-code to TIME OUT code here</a>
</div>
<div id="rightCol">
<div id="output">OUTPUT<br /></div>
<div style="width: 900px">
<div class="console">PROGRAM<div id="console"></div></div>
<div class="stack">STACK <div id="dataStack"></div></div>
</div>
</div>
</div>
</body>
</html>