added some javascript for theme changing
need to test on other machine
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
var currentTheme = localStorage.getItem('theme');
|
||||
|
||||
console.log("loaded " + JSON.stringify(currentTheme));
|
||||
|
||||
var html = document.getElementsByTagName("html");
|
||||
var body = document.body;
|
||||
var divs = document.getElementsByTagName("div");
|
||||
var links = document.getElementsByTagName("a");
|
||||
|
||||
let checkTheme = () =>
|
||||
{
|
||||
console.log("checking theme, result: " + JSON.stringify(currentTheme));
|
||||
// check for previously set theme
|
||||
if (JSON.stringify(currentTheme) == "dark")
|
||||
{
|
||||
for(let i = 0; i < html.length; i++)
|
||||
{
|
||||
html[i].classList.toggle("dark-mode");
|
||||
}
|
||||
|
||||
body.classList.toggle("dark-mode");
|
||||
|
||||
for(let i = 0; i < divs.length; i++)
|
||||
{
|
||||
divs[i].classList.toggle("dark-mode");
|
||||
}
|
||||
for(let i = 0; i < links.length; i++)
|
||||
{
|
||||
links[i].classList.toggle("dark-mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user