-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.js
1 lines (1 loc) · 1.26 KB
/
switch.js
1
!function(){var a;let b=document.getElementById("lightSwitch");function c(){b.checked?function(){document.querySelectorAll(".bg-light").forEach(a=>{a.className=a.className.replace(/-light/g,"-dark")}),document.body.classList.add("bg-dark"),document.body.classList.contains("text-dark")?document.body.classList.replace("text-dark","text-light"):document.body.classList.add("text-light");for(var c=document.querySelectorAll("table"),a=0;a<c.length;a++)c[a].classList.add("table-dark");b.checked||(b.checked=!0),localStorage.setItem("lightSwitch","dark")}():function(){document.querySelectorAll(".bg-dark").forEach(a=>{a.className=a.className.replace(/-dark/g,"-light")}),document.body.classList.add("bg-light"),document.body.classList.contains("text-light")?document.body.classList.replace("text-light","text-dark"):document.body.classList.add("text-dark");for(var c=document.querySelectorAll("table"),a=0;a<c.length;a++)c[a].classList.contains("table-dark")&&c[a].classList.remove("table-dark");b.checked&&(b.checked=!1),localStorage.setItem("lightSwitch","light")}()}b&&(null==(a=localStorage.getItem("lightSwitch"))&&(a=function(){let a=window.matchMedia("(prefers-color-scheme: dark)");return a.matches?"dark":"light"}()),"dark"==a&&(b.checked=!0),b.addEventListener("change",c),c())}()