finish theme switcher

This commit is contained in:
Geindre Colin 2021-02-25 09:28:27 +01:00
parent e0f9462144
commit e2ad52ed3c

View file

@ -133,6 +133,8 @@ window.onload = function() {
} }
} }
var css_url = "/Y/ystyle.css"
if (typeof(Storage) !== "undefined") { if (typeof(Storage) !== "undefined") {
var theme = localStorage.getItem("theme"); var theme = localStorage.getItem("theme");
console.log("theme : " + theme) console.log("theme : " + theme)
@ -160,9 +162,12 @@ window.onload = function() {
option.value = opt; option.value = opt;
option.text = "style " + i.toString(); option.text = "style " + i.toString();
i++; i++;
console.log(option) if (option.value == css_url) {
option.selected = "selected"
}
option.style.outline = "none"
option.style.border = "none"
toggler.appendChild(option); toggler.appendChild(option);
console.log("added option")
} }
toggler.style.position = "absolute" toggler.style.position = "absolute"
@ -176,12 +181,9 @@ window.onload = function() {
toggler.style.color = "#eee" toggler.style.color = "#eee"
toggler.style.zIndex = "12" toggler.style.zIndex = "12"
toggler.style.cursor = "pointer" toggler.style.cursor = "pointer"
toggler.style.outline = "none"
toggler.addEventListener("change", function() { toggler.addEventListener("change", function() {
if (css_url == "/Y/ystyle.css") { css_url = toggler.value
css_url = "/Y/ystyle2.css";
} else {
css_url = "/Y/ystyle.css";
}
changeCSS(css_url, 0) changeCSS(css_url, 0)
}) })
} }
@ -191,7 +193,7 @@ function changeCSS(css_file, cssLinkIndex) {
localStorage.setItem("theme", css_file); localStorage.setItem("theme", css_file);
} }
console.log("changing css") console.log("changing css to " + css_file)
var oldlink = document.getElementsByTagName("link").item(cssLinkIndex); var oldlink = document.getElementsByTagName("link").item(cssLinkIndex);