-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
45 lines (36 loc) · 1.2 KB
/
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
37
38
39
40
41
42
43
44
45
const toggleSwitch = document.querySelector('select.theme-switch');
function switchTheme(e) {
let val = e.target.value;
if (val) {
document.documentElement.setAttribute('data-theme', val);
localStorage.setItem('theme', val);
}
else {
document.documentElement.removeAttribute('data-theme');
localStorage.removeItem('theme');
}
}
toggleSwitch.addEventListener('change', switchTheme, false);
function checkTheme(){
let theme = localStorage.getItem('theme');
if(theme){
toggleSwitch.value = theme;
document.documentElement.setAttribute('data-theme', theme);
}else{
toggleSwitch.value = undefined;
document.documentElement.removeAttribute('data-theme');
}
}
checkTheme();
(function time(){
var x = document.querySelector('span.c-time');
var y = document.querySelector('span.c-day');
var m = moment();
x.innerHTML = m.format("hh:mm:ss a");
y.innerHTML = m.format("dddd, MMM D");
setInterval(()=>{
var m = moment();
x.innerHTML = m.format("hh:mm:ss a");
y.innerHTML = m.format("dddd, MMM D");
},1000);
})()