mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2025-09-21 11:21:05 +00:00
deploy: ef18d7efdf8c433b76874e637152873dbc78a479
This commit is contained in:
1
js/darkmode.557cde7fcc3511a3d7ca8545ecd46d77.min.js
vendored
Normal file
1
js/darkmode.557cde7fcc3511a3d7ca8545ecd46d77.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const userPref=window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark",currentTheme=localStorage.getItem("theme")??userPref,syntaxTheme=document.querySelector("#theme-link");currentTheme&&(document.documentElement.setAttribute("saved-theme",currentTheme),syntaxTheme.href=currentTheme==="dark"?"https://ar.falsy.cat/styles/_dark_syntax.bec558461529f0dd343a0b008c343934.min.css":"https://ar.falsy.cat/styles/_light_syntax.86a48a52faebeaaf42158b72922b1c90.min.css");const switchTheme=e=>{e.target.checked?(document.documentElement.setAttribute("saved-theme","dark"),localStorage.setItem("theme","dark"),syntaxTheme.href="https://ar.falsy.cat/styles/_dark_syntax.bec558461529f0dd343a0b008c343934.min.css"):(document.documentElement.setAttribute("saved-theme","light"),localStorage.setItem("theme","light"),syntaxTheme.href="https://ar.falsy.cat/styles/_light_syntax.86a48a52faebeaaf42158b72922b1c90.min.css")};window.addEventListener("DOMContentLoaded",()=>{const e=document.querySelector("#darkmode-toggle");e.addEventListener("change",switchTheme,!1),currentTheme==="dark"&&(e.checked=!0)})
|
@@ -1 +0,0 @@
|
||||
const userPref=window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark",currentTheme=localStorage.getItem("theme")??userPref,syntaxTheme=document.querySelector("#theme-link");currentTheme&&(document.documentElement.setAttribute("saved-theme",currentTheme),syntaxTheme.href=currentTheme==="dark"?"https://falsy.cat/styles/_dark_syntax.bec558461529f0dd343a0b008c343934.min.css":"https://falsy.cat/styles/_light_syntax.86a48a52faebeaaf42158b72922b1c90.min.css");const switchTheme=e=>{e.target.checked?(document.documentElement.setAttribute("saved-theme","dark"),localStorage.setItem("theme","dark"),syntaxTheme.href="https://falsy.cat/styles/_dark_syntax.bec558461529f0dd343a0b008c343934.min.css"):(document.documentElement.setAttribute("saved-theme","light"),localStorage.setItem("theme","light"),syntaxTheme.href="https://falsy.cat/styles/_light_syntax.86a48a52faebeaaf42158b72922b1c90.min.css")};window.addEventListener("DOMContentLoaded",()=>{const e=document.querySelector("#darkmode-toggle");e.addEventListener("change",switchTheme,!1),currentTheme==="dark"&&(e.checked=!0)})
|
Reference in New Issue
Block a user