-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathindex.html
More file actions
99 lines (87 loc) · 2.65 KB
/
index.html
File metadata and controls
99 lines (87 loc) · 2.65 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
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,Array.prototype.find,Number.isFinite,Number.isInteger,console,console.log,document.head,performance.now"></script>
<head>
<title>CodeWorld</title>
<style type="text/css">
* { margin: 0; overflow: hidden }
#screen {
cursor: default;
width: 100vw;
height: 100vw;
max-height: 100vh;
max-width: 100vh;
}
</style>
</head>
<body style="text-align: center">
<canvas id="screen"></canvas>
</body>
<script type="text/javascript">
function addMessage(err, str) {
if (window.parent && window.parent.addToMessage) {
var message = window.parent.addToMessage(str);
if (err) {
var message = window.parent.document.getElementById('message');
message.classList.add('error');
}
} else {
console.log(str);
}
}
function showCanvas() {
if (!window.parent) {
return;
}
var runner = window.parent.document.getElementById('runner');
if (!runner) {
return;
}
runner.style.display = '';
runner.focus();
runner.contentWindow.focus();
}
function start() {
h$base_writeStdout = function(fd, fdo, buf, buf_offset, n, c) {
addMessage(false, h$decodeUtf8(buf, n, buf_offset));
c(n);
};
h$base_writeStderr = function(fd, fdo, buf, buf_offset, n, c) {
addMessage(false, h$decodeUtf8(buf, n, buf_offset));
c(n);
};
h$log = function() {
var s = '';
for(var i=0;i<arguments.length;i++) { s = s + arguments[i]; }
addMessage(false, s+'\n');
};
h$errorMsg = function(str) {
for(var i=1;i<arguments.length;i++) {
str = str.replace(/%s/, arguments[i]);
}
addMessage(true, '\n' + str);
};
h$base_stdout_fd.write = h$base_writeStdout;
h$base_stderr_fd.write = h$base_writeStderr;
h$run(h$mainZCZCMainzimain);
}
function reportRuntimeError(err, str) {
if (window.parent.addToMessage) {
var message = window.parent.addToMessage('\n' + str);
if (err) {
var message = window.parent.document.getElementById('message');
message.classList.add('error');
}
} else {
console.log(str);
}
}
var loadScript = document.createElement('script');
loadScript.setAttribute('type', 'text/javascript');
loadScript.setAttribute('src', 'js/runjs.js');
loadScript.onload = function() {
start();
};
document.head.appendChild(loadScript);
</script>
</html>