-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (30 loc) · 927 Bytes
/
script.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
console.log("its working!")
let themeDotes = document.getElementsByClassName('theme-dot')
let theme = sessionStorage.getItem('theme')
if (theme == null) {
setTheme('light')
} else {
setTheme(theme)
}
for (var i = 0; themeDotes.length > i; i++) {
themeDotes[i].addEventListener('click', function () {
let mode = this.dataset.mode
console.log('Option clicked', mode)
setTheme(mode)
})
}
function setTheme(mode) {
if (mode == 'light') {
document.getElementById('theme-style').href = 'default.css'
}
if (mode == 'dark') {
document.getElementById('theme-style').href = 'dark.css'
}
if (mode == 'pink') {
document.getElementById('theme-style').href = 'pink.css'
}
if (mode == 'gray') {
document.getElementById('theme-style').href = 'gray.css'
}
sessionStorage.setItem('theme', mode)
}