// about.sahik.org (() => { const reduceMotion = matchMedia("(prefers-reduced-motion: reduce)").matches; /* ---------- 開機畫面:每個分頁只播一次,點一下或按任意鍵跳過 ---------- */ if (!reduceMotion && !sessionStorage.getItem("booted")) { sessionStorage.setItem("booted", "1"); const lines = [ "SAHIK BIOS v26.12", "", "CPU Xeon E5-2696 v4 ........ OK", "MEM 256 GB ECC ............. OK", "GPU Tesla M40 24G .......... OK", "NAS 3 × mirror ............. OK", "", "Loading about.sahik.org", ]; const boot = document.createElement("div"); boot.className = "boot"; boot.setAttribute("aria-hidden", "true"); const pre = document.createElement("pre"); boot.appendChild(pre); document.body.appendChild(boot); let i = 0, timer; const finish = () => { clearTimeout(timer); boot.classList.add("done"); setTimeout(() => boot.remove(), 400); removeEventListener("keydown", finish); }; const step = () => { if (i < lines.length) { pre.innerHTML = lines.slice(0, ++i).join("\n") + ' '; timer = setTimeout(step, i === 1 ? 220 : 110); } else { timer = setTimeout(finish, 380); } }; boot.addEventListener("click", finish); addEventListener("keydown", finish); step(); } /* ---------- 伺服器照片切換 ---------- */ document.querySelectorAll("[data-gallery]").forEach((g) => { const main = g.querySelector(".server-photo"); const caption = g.querySelector(".photo-caption"); const thumbs = g.querySelectorAll(".thumbs button"); thumbs.forEach((t) => { t.addEventListener("click", () => { main.src = t.dataset.src; main.alt = t.dataset.alt; caption.textContent = t.dataset.caption; thumbs.forEach((x) => x.setAttribute("aria-pressed", String(x === t))); }); }); }); /* ---------- 頭像彩蛋 ---------- */ const toast = document.querySelector(".toast"); let toastTimer; const say = (msg) => { toast.textContent = msg; toast.classList.add("show"); clearTimeout(toastTimer); toastTimer = setTimeout(() => toast.classList.remove("show"), 2200); }; const avatar = document.querySelector(".avatar-btn"); const msgs = ["?", "咕。", "牠沒有名字。", "再點一下就要發生事情了。"]; let clicks = 0; avatar.addEventListener("click", () => { avatar.classList.remove("wiggle"); void avatar.offsetWidth; avatar.classList.add("wiggle"); if (clicks < msgs.length) { say(msgs[clicks++]); } else { clicks = 0; say("Never gonna give you up ♪"); window.open("https://sahik.dev", "_blank", "noopener"); } }); })();