-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
94 lines (83 loc) · 2.33 KB
/
ui.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
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
import colorScheme from "https://gavinmorrow.github.io/EasyJS/2/ui/colorScheme/index.js";
import Cookie from "https://gavinmorrow.github.io/EasyJS/1/cookies/cookie/index.js";
import cookieConsent from "https://gavinmorrow.github.io/EasyJS/1/cookies/cookieConsent/index.js";
colorScheme.setColors(
{
bg: "#12c0ff",
navBg: "#10befd",
contrastNavBg: "#043b6c",
cardBg: "#32e0ff",
buttonBg: "#22d0ef",
divideBg: "#2c2c2c",
alertBg: "#ffff00",
text: "#063d6e",
subText: "#535353",
link: "#0000ff",
},
{
bg: "#063d6e",
navBg: "#043b6c",
contrastNavBg: "#10befd",
cardBg: "#265d8e",
buttonBg: "#32699a",
divideBg: "#d3d3d3",
alertBg: "#aaaa00",
text: "#12c0ff",
subText: "#acacac",
link: "#adddad",
}
);
const cs = () => {
colorScheme.autoChange = true;
switch (Cookie.get("cs").value) {
case "light":
colorScheme.set(true);
break;
case "dark":
colorScheme.set(false);
break;
default:
case "auto":
colorScheme.reset();
colorScheme.autoChange = true;
break;
}
};
cs();
addEventListener("cs", cs);
window.sleep = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
window.noCache = {
cache: "no-store",
};
window.bbSrc = "https://gavinmorrow.com/bb/src/";
window.bbData = "https://gavinmorrow.com/bb/data/";
cookieConsent();
window.warn = async (reason, time = 5000, autoHide = true) => {
const elem = document.createElement("div");
elem.className = "warning";
switch (reason) {
case "loading":
elem.innerHTML = "Loading…";
break;
default:
elem.innerHTML = reason;
break;
}
document.body.appendChild(elem);
await sleep(1); // Allow the element to be added to the DOM
elem.style.setProperty("right", `var(--border-radius)`);
await sleep(2000); // wait 5s for the transition to finish
await sleep(time); // then wait the ammount of time the caller wants the alert to be shown
const hide = () => elem.style.setProperty("right", `-100vw`);
if (autoHide) hide();
else return { elem, hide };
};
window.ee = (name, find = "") => {
// First, see if you have to find the easter egg or see if it is found
if (find === true) new Cookie(`ee-${name}`, "f");
else if (find === false) Cookie.get(`ee-${name}`).delete();
// Check to see if the user has found the easter egg
const eeCookie = Cookie.get(`ee-${name}`);
if (eeCookie.value === "f") return true;
else return false;
};