-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
235 lines (204 loc) · 7.56 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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Joeasus Online Interpreter</title>
<style>
body, html {
margin: 0;
padding: 0;
font-family: 'Courier New', monospace;
background-color: #000;
color: #0f0;
height: 100%;
overflow: hidden;
}
.container {
display: flex;
flex-direction: column;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
header {
text-align: center;
margin-bottom: 20px;
}
h1 {
font-size: 2.5em;
text-shadow: 0 0 10px #0f0, 0 0 20px #0f0, 0 0 30px #0f0;
}
.editor-container {
display: flex;
flex-grow: 1;
gap: 20px;
}
.code-editor, .input-box, .output {
flex: 1;
background-color: rgba(0, 50, 0, 0.3);
border: 1px solid #0f0;
border-radius: 5px;
padding: 10px;
font-size: 16px;
resize: none;
color: #0f0;
}
.code-editor:focus, .input-box:focus, .output:focus {
outline: none;
box-shadow: 0 0 10px #0f0;
}
.input-output-container {
display: flex;
flex-direction: column;
gap: 20px;
flex: 1;
}
.controls {
display: flex;
justify-content: center;
margin-top: 20px;
gap: 10px;
}
.run-btn, .permalink-btn {
background-color: #008000;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border-radius: 5px;
transition: all 0.3s ease;
}
.run-btn:hover, .permalink-btn:hover {
background-color: #00ff00;
box-shadow: 0 0 20px #00ff00;
}
.permalink-container {
margin-top: 20px;
text-align: center;
}
.permalink-input {
width: 80%;
padding: 10px;
font-size: 16px;
background-color: rgba(0, 50, 0, 0.3);
border: 1px solid #0f0;
border-radius: 5px;
color: #0f0;
}
@keyframes matrix-bg {
0% { background-position: 0% 0%; }
100% { background-position: 0% 100%; }
}
.matrix-bg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.1;
z-index: -1;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==');
animation: matrix-bg 20s linear infinite;
}
</style>
</head>
<body>
<div class="matrix-bg"></div>
<div class="container">
<header>
<h1><a href="https://github.com/lyxal/Joeasus">Joeasus</a> Online Interpreter</h1>
</header>
<div class="editor-container">
<textarea class="code-editor" id="code-editor" placeholder="Enter your Joeasus code here..."></textarea>
<div class="input-output-container">
<textarea class="input-box" id="input-box" placeholder="Enter your inputs here..."></textarea>
<textarea class="output" id="output" readonly placeholder="Output will appear here..."></textarea>
</div>
</div>
<div class="controls">
<button class="run-btn" id="run-btn">Run Code</button>
<button class="permalink-btn" id="permalink-btn">Generate Permalink</button>
</div>
<div class="permalink-container">
<input type="text" class="permalink-input" id="permalink-input" readonly placeholder="Permalink will appear here...">
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const codeEditor = document.getElementById('code-editor');
const inputBox = document.getElementById('input-box');
const output = document.getElementById('output');
const runBtn = document.getElementById('run-btn');
const permalinkBtn = document.getElementById('permalink-btn');
const permalinkInput = document.getElementById('permalink-input');
runBtn.addEventListener('click', async () => {
const code = codeEditor.value;
const inputs = inputBox.value;
output.value = 'Running...';
try {
const response = await fetch('https://joeasus-interpreter.lyxal.workers.dev/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ program: code, inputs: inputs }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.text();
output.value = result;
} catch (error) {
output.value = `Error: ${error.message}`;
}
});
function generatePermalink(baseUrl, code, inputs) {
// Serialize the code and inputs to a JSON string
const data = JSON.stringify({ code, inputs });
// Encode the JSON string to base64
const encodedData = btoa(data);
// Return the complete permalink
return `${baseUrl}?data=${encodeURIComponent(encodedData)}`;
}
function decodePermalink(url) {
// Extract the `data` parameter from the URL
const params = new URL(url).searchParams;
const encodedData = params.get('data');
if (!encodedData) {
throw new Error('No data parameter found in the URL');
}
// Decode the base64 string and parse the JSON
const decodedData = JSON.parse(atob(encodedData));
return {
code: decodedData.code,
inputs: decodedData.inputs
};
}
permalinkBtn.addEventListener('click', () => {
permalink = generatePermalink("https://lyxal.github.io/Joeasus/", codeEditor.value, inputBox.value)
permalinkInput.value = permalink;
});
// Read permalink on page load
const info = decodePermalink(window.location.href)
if (info.code) {
codeEditor.value = info.code;
}
if (info.inputs) {
inputBox.value = info.inputs;
}
// Add some visual effects
[codeEditor, inputBox].forEach(element => {
element.addEventListener('input', () => {
element.style.boxShadow = '0 0 20px #00ff00';
setTimeout(() => {
element.style.boxShadow = 'none';
}, 200);
});
});
});
</script>
</body>
</html>