forked from shixiongfei/ape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.html
71 lines (65 loc) · 1.76 KB
/
template.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ape Shell</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
}
textarea {
font-family: monospace;
width: 100%;
height: 180px;
resize: none;
border-width: 0;
border: none;
outline: none;
overflow: auto;
}
#status {
width: 100%;
font-size: 12px;
}
</style>
</head>
<body>
<div id="status">Downloading...</div>
<textarea id="output" readonly></textarea>
<script type="text/javascript">
const outputElement = document.getElementById('output')
const statusElement = document.getElementById('status')
const scripts = localStorage.getItem('apeScript') || ''
var Module = {
preRun: function () {
function stdin() {
return null
}
function stdout(asciiCode) {
outputElement.value += String.fromCharCode(asciiCode)
outputElement.scrollTop = outputElement.scrollHeight
}
function stderr(asciiCode) {
return stdout(asciiCode)
}
FS.init(stdin, stdout, stderr)
FS.writeFile('./run.ape', scripts)
},
setStatus: function (text) {
statusElement.innerHTML = text
if (text === '') {
statusElement.hidden = true
}
},
arguments: ['./run.ape'],
monitorRunDependencies: function (left) {
Module.setStatus(left ? 'Preparing...' : 'All downloads complete')
}
}
</script>
{{{ SCRIPT }}}
</body>
</html>