wiki/assets/js/theme.js
Pk11 06f775b62e Improve support for old browsers
The site is now functional, though not perfect, on the n3DS browser (and also Safari 5.0.6, the Vita browser, and probably more)
2021-06-27 00:28:27 -05:00

36 lines
793 B
JavaScript

function loadTheme() {
const themeCSS = document.getElementById("themeCSS");
if(!localStorage.theme || localStorage.theme == "default") {
if(themeCSS)
themeCSS.remove();
} else {
if(themeCSS) {
themeCSS.href = "/assets/css/" + localStorage.theme +".css";
} else {
const l = document.createElement("link");
l.rel = "stylesheet";
l.type = "text/css";
l.media = "screen";
l.href = "/assets/css/" + localStorage.theme +".css"
l.id = "themeCSS";
document.head.appendChild(l);
}
}
}
function setTheme(theme) {
if(theme == "default")
delete localStorage.theme;
else
localStorage.theme = theme;
loadTheme();
}
loadTheme();
window.onload = function() {
if(localStorage.theme)
document.getElementById("themeSelector").value = localStorage.theme;
}