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"); if (this.localStorage.colorMode == '1'){ toggle.src = "/images/lightMode.png"; root.style.setProperty("--transition-speed", "0.4s"); } }); function toggleBrightness(){ var toggle = document.getElementById("brightness-icon"); 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" 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" localStorage.colorMode = '0'; } }