Something went wrong. Try again.
My website. cameron.stream
Something went wrong. Try again.
JavaScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788(function () { var btn = document.getElementById("theme-toggle"); var choices = Array.prototype.slice.call(document.querySelectorAll("[data-theme-choice]")); var media = window.matchMedia("(prefers-color-scheme: dark)");
if (!btn && choices.length === 0) return;
function storedTheme() { try { var value = localStorage.getItem("theme"); return value === "dark" || value === "light" ? value : "system"; } catch (_error) { return "system"; } }
var selectedTheme = storedTheme();
function isDark() { var t = document.documentElement.getAttribute("data-theme"); if (t) return t === "dark"; return media.matches; }
function icon(dark) { if (dark) { return '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="3.5"></circle><path d="M12 2.25v2.25M12 19.5v2.25M2.25 12H4.5M19.5 12h2.25M5.11 5.11 6.7 6.7M17.3 17.3l1.59 1.59M18.89 5.11 17.3 6.7M6.7 17.3l-1.59 1.59"></path></svg>'; } return '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20.25 15.17A8.5 8.5 0 0 1 8.83 3.75 8.5 8.5 0 1 0 20.25 15.17Z"></path></svg>'; }
function setTheme(theme) { if (theme !== "system" && theme !== "light" && theme !== "dark") return; selectedTheme = theme;
if (theme === "system") { document.documentElement.removeAttribute("data-theme"); try { localStorage.removeItem("theme"); } catch (_error) { // The system preference still works when storage is unavailable. } } else { document.documentElement.setAttribute("data-theme", theme); try { localStorage.setItem("theme", theme); } catch (_error) { // The current document can still use the requested theme. } } update(); }
function update() { var dark = isDark();
if (btn) { btn.innerHTML = icon(dark); btn.setAttribute("aria-label", dark ? "Use light theme" : "Use dark theme"); btn.setAttribute("title", dark ? "Use light theme" : "Use dark theme"); }
choices.forEach(function (choice) { choice.setAttribute("aria-pressed", choice.getAttribute("data-theme-choice") === selectedTheme ? "true" : "false"); }); }
if (btn) { btn.addEventListener("click", function () { setTheme(isDark() ? "light" : "dark"); }); }
choices.forEach(function (choice) { choice.addEventListener("click", function () { setTheme(choice.getAttribute("data-theme-choice")); }); });
if (typeof media.addEventListener === "function") { media.addEventListener("change", function () { if (selectedTheme === "system") update(); }); }
update();})();