-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.min.js
1 lines (1 loc) · 1.3 KB
/
script.min.js
1
const sections=document.querySelectorAll("section");sections.forEach((function(e){const t=e.querySelectorAll("a");if(1==t.length){const o=t[0].getAttribute("href");e.addEventListener("click",(function(){window.location.href=o}))}else e.classList="noAutoLink"}));const modeDiv=document.createElement("div");function defineMode(e){"light"==e?(modeDiv.textContent="🌙",githubIcon.src=githubIconSrcBase+".svg"):(modeDiv.textContent="☀️",githubIcon.src=githubIconSrcBase+"-white.svg"),document.documentElement.setAttribute("data-theme",mode)}modeDiv.className="mode",document.body.insertBefore(modeDiv,document.querySelector("header")),modeDiv.addEventListener("click",(()=>{mode="dark"==mode?"light":"dark",defineMode(mode)}));const githubIcon=document.querySelector('img[alt*="Github"]'),githubIconSrcBase="img/github";let mode="light";window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?(githubIcon.src=githubIconSrcBase+"-white.svg",mode="dark",defineMode(mode)):(githubIcon.src=githubIconSrcBase+".svg",mode="light",defineMode(mode)),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(e=>{"dark"==(e.matches?"dark":"light")?(mode="dark",githubIcon.src=githubIconSrcBase+"-white.svg",defineMode(mode)):(mode="light",githubIcon.src=githubIconSrcBase+".svg",defineMode(mode))}));