-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtst_system.html
102 lines (87 loc) · 2.94 KB
/
tst_system.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
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="js/common.js"></script>
<script src="js/memory.js"></script>
<script src="js/mmixcommands.js"></script>
<script src="js/processor.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="tasks/part1.js"></script>
<script src="tasks/part2.js"></script>
<script src="tasks/part3.js"></script>
<script src="js/testsystem.js"></script>
<style type="text/css">
#results .resItem {
border: 1px solid beige;
}
#results .wrong {
background-color: magenta;
}
#results .ok {
background-color: greenyellow;
}
</style>
<script>
var shared = window
$(document).ready(function() {
for(var i = 0; i < shared.tasks.length; i++) {
for(var j = 0; j < shared.tasks[i].length; j++) {
var opt = $("<option>" + (i + 1) + " - " + (j + 1) + "</option>");
$("#task").append(opt);
opt.attr("value", [i,j])
}
}
});
function runTask(opt) {
var a = eval("([" + opt + "])")
task = shared.tasks[a[0]][a[1]]
var res = $("#results")
res.empty()
$("#res_code").empty();
$("#res_code").append("<ol>");
goTask(task, $("#program")[0].value.replace(/[^0-9A-Fa-f]/g, ""), function(r, task, ext, text) {
var tli = $("<li>" + text + "</li>");
tli.addClass("resItem");
if (r) {
tli.addClass("ok");
} else {
tli.addClass("wrong");
}
res.append(tli);
var styleText = "";
if (!r) {
styleText = " style='background-color: magenta;'"
}
$("#res_code").append("<li" + styleText + ">" + text + "</li>");
});
$("#res_code").append("</ol>");
}
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
</div>
</div>
<div class="container">
<div class="row">
<div class="col-6">
<textarea id="program" rows="15" cols="20"></textarea>
</div>
<div class="col-6">
<select id="task"></select><button onclick="runTask($('#task').val())">Run Test</button>
<ol id="results"></ol>
<pre id="res_code"></pre>
</div>
</div>
</div><!-- /.container -->
</body>
</html>