Files
linkspin/public/view.html
T
martbost b84eed3be5 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>
2026-11-01 10:44:40 -06:00

52 lines
3.6 KiB
HTML

<!doctype html>
<html lang="en" data-theme-base="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Viewing ad — LinkSpin</title>
<link rel="icon" type="image/png" href="/logo-icon.png">
<!--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="/assets/site.css?v=ls20261101t">
<style>
html,body{height:100%;margin:0;overflow:hidden}
.vw{display:flex;flex-direction:column;height:100vh;height:100dvh;background:var(--ground,#04110c);color:var(--ink,#e8fff7)}
/* right padding keeps the check buttons clear of the dashboard overlay's ✕ close button */
.vbar{flex:0 0 auto;display:flex;align-items:center;gap:14px;padding:10px 68px 10px 16px;
background:var(--panel-solid,#071a12);border-bottom:1px solid var(--line,rgba(59,157,255,.18));flex-wrap:wrap}
.vbrand{font-family:var(--disp,sans-serif);font-weight:800;font-size:15px;white-space:nowrap}
.vbrand em{color:var(--mint,#3b9dff);font-style:normal}
.vtimer{font-family:var(--mono,monospace);font-weight:700;font-size:14px;border:1px solid var(--line-strong,rgba(59,157,255,.32));
border-radius:999px;padding:5px 14px;min-width:104px;text-align:center}
.vtimer.paused{color:var(--amber,#ffb238);border-color:rgba(255,178,56,.55)}
.vtimer.done{color:var(--mint,#3b9dff)}
.vmsg{font-size:13px;color:var(--muted,#8ba69c);flex:1;min-width:140px}
.vcheck{display:none;align-items:center;gap:8px;flex-wrap:wrap}
.vcheck.on{display:flex}
.vcheck .prompt{font-size:13.5px;font-weight:700}
.vcheck button{font-size:20px;line-height:1;background:var(--panel,rgba(9,26,19,.85));color:inherit;
border:1px solid var(--line-strong,rgba(59,157,255,.32));border-radius:10px;padding:7px 12px;cursor:pointer;margin-right:6px}
.vcheck button:hover,.vcheck button:focus-visible{border-color:var(--mint,#3b9dff);outline:none}
.vdone{display:none;gap:8px;align-items:center}
.vdone.on{display:flex}
.vframe{flex:1;border:0;width:100%;background:#fff}
.vfail{flex:1;display:grid;place-items:center;color:var(--muted,#8ba69c);padding:30px;text-align:center;font-size:15px}
</style>
</head>
<body>
<div class="vw">
<div class="vbar">
<span class="vbrand">Link<em>Spin</em></span>
<span class="vtimer" id="vTimer">…</span>
<span class="vmsg" id="vMsg">Loading the ad…</span>
<span class="vcheck" id="vCheck"><span class="prompt" id="vPrompt"></span><span id="vOpts"></span></span>
<span class="vdone" id="vDone">
<a class="btn small" href="/ads">Back to dashboard</a>
<button class="btn small sec" id="vClose" type="button">Close tab</button>
</span>
</div>
<iframe class="vframe" id="vFrame" sandbox="allow-scripts allow-same-origin allow-forms allow-popups" referrerpolicy="no-referrer" title="Advertiser site"></iframe>
</div>
<script src="/assets/view.js?v=20261008a"></script>
</body>
</html>