-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (25 loc) · 793 Bytes
/
script.js
File metadata and controls
28 lines (25 loc) · 793 Bytes
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
let switches = document.getElementsByClassName('switch');
let style = localStorage.getItem('style');
if (style == null) {
setTheme('light');
} else {
setTheme(style);
}
for (let i of switches) {
i.addEventListener('click', function () {
let theme = this.dataset.theme;
setTheme(theme);
});
}
function setTheme(theme) {
if (theme == 'light') {
document.getElementById('switcher-id').href = './themes/light.css';
} else if (theme == 'sky') {
document.getElementById('switcher-id').href = './themes/sky.css';
} else if (theme == 'purple') {
document.getElementById('switcher-id').href = './themes/purple.css';
} else if (theme == 'dark') {
document.getElementById('switcher-id').href = './themes/dark.css';
}
localStorage.setItem('style', theme);
}