-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (33 loc) · 1.39 KB
/
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function changeTheme() {
var sun = document.getElementById('changeTheme-icon-sun')
var moon = document.getElementById('changeTheme-icon-moon')
var body = document.getElementsByTagName('html')[0]
var theme = body.classList.contains('dark') ? 'dark' : 'light'
var expire = new Date()
expire.setTime(new Date().getTime() + 3600000*24*365)
if (theme === 'dark') {
sun.classList.add('hidden')
moon.classList.remove('hidden')
body.classList.remove('dark')
body.classList.remove('color-scheme-dark')
body.classList.add('color-scheme-light')
document.cookie = 'theme=light;path=/;samesite=Lax;expires=' + expire.toGMTString()
} else {
sun.classList.remove('hidden')
moon.classList.add('hidden')
body.classList.add('dark')
body.classList.add('color-scheme-dark')
body.classList.remove('color-scheme-light')
document.cookie = 'theme=dark;path=/;samesite=Lax;expires=' + expire.toGMTString()
}
}
function openSidemenu() {
document.getElementById('sidemenu').dataset.sidemenuhidden = 'false';
document.getElementById('sidemenu-overlay').dataset.sidemenuhidden = 'false';
lockScroll();
}
function closeSidemenu() {
document.getElementById('sidemenu').dataset.sidemenuhidden = 'true';
document.getElementById('sidemenu-overlay').dataset.sidemenuhidden = 'true';
unlockScroll();
}