-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
23 lines (22 loc) · 847 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// START Darkmode
window.toggleDarkmode = function () {
var darkmodeButton = document.getElementById('darkmode-toggle')
var html = document.querySelector('html')
if (!window.darkmode) {
window.localStorage && window.localStorage.setItem('darkmode', true)
html.classList.add('darkmode')
darkmodeButton.setAttribute("aria-pressed", "true")
window.darkmode = true
} else {
window.localStorage && window.localStorage.removeItem('darkmode')
html.classList.remove('darkmode')
darkmodeButton.setAttribute("aria-pressed", "false")
window.darkmode = false
}
}
if (window.localStorage && window.localStorage.getItem('darkmode')) {
document.querySelector('html').classList.add('darkmode')
document.getElementById('darkmode-toggle').setAttribute("aria-pressed", "true")
window.darkmode = true
}
// END Darkmode