summaryrefslogtreecommitdiff
path: root/js/setColour.js
blob: 4881196ebb686123a41d36f7076526475d8b04d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
function setColour(colour) {
	if ((colour === "black" || colour === "white") || ((colour !== "blue") && (colour !== "green") && (colour !== "red") && (colour !== "yellow"))) {
		colour = "red";
	}
	localStorage.setItem("colour",colour);
	var   root        = document.querySelector(":root");
	var   rootstyle   = getComputedStyle(root);
	const colourValue = rootstyle.getPropertyValue("--" + colour);
	root.style.setProperty("--colour",colourValue);
}