44 lines
1.8 KiB
JavaScript

var root = document.querySelector(':root');
if (localStorage.colorMode){
if (localStorage.colorMode == '1'){
root.style.setProperty("--transition-speed", "0s");
root.style.setProperty("--black", "#efefef");
root.style.setProperty("--dark-grey", "#cbcbcb");
root.style.setProperty("--light-grey", "#a9a9a9");
root.style.setProperty("--white", "#141414");
}
}else{
localStorage.colorMode = '0';
}
window.addEventListener("load", function(){
var toggle = document.getElementById("brightness-icon");
var fury = document.getElementById("fury");
if (this.localStorage.colorMode == '1'){
toggle.src = "/images/lightMode.png";
if (fury != null) fury.src = "/images/lightfury.gif";
root.style.setProperty("--transition-speed", "0.4s");
}
});
function toggleBrightness(){
var toggle = document.getElementById("brightness-icon");
var fury = document.getElementById("fury");
if (getComputedStyle(root).getPropertyValue('--black') == "#141414"){
root.style.setProperty("--black", "#efefef");
root.style.setProperty("--dark-grey", "#cbcbcb");
root.style.setProperty("--light-grey", "#a9a9a9");
root.style.setProperty("--white", "#141414");
toggle.src = "/images/lightMode.png"
if (fury != null) fury.src = "/images/lightfury.gif";
localStorage.colorMode = '1';
}else{
root.style.setProperty("--black", "#141414");
root.style.setProperty("--dark-grey", "#1f1f1f");
root.style.setProperty("--light-grey", "#333333");
root.style.setProperty("--white", "#e6e6e6");
toggle.src = "/images/darkMode.png"
if (fury != null) fury.src = "/images/toothless-dragon-toothless.gif";
localStorage.colorMode = '0';
}
}