-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepaint.js
More file actions
62 lines (54 loc) · 1.78 KB
/
Copy pathrepaint.js
File metadata and controls
62 lines (54 loc) · 1.78 KB
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
(() => {
const THEMES = {
"Default": { bg: "#fffbef", fg: "#222222" },
"Castle": { bg: "#171628", fg: "#ffffff" },
"ProveIt": { bg: "#223c5f", fg: "#ff3300" },
"HakunaMatata": { bg: "#0c2c73", fg: "#ffffff" },
"Drawer": { bg: "#1d2643", fg: "#02d3be" },
"tooSigma": { bg: "#00a5bd", fg: "#edf9fa" },
"PokerRiver": { bg: "#0e4888", fg: "#e7f2f8" },
"PlainJane": { bg: "#ffffff", fg: "#000000" },
"insiderTrader27": { bg: "#000000", fg: "#00aeef" },
"HormoneReplacementTherapy": { bg: "#fc8404", fg: "#ffffff" },
"Musashi": { bg: "#405270", fg: "#ffffff" },
"Root": { bg: "#000000", fg: "#66b361" }
};
const THEME_ORDER = [
"Default", "Castle", "ProveIt", "HakunaMatata", "Drawer",
"tooSigma", "PokerRiver", "PlainJane", "insiderTrader27",
"HormoneReplacementTherapy", "Musashi", "Root"
];
const STORAGE_KEY = "siteThemeIndex";
function applyTheme(name) {
const t = THEMES[name] || THEMES["Default"];
document.documentElement.style.setProperty("--bg", t.bg);
document.documentElement.style.setProperty("--fg", t.fg);
document.body.style.background = t.bg;
document.body.style.color = t.fg;
}
function getThemeIndex() {
const saved = parseInt(localStorage.getItem(STORAGE_KEY), 10);
if (Number.isInteger(saved) && saved >= 0 && saved < THEME_ORDER.length) {
return saved;
}
return 0;
}
function setThemeIndex(i) {
localStorage.setItem(STORAGE_KEY, String(i));
}
function repaint() {
const next = (getThemeIndex() + 1) % THEME_ORDER.length;
setThemeIndex(next);
applyTheme(THEME_ORDER[next]);
}
function initTheme() {
applyTheme(THEME_ORDER[getThemeIndex()]);
}
window.SiteTheme = {
initTheme,
applyTheme,
repaint,
THEMES,
THEME_ORDER
};
})();