-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
47 lines (37 loc) · 1.26 KB
/
script.js
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
let finalLevel;
const partsArea = document.getElementById('parts');
const finish = document.getElementById('finish');
let partNum = 1;
addPart = () => {
const newPart = document.createElement('div');
newPart.innerHTML = `
<p>Enter Part ${partNum}:</p><textarea name="part${partNum}" id="part${partNum}" cols="60" rows="5"></textarea>`;
partNum++
partsArea.before(newPart);
}
merge = () => {
try {
let name = document.getElementById('name').value;
let inputParts = [];
let partNum = 1;
while (true) {
const currentPart = document.getElementById('part' + partNum);
if (currentPart != null) {
inputParts.push(JSON.parse(currentPart.value));
partNum++;
} else break;
}
finalLevel = m.mergeMain(name, inputParts);
outputText("Level is merged, now copy it.", "rgb(21, 255, 0)");
} catch (e) {
outputText(e + ", check your parts", "red");
}
}
clipboardCopy = () => {
navigator.clipboard.writeText(finalLevel);
outputText("Done!", "rgb(21, 255, 0)");
}
const logs = document.getElementById('logs');
outputText = (text, color) => {
logs.innerHTML = `<p id="important" style="color:${color};">${text}</p>`;
}