blob: 09de4afba5e6152557acb3036cbd0e319650f904 (
plain)
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
|
/* global PKT_PANEL:false */
function onDOMLoaded() {
if (!window.thePKT_PANEL) {
var thePKT_PANEL = new PKT_PANEL();
/* global thePKT_PANEL */
window.thePKT_PANEL = thePKT_PANEL;
thePKT_PANEL.initStyleGuide();
}
window.thePKT_PANEL.overlay.create();
setupDarkModeUI();
}
function setupDarkModeUI() {
let isDarkModeEnabled = window?.matchMedia(`(prefers-color-scheme: dark)`)
.matches;
let elDarkModeToggle = document.querySelector(`#dark_mode_toggle input`);
let elBody = document.querySelector(`body`);
function setTheme() {
if (isDarkModeEnabled) {
elBody.classList.add(`theme_dark`);
elDarkModeToggle.checked = true;
} else {
elBody.classList.remove(`theme_dark`);
elDarkModeToggle.checked = false;
}
}
setTheme();
elDarkModeToggle.addEventListener(`click`, function(e) {
e.preventDefault;
isDarkModeEnabled = !isDarkModeEnabled;
setTheme();
});
}
if (document.readyState != `loading`) {
onDOMLoaded();
} else {
document.addEventListener(`DOMContentLoaded`, onDOMLoaded);
}
|