-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.html
180 lines (169 loc) · 5.16 KB
/
console.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Console</title>
<style>
body {
font-family: "Courier New", Courier, monospace;
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
margin: 0;
padding: 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
}
#ide,
#console {
width: 50%;
height: 92vh;
display: flex;
flex-direction: column;
align-items: flex-start;
background: #000;
color: #fff;
padding: 2vh;
font-size: 18px;
}
#ide {
background: #222;
color: #eee;
}
#ide textarea,
#console textarea {
width: 100%;
height: 98%;
background: #282c34;
color: #eee;
border: none;
outline: none;
font-family: "Courier New", Courier, monospace;
resize: none;
padding: 1%;
font-size: 18px;
}
#console textarea {
height: 93%;
background: #000;
color: #fff;
padding: 1%;
}
#ide #toolbox {
width: 100%;
height: 5%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background-color: #222;
}
#console #prompt {
width: 100%;
height: auto;
display: flex;
flex-direction: column;
justify-content: left;
align-items: top;
background-color: #000000;
width: 100%;
}
#console #prompt div {
padding: 1%;
}
#console #prompt input {
display: flex;
border: none;
background-color: #000000;
color: white;
font-family: "Courier New", Courier, monospace;
outline: none;
width: 100%;
height: 5vh;
font-size: 18px;
}
</style>
</head>
<body>
<div id="ide">
<div id="toolbox">
<div class="section">
<button onclick="incresFontSize()">+</button>
<button onclick="decreseFontSize()">-</button>
<button onclick="resetFontSize()">Reset fonts</button>
</div>
<div class="section">
<button onclick="examples()">Load Example</button>
</div>
<div class="section">
<select id="select">
<option value="io">io.fg</option>
<option value="print">print.fg</option>
<option value="operator1">operator1.fg</option>
<option value="operator2">operator2.fg</option>
<option value="operator3">operator3.fg</option>
</select>
</div>
<div class="section">
<button onclick="location.reload()">Reset compiler</button>
<button id="run" onclick="run()">Run</button>
</div>
</div>
<textarea name="ide" id="idetxt" spellcheck="false"></textarea>
</div>
<div id="console">
<div id="prompt"></div>
<textarea name="cons" id="cons"></textarea>
</div>
<script>
var cons = document.getElementById("cons");
var ide = document.getElementById("idetxt");
var inputdiv = document.getElementById("prompt");
var scriptm = document.getElementById("scriptm");
var rundiv = document.getElementById("run");
var ideFontSize = 18;
function incresFontSize() {
ideFontSize += 2;
ide.style.fontSize = ideFontSize + "px";
}
function decreseFontSize() {
ideFontSize -= 2;
ide.style.fontSize = ideFontSize + "px";
}
function resetFontSize() {
ideFontSize = 18;
ide.style.fontSize = ideFontSize + "px";
}
var err = null;
if (localStorage.getItem("ide")) {
ide.value = localStorage.getItem("ide");
}
ide.addEventListener("keyup", (e) => {
if (e.key == "Enter" && e.shiftKey) {
e.preventDefault();
run();
} else if (e.key == "Tab") {
e.preventDefault();
ide.value += " ";
} else if (e.key == "ArrowLeft" && e.ctrlKey) {
e.preventDefault();
ide.value = cons.value;
} else {
localStorage.setItem("ide", ide.value);
}
});
</script>
<script>
let select = document.getElementById("select");
let examples = () => {
fetch("examples/" + select.value + ".fg")
.then((res) => res.text())
.then((data) => {
ide.value = data;
});
};
</script>
<script src="compiler.js"></script>
</body>
</html>