-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfpage.html
96 lines (93 loc) · 2.83 KB
/
cfpage.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
<html>
<head>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
p {
font-family: verdana;
font-size: 24px;
}
h1 {
font: Arial;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
td {
vertical-align:top;
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="CreoleForth_min.js"></script>
<script>
var parseInput = function (input) {
var parsedInput = input.split(/\s+/);
return parsedInput;
};
// puts textarea values onto the stack
var parseStack = function (taval) {
var ds0 = [];
var ds = [];
ds0 = taval.split("\n").reverse();
for (i = 0; i < ds0.length; i++) {
if (ds0[i].trim() != "") {
ds.push(ds0[i]);
}
}
return ds;
};
var cfjsSubmit = function () {
var ds = document.getElementById('DataStack').value;
var dsVals = parseStack(ds);
gsp.DataStack = dsVals;
var input = document.getElementById('Input').value
gsp.InputArea = input;
cfb1.Modules.Interpreter.doParseInput(gsp);
cfb1.Modules.Interpreter.doOuter(gsp);
document.getElementById('DataStack').value = gsp.DataStack.reverse().join("\n");
document.getElementById('vlist').innerHTML = gsp.HelpCommentField;
document.getElementById('soundArea').innerHTML = gsp.SoundField;
};
</script>
</head>
<body>
<table>
<tr>
<th>Stack</th><th>Input</th><th>How to use the Creole Forth for JavaScript Page</th>
</tr>
<tr>
<td><textarea id="DataStack" rows="20" cols="8"></textarea></td>
<td><textarea id="Input" rows="10" cols="75"></textarea>
<br /><button class="button" onclick="cfjsSubmit()">Submit</button>
</td>
<td>
<p>
Please enter the Forth input you want to process in the input box on the left
and click the <strong>Submit</strong> button.<br/><br/>
<strong>VLIST</strong> gives a list of definitions that can be executed.
</p>
</td>
</tr>
</table>
<div id="soundArea">
</div>
<div id="vlist">
</div>
</body>
</html>