blowfish/docs/js/appearance.min.4a00b8b8a9118d31826a03a2a9cca83390fcd3eddd9e03868fffcf4dc1e2dc15649e9266091f1225a24e1bcf6558ff4807f77663bcfaaa8f3050d73c1bd5bf0b.js
Nuno Coração 632be5f6bd fix
2022-09-11 22:04:33 +01:00

1 line
No EOL
1.4 KiB
JavaScript

const sitePreference=document.documentElement.getAttribute("data-default-appearance"),userPreference=localStorage.getItem("appearance");(sitePreference==="dark"&&userPreference===null||userPreference==="dark")&&document.documentElement.classList.add("dark"),document.documentElement.getAttribute("data-auto-appearance")==="true"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&userPreference!=="light"&&document.documentElement.classList.add("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{e.matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")})),window.addEventListener("DOMContentLoaded",n=>{const e=document.getElementById("appearance-switcher"),t=document.getElementById("appearance-switcher-mobile");e&&(e.addEventListener("click",()=>{document.documentElement.classList.toggle("dark"),localStorage.setItem("appearance",document.documentElement.classList.contains("dark")?"dark":"light")}),e.addEventListener("contextmenu",e=>{e.preventDefault(),localStorage.removeItem("appearance")})),t&&(t.addEventListener("click",()=>{document.documentElement.classList.toggle("dark"),localStorage.setItem("appearance",document.documentElement.classList.contains("dark")?"dark":"light")}),t.addEventListener("contextmenu",e=>{e.preventDefault(),localStorage.removeItem("appearance")}))})