blob: 47c5dfeb2306449367a522847c86a475f53e1d09 (
plain) (
blame)
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
|
const themeBtn = document.getElementById('changeThemeBtn');
if (darkThemeStyle.disabled)
themeBtn.src = '/img/moon.svg';
themeBtn.style.display = 'initial';
themeBtn.onclick = function() {
darkThemeStyle.disabled = !darkThemeStyle.disabled;
if (localStorage.getItem('theme') !== 'light') {
themeBtn.src = '/img/moon.svg';
localStorage.setItem('theme', 'light');
}
else {
themeBtn.src = '/img/sun.svg';
localStorage.setItem('theme', 'dark');
}
}
/* Keyboard controls */
document.addEventListener('keydown', function (e) {
if (e.ctrlKey) return;
switch (e.code) {
case 'KeyC':
themeBtn.click();
break;
}
});
|