-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx-code.html
159 lines (143 loc) · 3.48 KB
/
x-code.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>X-Code 1.0</title>
<style>
div {
display: flex;
flex-direction: column;
height: 100%;
}
textarea {
height: 100%;
resize: none;
}
section {
display: flex;
height: 10%;
justify-content: center;
align-items: center;
flex-direction: row;
}
button {
padding: 0px 10px;
margin: 0px 10px;
}
html, body {
margin: 0px;
height: 100%;
}
</style>
<script>
function back() {
window.location.href = ".."
}
var line_num = 0
var variables = {
'xcode': 'X-Code 1.0 - Javascript Interpreter',
'xcode:v': '1.0',
'xcode:v:': 'OnePointZero',
'\\n': '\n',
'21': 21
}
function onDocLoad() {
document.getElementById('out').value = ''
}
function standardOutput(out) {
document.getElementById('out').value = document.getElementById('out').value + out
}
function exception(type) {
standardOutput('\nSCRIPT|EXCEPTION OCCURED:\n')
standardOutput('Line: '+line_num+' | Type: '+type)
}
function saycodeToStringType(str) {
var format_output = ''
var del_spaces = true
for (x in str) {
if (del_spaces === true && str[x] == ' ') {
continue
}
else {
del_spaces = false
format_output = format_output+str[x]
}
}
if (format_output.includes("'")) {
var quoteless = ''
for (x in format_output) {
if (x == 0) {
continue
}
if (x == format_output.length-1) {
break
}
quoteless = quoteless+format_output[x]
}
return quoteless+'\n'
}
else {
if (variables[format_output] == undefined) {
exception('VariableNotDefined')
return ''
}
return variables[format_output]
}
}
function setVarToValue(variable_name, value) {
value = saycodeToStringType(value)
variables[variable_name] = value
}
function runXcodeScript() {
line_num = 0
document.getElementById('out').value = ''
var code = document.getElementById('in').value
var slashen = code.split('\n')
for (x in slashen) {
line_num = line_num+1
if (slashen[x].split(':')[0] == 'say') {
var format = ''
for (splitty in slashen[x].split(':')) {
if (splitty != 0) {
format = format+slashen[x].split(':')[splitty]
if (splitty < slashen[x].split(':').length-1) {
format = format+':'
}
}
}
standardOutput(saycodeToStringType(format))
}
else if (slashen[x].split(':')[0] == 'var') {
if (slashen[x].split(':')[1] == 'set') {
var format = ''
for (splitty in slashen[x].split(':')) {
if (splitty > 2) {
format = format+slashen[x].split(':')[splitty]
if (splitty < slashen[x].split(':').length-1) {
format = format+':'
}
}
}
setVarToValue(slashen[x].split(':')[2], format)
}
}
else {
exception('CommandNotDefined')
}
}
}
</script>
</head>
<body onload='onDocLoad()'>
<div>
<textarea id='out' readonly placeholder='X-Code On-Javascript Terminal 1.0
Type Inside the Editor and Run the Script to get an output' resizable='false'></textarea>
<textarea id='in' spellcheck='false' placeholder='Enter your code here, and press "Run Script" to run your X-Code project!' autofocus resizable='false'></textarea>
<section>
<button onclick='runXcodeScript()'>Run Script ▶</button>
<button onclick='back()'>Back ...</button>
</section>
</div>
</body>
</html>