-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptTheme.js
More file actions
executable file
·35 lines (34 loc) · 996 Bytes
/
scriptTheme.js
File metadata and controls
executable file
·35 lines (34 loc) · 996 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
29
30
31
32
33
34
35
// console.log("Back to JS baby ");
let theme=localStorage.getItem('theme');
if(theme==null){
setTheme('dark');
}
else{
setTheme(theme);
}
let themeDots=document.getElementsByClassName('theme-dot');
for(let i=0;i<themeDots.length;i++){
themeDots[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='style.css'
}
if(mode=='dark'){
document.getElementById('theme-style').href='/style/dark.css'
}
if(mode=='blue'){
document.getElementById('theme-style').href='/style/blue.css';
}
if(mode=='green'){
document.getElementById('theme-style').href='/style/green.css'
}
if(mode=='purple'){
document.getElementById('theme-style').href='/style/purple.css'
}
localStorage.setItem('theme',mode);
}