Theme switch: auto | light | dark, stored in localStorage ls.theme and on the account, applied before first paint on every page

themehead.js is the one source of the tiny inline head script (and of AUTO_DEFAULT, the one constant Marty decides later: 0 = nothing stored keeps the page's current look, light for Control Room and public pages, dark for the sapphire pages; 1 = follow the device). The script sets data-theme on <html> from ls.theme (auto follows prefers-color-scheme and tracks changes live) and exposes window.LSTheme. tools/stamp-theme-head.cjs writes it into every static page before the first stylesheet with data-theme-base on <html>; blog, leaderboard, what's-new, the badge page, the unsubscribe page and the wall 404 read the module directly. The site CSP allows inline scripts by hash only, so themehead.CSP_HASH joins script-src (the script was silently blocked until then).

Account side: accounts.theme (JSON store and MySQL, alterSafe column), in the public account JSON and /api/me; POST /api/my/profile {theme} rides the existing profile save path and never touches the username. cr-shell.js renders a Light / Dark / Auto segmented control in the topbar of every Control Room screen and paints every .theme-seg on the page (the Profile pane gains an Appearance card with the same control); a click applies at once, saves locally and to the account when signed in; at sign-in the account value wins over the local one, and a local choice is pushed up when the account has none yet. view.html stops reading an undefined --bg so its light variant has a light stage. ?v= tags bumped on every changed stylesheet and script (20261101t / ls20261101t).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-01 10:44:40 -06:00
parent 7c8f204f5a
commit b84eed3be5
42 changed files with 299 additions and 188 deletions
+8 -7
View File
@@ -1,14 +1,15 @@
<!doctype html>
<html lang="en">
<html lang="en" data-theme-base="dark">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>For site owners | LinkSpin</title>
<meta name="description" content="Marty's partner kit for site owners who run a downline builder: the platform in three minutes, how the money moves, what your members get, and what you get for listing LinkSpin.">
<meta name="robots" content="noindex">
<meta name="theme-color" content="#043b2f">
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"light",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("ls.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.LSTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("ls.theme",c);else localStorage.removeItem("ls.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("ls-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@500;700;800&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/site.css?v=ls20260916a">
<link rel="stylesheet" href="/assets/site.css?v=ls20261101t">
<style>
.pk{max-width:820px}
.pk h2{font-size:24px;margin:44px 0 12px;padding-top:20px;border-top:1px solid var(--line)}
@@ -26,11 +27,11 @@
table{border-collapse:collapse;width:100%;margin:10px 0 18px;font-variant-numeric:tabular-nums;font-size:15px}
th,td{text-align:left;padding:9px 10px;border-bottom:1px solid var(--line)} th{color:var(--muted);font-family:var(--mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;font-weight:500}
td:nth-child(2),td:nth-child(3),th:nth-child(2),th:nth-child(3){text-align:right}
.get{border:1px solid #f2c94c;background:rgba(242,201,76,.08);border-radius:14px;padding:18px 22px;margin:16px 0}
.get h3{color:#f2c94c;margin:0 0 8px}
.cta{margin:26px 0 8px;padding:22px;border:1px solid var(--mint);border-radius:14px;background:rgba(59,157,255,.06)}
.get{border:1px solid var(--gold-line);background:var(--gold-soft);border-radius:14px;padding:18px 22px;margin:16px 0}
.get h3{color:var(--gold-2);margin:0 0 8px}
.cta{margin:26px 0 8px;padding:22px;border:1px solid var(--mint);border-radius:14px;background:var(--mint-faint)}
.cta .btn{margin-top:10px}
code{background:rgba(4,8,7,.6);padding:2px 7px;border-radius:6px;font-size:13.5px;word-break:break-all}
code{background:var(--ground-soft);padding:2px 7px;border-radius:6px;font-size:13.5px;word-break:break-all}
@media (max-width:640px){.split{grid-template-columns:1fr 1fr}}
</style>
</head>
@@ -130,7 +131,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261023ov"></script>
<script src="/assets/common.js?v=20261101t"></script>
<script src="/assets/partners.js?v=20261010a"></script>
</body>
</html>