-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (78 loc) · 2.29 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
<!DOCTYPE html>
<html>
<head>
<title>4js</title>
<style>
html, body {
height: 100%;
margin: 0;
color:yellow;
}
body {
background: blue;
}
.title {
font-size: 1.25rem;
top: 0.5rem;
position: fixed;
}
.container {
padding: 0 5% 0 5%;
height: 100%;
}
.terminal {
top: 1.5rem;
bottom: 4rem;
width: 90%;
background: white;
color: black;
position: fixed;
overflow: auto;
}
.prompt {
bottom: 3.5rem;
position: fixed;
}
.console {
bottom: 2rem;
width: 90%;
position: fixed;
}
</style>
</head>
<body>
<div class="container">
<form action='javascript:onInput()'>
<label class='title' for="terminal">4JS - Minimalist JavaScript Forth</label>
<pre class="terminal" id='terminal'></pre>
<label class='prompt' for='console'>Console</label>
<input class="console" id='console' type="text">
</form>
</div>
</body>
<script src="./4js.js"></script>
<script>
let screen = document.getElementById('terminal')
let input = document.getElementById('console')
// 640k objects should be enough for everyone
// f is a Forth 'task', everything but dictionary is local to this task
let f = forth(1024, 640*1024)
// embedding API - defining words from JS
define(".", (task) => screen.innerHTML += task.pop())
function onInput() {
let text = input.value
input.value = ''
if (text != "") {
try {
f.run(text)
screen.innerHTML += 'ok \n'
}
catch (error) {
screen.innerHTML += error +"\n"
}
screen.scrollBy(0, 100)
}
}
input.focus()
</script>
</html>