Public Access
A Zola site in site/, from the design: both themes on the device's palette, notched shapes, self-hosted fonts, the wordmark and icons, two generated hero drawings, nine App cards (the mesh messenger marked planned), real screenshots, the updates and build sections. The Install page builds ESP Web Tools' manifest in the browser from the Gitea API (it needs Caddy to allow the origin), refuses any download that isn't on the project's server, and falls back to the esptool steps. Downloads lists the releases. The focus ring shows on notched controls. A page checker fails the build if a page loads from another origin. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
// The theme switch. Without JavaScript the page follows the visitor's setting (prefers-color-scheme);
|
|
// this adds a button that overrides it, remembered in this browser only.
|
|
(function () {
|
|
var root = document.documentElement;
|
|
root.classList.add("js");
|
|
try {
|
|
var saved = localStorage.getItem("theme");
|
|
if (saved === "dark" || saved === "light") root.setAttribute("data-theme", saved);
|
|
} catch (e) { /* storage blocked: the setting just isn't remembered */ }
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
var button = document.getElementById("theme-toggle");
|
|
if (!button) return;
|
|
function current() {
|
|
return root.getAttribute("data-theme") || (window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark");
|
|
}
|
|
function show() {
|
|
var next = current() === "dark" ? "light" : "dark";
|
|
button.textContent = next === "light" ? "Light" : "Dark";
|
|
button.setAttribute("aria-label", "Switch to the " + next + " theme");
|
|
}
|
|
button.addEventListener("click", function () {
|
|
var next = current() === "dark" ? "light" : "dark";
|
|
root.setAttribute("data-theme", next);
|
|
try { localStorage.setItem("theme", next); } catch (e) { /* see above */ }
|
|
show();
|
|
});
|
|
show();
|
|
});
|
|
})();
|