This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (58 loc) · 3.44 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Integral Interpreter</title>
<link rel="stylesheet" href="css/main.css">
<script src="dist/encoder.js"></script>
<script src="dist/interpreter.js"></script>
</head>
<body>
<nav>
<img class="btn" id="run-btn" src="images/run.png" alt="Run code">
<img class="btn" id="link-btn" src="images/link.png" alt="Get permalink">
<img class="btn" id="se-btn" src="images/se.png" alt="Get PPCG post">
<span id="byteselm"></span>
</nav>
<section id="main">
<textarea id="code-elm" placeholder="Code goes here..."></textarea>
<textarea id="input-elm" placeholder="Inputs go here..."></textarea>
<textarea id="output-elm" placeholder="Output appears here..." readonly></textarea>
</section>
<br>
<section id="encoders">
<div id="numberencode">
<input type="string" id="numberin" placeholder="Number to encode"> > <input type="text" id="numberout"
readonly placeholder="Encoded number">
</div>
<br>
<div id="stringencode">
<input type="text" id="stringin" placeholder="String to encode"> > <input type="text" id="stringout"
readonly placeholder="Encoded string">
</div>
</section>
</body>
<script>
if (window.location.search) {
document.getElementById("code-elm").value = decodeLink(unescape(window.location.search.split("?code=").join("|").split("&input=").join("|").split("&input").join("|").split("|")[1]));
document.getElementById("input-elm").value = decodeLink(unescape(window.location.search.split("?code=").join("|").split("&input=").join("|").split("&input").join("|").split("|")[2]));
}
document.getElementById("run-btn").addEventListener("click", function () {
document.getElementById("output-elm").value = runlang(document.getElementById("code-elm").value, document.getElementById("input-elm").value);
});
document.getElementById("link-btn").addEventListener("click", function () {
document.getElementById("output-elm").value = "https://nph278.github.io/integral?code=" + escape(encodeLink(document.getElementById("code-elm").value)) + "&input=" + escape(encodeLink(document.getElementById("input-elm").value));
});
document.getElementById("se-btn").addEventListener("click", function () {
const link = "https://nph278.github.io/integral?code=" + escape(encodeLink(document.getElementById("code-elm").value)) + "&input=" + escape(encodeLink(document.getElementById("input-elm").value));
document.getElementById("output-elm").value = "# [Integral], " + document.getElementById("code-elm").value.length + " bytes\n```\n " + document.getElementById("code-elm").value + "\n```\n[Try it]\n\n[Integral]: https://github.com/nph278/integral\n[Try it]: " + link
});
setInterval(function () {
document.getElementById("numberout").value = ";" + encode(+document.getElementById("numberin").value) + ";";
const encoded = encodestr(document.getElementById("stringin").value);
document.getElementById("stringout").value = document.getElementById("stringin").value.length !== 1 ? ("÷" + encoded + "÷") : ("v" + encoded);
document.getElementById("byteselm").innerHTML = String(document.getElementById("code-elm").value.length) + " bytes";
}, 10);
</script>
</html>