// Publisher program page (2026-10-10): fills the "Network right now" strip and every rate number from // /api/public/publishers (server-side totals, cached a minute), and points Start at the Zones screen when the visitor // is already signed in (otherwise the join page, zones angle). Display only; nothing here changes an account. (function () { const $ = id => document.getElementById(id); const fmt = n => Number(n || 0).toLocaleString(); const ago = t => { if (!t) return ''; const d = Date.now() - t; if (d < 90e3) return 'updated just now'; if (d < 3600e3) return 'updated ' + Math.round(d / 60e3) + ' min ago'; return 'updated ' + Math.round(d / 3600e3) + ' h ago'; }; async function strip() { let d; try { d = await (await fetch('/api/public/publishers')).json(); } catch (e) { $('stUpdated').textContent = 'live numbers unavailable right now'; $('stDot').classList.add('off'); return; } $('stLive').textContent = fmt(d.live); $('stViews').textContent = fmt(d.viewable7); $('stCredits').textContent = fmt(d.credits7); $('stUpdated').textContent = (d.zones ? fmt(d.zones) + ' zone' + (d.zones === 1 ? '' : 's') + ' installed ยท ' : '') + ago(d.updated); if (!d.live) $('stDot').classList.add('off'); const r = Object.assign({}, d.rates || {}); r.warmup = d.warmup; r.holdPct = Math.round((d.holdRatio || 0.4) * 100); document.querySelectorAll('[data-rate]').forEach(el => { const v = r[el.dataset.rate]; if (v != null && v !== '') el.textContent = fmt(v); }); } // signed in already? then Start opens the Zones screen with the first-run card; the join page otherwise async function start() { try { localStorage.setItem('ls.publisher', '1'); } catch (e) {} let signedIn = false; try { signedIn = (await fetch('/api/my/zones', { cache: 'no-store' })).status === 200; } catch (e) {} if (!signedIn) return; document.querySelectorAll('[data-start]').forEach(a => { a.href = '/zones?start=1'; if (/^Start/.test(a.textContent)) a.textContent = 'Open Zones: add your site'; }); document.querySelectorAll('[data-join]').forEach(a => { a.href = '/links'; a.textContent = 'Control Room'; }); } strip(); start(); setInterval(strip, 60000); })();