summaryrefslogblamecommitdiff
path: root/js/setTheme.js
blob: 31cf807b221e5709bd81159bc76adb55d56cb351 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                            








                                                                
         









                                                           
 
function setTheme(theme) {
	localStorage.setItem("theme",theme);
	var   root      = document.querySelector(":root");
	var   rootstyle = getComputedStyle(root);
	const black     = rootstyle.getPropertyValue("--black");
	const white     = rootstyle.getPropertyValue("--white");
	var   bgcol;
	var   fgcol;
	if (theme === "dark") {
		bgcol = black;
		fgcol = white;
	}
	else if (theme === "light") {
		bgcol = white;
		fgcol = black;
	}
	else {
		setTheme("dark");
		return;
	}
	root.style.setProperty("--backgroundColour",bgcol);
	root.style.setProperty("--foregroundColour",fgcol);
}