-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
42 lines (35 loc) · 954 Bytes
/
init.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
(()=>{
function ael(el, name, fn) {
el.addEventListener(name, fn, false);
}
function qs(selector) {
return document.querySelector(selector);
}
function hide(el) {
el.style.display = "none";
}
function show(el) {
el.style.display = "block";
}
function onclickRunButton() {
hide(qs(".run_button"));
show(qs(".loading_container"));
const scr = document.createElement("script");
qs("body").appendChild(scr);
ael(scr, "load", () => console.log("main.js loaded"));
scr.src = "./main.js";
}
function isEmbedMode() {
const url = new URL(location.href);
return url.searchParams.get("embed") === "1";
}
function init() {
if (isEmbedMode()) {
qs("body").style.margin = 0;
qs("body").style.background = "#444";
qs(".footer").style.display = "none";
}
ael(qs(".run_button"), "click", onclickRunButton);
}
ael(document, "DOMContentLoaded", init);
})();