-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
761 lines (649 loc) · 28.1 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Perfect Tower II Script Editor</title>
<meta property="og:type" content="website" />
<meta property="og:title" content="Perfect Tower II Script Editor" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="lib/codemirror.css">
<link rel="stylesheet" href="lib/darcula.css">
<script src="lib/codemirror.js"></script>
<script src="addon/edit/matchbrackets.js"></script>
<script src="addon/selection/active-line.js"></script>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<span id="loadingText" class="infotext">Loading...</span>
<dialog id="setup">
<h2 class="settings">Settings</h2>
<div class="settings-layout">
<label><input id="autoSpace" type="checkbox" checked onchange="settingsChange()">
Auto-indent with spaces instead of tabs
</label>
<label><input id="tabWidth" type="number" min=1 style="width: 3em" value=4 onchange="settingsChange()">
<Tab> width
</label>
<fieldset style="display: flex; justify-content: space-between;">
<legend style="font: revert; margin: revert; padding: revert;">Export format type:</legend>
<label><input id="v2_format" type="radio" name="exportFormat" checked onchange="settingsChange()">
Modern
</label>
<label><input id="v1_format" type="radio" name="exportFormat" onchange="settingsChange()">
Old
</label>
<label><input id="v0_format" type="radio" name="exportFormat" onchange="settingsChange()">
Oldest (uncompressed)
</label>
</fieldset>
<div style="display: flex; justify-content: space-between">
Instructions for importing<br/>code from Kyromyr.github.io
<button class="basicBtn" style="width: 200px" onclick="settingsClose(); workspaceOtherSite()">Export From Other Site</button>
</div>
<button class="basicBtn" onclick="settingsClose()">Close</button>
</div>
</dialog>
<div id="loadingDiv" style="visibility: hidden;">
<template id="template-nav-item">
<li class="nav-item"><a class="nav-link" data-toggle="tab" onclick="scriptSelect(this.parentElement)">New Script</a></li>
</template>
<div class="top-container">
<div class="script-buttons">
<button class="basicBtn" onclick="scriptNew()">New</button>
<button class="basicBtn basicBtnRed" onclick="scriptDelete()">Delete</button>
<button class="basicBtn" onclick="scriptImport()">Import</button>
<button class="basicBtn" onclick="scriptRename()">Rename</button>
</div>
<div class="editor-info">
<div>
<span class="infotext">Editor: 1.83 ─ Game: v0.49.0</span>
<br/>
<span id="warning" class="infotext warning">Cannot access Local Storage. Scripts will not save!</span>
<a id="compression" class="infotext warning" target="_blank" style="display:none" href="old_browser.html">
Browser out of date, can't access CompressionStream API!
</a></span>
</div>
<select id="functionList" class="functionList"></select>
</div>
<div class="workspaces">
<div>
<button class="basicBtn" onclick="workspaceExportSource()">Export Source</button>
<button class="basicBtn" onclick="settingsModal()">Settings ⚙️</button>
<div style="flex-grow:1"></div>
<div>
Workspace:
<select id="workspaceList" class="workspaceList" oninput="workspaceChange(this.value)"></select>
</div>
</div>
<div>
<button class="basicBtn" onclick="workspaceNew()">New Workspace</button>
<button class="basicBtn" onclick="workspaceRename()">Rename Workspace</button>
<button class="basicBtn basicBtnRed" onclick="workspaceDelete()">Delete Workspace</button>
<button class="basicBtn" onclick="workspaceExport()">Export Workspace</button>
<button id="move-script" class="basicBtn" onclick="workspaceMoveScript()">Move Script</button>
</div>
</div>
</div>
<div class="div-container">
<div class="div-container-item div-container-border div-container-code">
<ul id="scripts-tab" class="nav nav-tabs"></ul>
<textarea id="scripts" placeholder="Scripts go here"></textarea>
</div>
<textarea id="output" readonly class="div-container-item textarea div-container-textarea"></textarea>
</div>
</div>
<script src="scripts/workspaces.js" defer></script>
<script>
"use strict";
const loadingText = document.getElementById("loadingText");
const loadingDiv = document.getElementById("loadingDiv");
const output = document.getElementById("output");
window.onerror = function(msg, url, line) {
loadingDiv.style.visibility = "hidden";
loadingText.style.display = "inline";
loadingText.textContent = "Something went wrong. :( \n\n" + line + ": " + msg;
}
output.onfocus = function(msg) {
if (typeof(output.copy) !== "undefined") {
output.setSelectionRange(output.copy, this.value.length);
}
}
let worker = new Worker('worker.js');
function runLua(...args) {
if (args[0] == "compile" || args[0] == "workspace") {
// Add this on, so the worker can can create an appropriate importFunc
args.scripts = scripts;
}
worker.postMessage(args);
}
const theme = (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) ? "darcula" : "default";
const editor = CodeMirror.fromTextArea(document.getElementById("scripts"), {
autocapitalize: false,
autocorrect: false,
dragDrop: false,
lineNumbers: true,
lineSeparator: "\n",
spellcheck: false,
readOnly: "nocursor",
theme: theme,
styleActiveLine: true,
matchBrackets: true,
});
editor.on("change", function() {
if (!activeTab || noSave) return;
updateWarn(false);
compileScript();
});
editor.clearHistory();
let emptyHistory = editor.getHistory();
let storageEnabled = false;
let activeTab = false;
let noSave = false;
let scripts = [];
let histories = [];
let scriptCounter = 0;
let exportFormat = "v2";
function compileScript() {
runLua("compile",
[{name: scripts[activeTab.id][0], text: editor.getValue()}],
{format: exportFormat});
}
function updateWarn(status) {
if (!storageEnabled || noSave) return;
const warn = document.getElementById("warning");
if (status) {
warn.textContent = "Saved.";
warn.style.color = "green";
} else {
warn.textContent = "Unsaved.";
warn.style.color = "red";
}
}
function scriptSelect(node) {
workspaceCancelMove();
scriptSave();
output.copy = undefined;
if (activeTab && node == activeTab) {
let tab = activeTab;
setTimeout(function() {
tab.children[0].classList.remove("active");
}, 0);
node = false;
}
activeTab = node;
noSave = true;
if (node == false) {
output.value = "";
editor.setOption("readOnly", "nocursor");
editor.setValue("");
editor.clearHistory();
} else {
editor.setOption("readOnly", false);
editor.setValue(scripts[node.id][1]);
editor.setHistory(histories[node.id]);
compileScript();
}
noSave = false;
}
let draggedOver = [];
let elementHeight;
let id;
function startDragScript(event)
{
elementHeight = event.target.clientHeight;
id = event.target.id; // Using this id only for UI animations, because it's probably not as safe as using dataTransfer for dropping
event.target.firstChild.classList.add("dragged");
event.dataTransfer.setData("id", event.target.id);
}
function endDragScript(event)
{
event.target.firstChild.classList.remove("dragged");
draggedOver.forEach((element) => {element.style.paddingTop = null; element.style.paddingBottom = null});
draggedOver = [];
}
function dragScriptLeave(event)
{
if (event.target.nodeType == 1
&& event.target.classList.contains("nav-link")
&& draggedOver.includes(event.target))
{
event.target.style.paddingBottom = null;
event.target.style.paddingTop = null;
draggedOver.splice(draggedOver.indexOf(event.target), 1);
}
}
function dragScriptOver(event)
{
if (event.target.nodeType == 1
&& event.target.classList.contains("nav-link")
&& !event.target.classList.contains("dragged"))
{
if (!draggedOver.includes(event.target))
{
let targetId = event.target.parentNode.id;
if (id < targetId)
event.target.style.paddingBottom = elementHeight + "px";
else
event.target.style.paddingTop = elementHeight + "px";
draggedOver.push(event.target);
}
event.preventDefault();
}
}
function dropScript(event)
{
const tabs = document.getElementById("scripts-tab");
if (event.target.nodeType != 1 || event.target.classList.contains("dragged") || !tabs.contains(event.target.parentNode)) // Shouldn't happen
{
console.error("A bug happened in the drag-and-drop script");
return ;
}
event.preventDefault();
let data = event.dataTransfer.getData("id");
let element = document.getElementById(data);
let id1 = parseInt(data);
let id2 = parseInt(event.target.parentNode.id);
let sibling = event.target.parentNode;
while (sibling && sibling != element)
{
if (id1 > id2)
sibling.id++;
else
sibling.id--;
sibling = id1 > id2 ? sibling.nextElementSibling : sibling.previousElementSibling;
}
element.id = id2;
tabs.removeChild(element);
if (id2 < id1)
tabs.insertBefore(element, event.target.parentNode);
else
tabs.insertBefore(element, event.target.parentNode.nextElementSibling);
let swap = scripts[id1];
scripts.splice(id1, 1);
scripts.splice(id2, 0, swap);
scriptSave();
}
function scriptNew(name) {
if (typeof(name) !== "string") name = "New " + ++scriptCounter;
const tabs = document.getElementById("scripts-tab");
const temp = document.getElementById("template-nav-item");
const clone = temp.content.cloneNode(true);
clone.children[0].id = scripts.length;
clone.children[0].children[0].textContent = name;
clone.children[0].draggable = true;
clone.children[0].addEventListener("dragstart", startDragScript);
clone.children[0].addEventListener("dragend", endDragScript);
clone.children[0].addEventListener("dragover", dragScriptOver);
clone.children[0].addEventListener("dragleave", dragScriptLeave);
clone.children[0].addEventListener("drop", dropScript);
scripts.push([name, scriptTemplate, currentWorkspace]);
histories.push(emptyHistory);
tabs.appendChild(clone);
}
function scriptImport() {
let input = prompt("Input");
if (!input || input.length == 0) return;
try {
workspaceImportSource(JSON.parse(input));
return;
} catch (e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
}
runLua("import", input);
}
function scriptImportDone(results) {
if (!results[0]) return;
if (!results[1].length) {
output.value = "Import contained no scripts!";
return;
}
for (const scriptData of results[1]) {
scriptNew(scriptData.name);
scripts[scripts.length - 1][1] = scriptData.code;
}
scriptSave();
}
function scriptDelete() {
if (!activeTab) return;
if (!confirm("Are you sure you want to delete " + scripts[activeTab.id][0] + "?")) return;
let node = activeTab;
while (node = node.nextElementSibling) {
node.id = node.id - 1;
}
const tabs = document.getElementById("scripts-tab");
scripts.splice(activeTab.id, 1);
tabs.removeChild(activeTab);
activeTab = false;
scriptSelect(false);
}
function scriptRename() {
if (!activeTab) return;
let input = prompt("Input", activeTab.children[0].textContent);
if (input && input.length > 0) {
activeTab.children[0].textContent = input;
updateWarn(false);
scriptSave();
compileScript();
}
}
function scriptSave() {
if (!storageEnabled || noSave) return;
if (activeTab) {
scripts[activeTab.id][0] = activeTab.children[0].textContent;
scripts[activeTab.id][1] = editor.getValue();
histories[activeTab.id] = editor.getHistory();
}
localStorage.setItem("scripts", JSON.stringify(scripts));
updateWarn(true);
}
function scriptLoad() {
if (!storageEnabled) return;
let data = localStorage.getItem("scripts");
if (data) {
let loaded = JSON.parse(data);
loaded.forEach(function(val) {
scriptNew(val[0]);
scripts[scripts.length - 1] = val;
// Add default workspace to scripts that have no workspace
if (typeof(scripts[scripts.length - 1][2]) !== "string") {
scripts[scripts.length - 1][2] = currentWorkspace;
}
})
}
}
function storageAvailable() {
let storage;
try {
storage = localStorage;
let x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
}
catch(e) {
return e instanceof DOMException && (
// everything except Firefox
e.code === 22 ||
// Firefox
e.code === 1014 ||
// test name field too, because code might not be present
// everything except Firefox
e.name === 'QuotaExceededError' ||
// Firefox
e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
// acknowledge QuotaExceededError only if there's something already stored
(storage && storage.length !== 0);
}
}
worker.onerror = function(error) {
window.onerror(error.message, error.filename, error.lineno);
}
worker.onmessage = function(e) {
let msg = e.data;
let results = msg.results;
let result = {status: results[0], value: results[1]};
if (!result.status) {
output.value = result.value;
}
switch (msg.args[0]) {
case 'ready':
document.getElementById("functionList").innerHTML = result.value;
doneLoading();
break;
case 'compile':
output.value = result.value;
output.copy = results[2];
if (msg.args[1][0].text == editor.getValue()) {
scriptSave();
}
break;
case 'workspace':
output.value = result.value;
output.copy = results[2];
break;
case 'import':
scriptImportDone(results);
break;
case 'unittest':
if (result.status) {
output.value = 'Unittest success!'
}
break;
}
}
function actionListSelect(v)
{
if (!activeTab)
return;
if($('#functionList').data('clicked') == false)
return;
let optGroup = document.querySelector('#functionList option:checked').parentElement.label;
if(optGroup === 'Primitive')
return;
let doc = editor.doc;
let cursor = doc.getCursor();
let line = doc.getLine(cursor.line);
let pos =
{
line: cursor.line,
ch: cursor.ch
}
let filteredReturnTypes = ['impulse', 'int', 'bool', 'double', 'void', 'string', 'type', 'vector']
let rawValue = v;
// Remove return types from the editor inputted action
if(filteredReturnTypes.indexOf(rawValue.substring(0, rawValue.indexOf(' '))) > -1)
rawValue = rawValue.substring(rawValue.indexOf(' ') + 1, rawValue.length);
// Some extra magic to make the insert behave as one would expect
if(cursor.ch === line.length && line.length > 0)
rawValue = '\n' + rawValue;
doc.replaceRange(rawValue, pos);
}
$('#functionList').on('change', function(e)
{
actionListSelect(e.target.value);
});
$('#functionList').on('click', function()
{
$(this).data('clicked', true);
});
$('#functionList').on('keydown', function(e)
{
var code = e.keyCode || e.which;
if(code === 38 || code === 40)
{
$(this).data('clicked', false);
}
else if (code === 13)
{
e.preventDefault();
$(this).data('clicked', true);
actionListSelect($('#functionList option:selected').val());
}
});
function settingsModal() {
const dialog = document.getElementById("setup");
dialog.showModal();
}
function settingsClose() {
const dialog = document.getElementById("setup");
dialog.close();
}
const SETTINGS_NAMES = new Set(["autoSpace", "tabWidth"]);
const SETTINGS_RADIOS = new Map([["exportFormat", "_format"]]);
function settingsLoad() {
if (storageEnabled) {
const settingsVal = JSON.parse(localStorage.getItem("settings") ?? "{}");
for (const [ele, value] of Object.entries(settingsVal)) {
const suffix = SETTINGS_RADIOS.get(ele);
if (suffix != null) {
const domElement = document.getElementById(value + suffix);
if (domElement === null) continue;
domElement.checked = true;
} else if (SETTINGS_NAMES.has(ele)) {
const domElement = document.getElementById(ele);
if (domElement === null) continue;
if (domElement.type === "checkbox") {
domElement.checked = value;
} else {
domElement.value = value;
}
}
}
}
settingsChange();
}
function settingsChange() {
const settingsVal = {};
for (const ele of SETTINGS_NAMES) {
const domElement = document.getElementById(ele);
settingsVal[ele] = (domElement.type === "checkbox") ? domElement.checked : domElement.value;
}
for (const [radio, suffix] of SETTINGS_RADIOS) {
for (const ele of document.getElementsByName(radio)) {
if (ele.checked) {
settingsVal[radio] = ele.id.replace(suffix, "");
}
}
}
if (storageEnabled) {
localStorage.setItem("settings", JSON.stringify(settingsVal));
}
const tabWidth = document.getElementById("tabWidth").value;
editor.setOption("tabSize", tabWidth);
editor.setOption("indentWithTabs", !document.getElementById("autoSpace").checked);
exportFormat = settingsVal.exportFormat;
}
function doneLoading() {
storageEnabled = storageAvailable();
settingsLoad();
updateWarn(true);
scriptLoad();
workspaceLoad();
if (typeof CompressionStream === "undefined") {
document.getElementById("compression").style.display = "inline";
}
loadingText.style.display = "none";
loadingDiv.style.visibility = "visible";
}
output.placeholder = `; Here's a tutorial, and a quick script to showcase it.
; New scripts start with this code, so don't worry about copying it by hand!
; Everything after a semicolon ';' is a comment.
; It doesn't get saved with the script.
; A line that ends with a backslash '\\' continues
; to the next line. This works even for comments,
; which is probably not what you want/expect!
; A line starting with a colon ':' is a compiler declaration.
; Most declarations are variable declarations, taking
; the form :[local/global] [int/double/string] [name]
; Variable names are a combination of letters, digits,
; dots '.' and underscores '_'. Names must start with a
; letter or underscore.
; Names containing special characters, or that reference
; string variables, must use the variable functions.
; These take the form
; [local/global].[int/double/string].[get/set]
; That's a handful, though, so you can use the first
; character in each word for short.
; You can also declare constants by using "const" instead
; of "global", but in this case you have to assign a
; value immediately, since it can't be re-assigned.
; Another type of declaration is :import [file], which
; imports the contents of the named file. Imported files
; can only consist of declarations, macro definitions, and
; comments, they can't produce any "output" (impulses,
; actions, etc). Macro usage is OK only if it doesn't
; produce "output", for instance inside of comments.
; This allows you to import common library macros
; without having to copy them. The compiler will
; ensure that an import only happens once for a given file.
; You can also do :name [script_name] to override the
; name of the script.
; A line starting with a variable name, followed by a
; colon, is defining a label. Labels are special variables.
; They are automatically replaced by a line number, and
; exist to make 'goto' and 'gotoif' easier to use.
; A line starting with a hashtag '#' is defining a macro.
; Simple macros are "#macro_name macro_body".
; Macro-functions can be be defined with
; #macro_name(arg1, arg2, ...) macro_body
; Macros can reference other macros, and also be nested
; inside macro calls. Macros are referenced using curly
; brackets '{}' and act as text replacement.
; An example: "#concat(a, b) {a}{b}" defines a macro
; function that combines its arguments.
; {co{concat(nc,at)}("hi, there")} would result in
; "hi there" by applying the function twice.
; There are two builtin macro-functions: {len()} returns
; the length of its argument (including any whitespace),
; and {lua()} evaluates its argument as a Lua chunk
; (don't forget to return a value!).
; Macros are useful when dealing with large amounts of
; copy-pasted code, and macro-functions are good for
; more complicated code-generation needs.
; Operators, and their precedence:
; ^ // exponent, logarithm (*not* floor-division!)
; * / % multiply, divide, modulo
; + - add, subtract
; . string concatenation. Automatically
converts int/double to string. Usually
requires space to parse correctly.
; == != < <= > >= comparators
; && & and
; || | or
; = assignment. Can be prefixed with other
operators, e.g. '+=', '*='. Must come
2nd on a line, after a variable name!
; Tips: Don't forget to consult the drop-down dialog for
; the full list of all available functions.
; Have fun!
; A fun game: Try guessing what all these lines will compile to,
; then re-import the compiled result and see if you were right.
; This is needed for full-speed execution
:budget_cap max
:local int i
:local double test
:local string var
; Lines that return impulse become... well, impulses
wakeup()
; Lines that return bool become conditions
isTowerTesting()
; This is a macro, one that uses Lua to collapse
; expressions into a single constant
#collapse(expr) {lua(return {expr})}
; Everything else is an action
; All variables are initialized to zero/empty string automatically
label:
dig(i % 4, i / 4)
i += 1
gotoif(label, i < {collapse(4 * 4)})
; You can do math on labels, too!
i = label * 5
; This is how you can use macros to cut down on duplication
#common_expr (i - 2) * (i - 1) / 2
; This is a valid way to use variables, too
global.int.set("a*b", {common_expr})
var = "a*b"
gis(var, {common_expr})
; Continuing a long line. Note the space before the backslash,
; that doesn't get included automatically.
var = "This is a really long string that probably shouldn't keep \\
going on like this and yet it does."
; This is how you use variables as operators
var = '+' ; Single quotes works too
test = a.d(3., var, 0.)
var = "=="
gotoif(99, c.i(3, var, 3))`;
// Firefox has a bug where placeholder text isn't used for size
// calculation, so there won't be scrollbars and the bottom won't be
// viewable. Setting the value also makes it selectable/copyable,
// which helps some people read. Leaving it set as a placeholder means
// it will still appear when there's no output.
output.value = output.placeholder;
const scriptTemplate = output.placeholder.split("Have fun!\n\n")[1];
</script>
</body>
</html>