// LinkSpin Control Room shell (2026-09-29): the frame every workspace screen shares. // Rail + topbar, session check, in-shell sign-in (email code, same endpoints as the dashboard), // fetch helper, toast, in-page dialogs (never native prompt/confirm). Pages: put content in //
, then CR.mount({active,title,sub,actions}) and CR.requireSession(cb). window.CR = (function () { const $ = id => document.getElementById(id); // network sign-in (2026-11-12): signed in on InstantAdPay = signed in here, no code (netsso.js asks the server once; same file on both sites) try { if (!document.querySelector('script[src^="/assets/netsso.js"]')) { const ns = document.createElement('script'); ns.src = '/assets/netsso.js?v=20261112sso'; ns.async = true; document.head.appendChild(ns); } } catch (e) {} // launch day is 2026-11-15 Central: the pre-launch notice shows only before it function prelaunch() { try { return new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) < '2026-11-15'; } catch (e) { return false; } } const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); const fmt = n => Number(n || 0).toLocaleString(); const NAV = [ ['links', 'Links', '/links', ''], ['sources', 'Sources', '/sources', ''], ['pages', 'Pages', '/pages', ''], ['zones', 'Zones', '/zones', ''], ['ads', 'Ads', '/ads', ''], ['credits', 'Credits', '/credits', ''], ['refuel', 'Refuel', '/credits#refuel', ''], // Monthly Refuel panel on Credits (Marty 2026-10-25: no refuel option in the menu) ['reports', 'Reports', '/reports', ''], ['conversions', 'Conversions', '/conversions', ''], // conversion pixel goals (2026-10-23) ['team', 'Team', '/team', ''], ['tank', 'Holding tank', '/tools#line', ''], // adopters only (2026-11-11): shown by tankItem() ['wallet', 'Wallet', '/wallet', ''], ['promo', 'Promo tools', '/tools#promo', ''], ['training', 'Training', '/tools#training', '', 1], ['pipeline', 'Pipeline', '/tools#pipeline', '', 1], ['profile', 'Profile', '/tools#profile', '', 1], ['forum', 'Earners Corner', 'https://earnerscorner.com/session/sso', ''], // the network forum (2026-11-10), signs in with InstantAdPay ['help', 'Help', '/help', ''], ['tools', 'More', '/tools', ''], ]; // screens not built yet fall back to the classic dashboard pane so nothing is a dead end const FALLBACK = {}; // the classic /my dashboard is retired (2026-10-08); its leftover panes live at /tools const BUILT = new Set(['tank', 'forum', 'links', 'sources', 'pages', 'zones', 'ads', 'credits', 'refuel', 'reports', 'conversions', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16) let ME = null, toastT; // Deep links (2026-10-25): /credits#refuel, /credits#buy and /ads#engine scroll to their panel once it has loaded (and any // sign-in or sponsor pop-up is closed) and flash it, so a button that says "Refuel" lands ON the Refuel panel. const ANCHOR = { refuel: 'rfPanel', buy: 'buyPanel', engine: 'erPanel', kit: 'rkPanel' }; function focusAnchor() { const id = ANCHOR[location.hash.slice(1)]; if (!id) return; const t0 = Date.now(); const tick = () => { const el = $(id); if (!el || el.hidden || !el.offsetParent || document.querySelector('.modal-back')) { if (Date.now() - t0 < 90000) setTimeout(tick, 400); return; } el.scrollIntoView({ behavior: 'smooth', block: 'start' }); el.classList.remove('cr-flash'); void el.offsetWidth; el.classList.add('cr-flash'); // panels above it (packages, purchases) can still be loading and push it down, mostly on phones: settle once more setTimeout(() => { const r = el.getBoundingClientRect(); if (Math.abs(r.top) > 60) el.scrollIntoView({ block: 'start' }); }, 1600); }; setTimeout(tick, 200); } // Arrival strip (2026-10-25, Marty: "it took me to LinkSpin, but I really don't know how to pick up from there"): a link from // InstantAdPay carries ?from=iap&task=; the screen opens with one line naming the job, its first step, a guide and the way back. const ARRIVE = { refuel: ['refuel LinkSpin', 'pick a package of $25 or more (marked "counts for Refuel") under Buy a package, then press Buy. It counts toward the same streak as InstantAdPay.', '/refuel', 'How the Refuel streak works'], conversions: ['set up conversion tracking', 'press Add a goal and name it, for example subscriber or sale. Then paste its two snippets on your pages.', '/conversion-tracking', 'Step-by-step setup guide'], bannerspin: ['make a Banner Spin', 'press + New Banner Spin, pick a banner size and add up to 5 banners. LinkSpin keeps showing the one that gets clicked.'], spinlink: ['make a spin link', 'press + New spin and paste the page you promote. You get one short link to use in your ads.'], testing: ['test A against B', 'open your spin link and add a second page under Destinations (or a second banner to a Banner Spin). The rotation picks the winner.'], page: ['build a page', 'press + New page, fill it in and publish it. Then add it to a spin link.'], ads: ['check your LinkSpin ads', 'your LinkSpin ads are listed on this screen. Open the one you came for to top it up or relaunch it.'], }; const qp = (() => { try { return new URLSearchParams(location.search); } catch (e) { return new URLSearchParams(''); } })(); const ARR = qp.get('from') === 'iap' ? (ARRIVE[qp.get('task')] || ['carry on from InstantAdPay', 'use the menu on the left. Everything here signs in with the same email.']) : null; function arriveStrip() { if (!ARR || $('crArrive')) return ''; if (!document.getElementById('crArriveCss')) { const st = document.createElement('style'); st.id = 'crArriveCss'; st.textContent = '.arrive{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;margin:12px 24px 0;padding:10px 14px;border:1px solid var(--sig,#ff6a1a);border-radius:8px;background:var(--sig-soft,#FFF8F2);font-size:13.5px;line-height:1.45}.arrive .grow{flex:1 1 auto}.arrive button{border:0;background:none;font-size:18px;line-height:1;cursor:pointer;color:inherit;padding:0 2px}@media (max-width:900px){.arrive{margin:10px 16px 0}}.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); } return '
You came from InstantAdPay to ' + esc(ARR[0]) + '. Sign in with the same email you use on InstantAdPay, then Step 1: ' + esc(ARR[1]) + (ARR[2] ? ' ' + esc(ARR[3]) + '' : '') + 'Back to InstantAdPay
'; } // Expired session (Marty 2026-10-23: "told me to sign in but never redirected me"): sessions last 24 h, and a screen // left open past that got 'Sign in first.' errors with no way forward. Any 401 from our API, or coming back to a tab // whose session has lapsed, opens the in-shell sign-in once and reloads the screen after it. let lostOpen = false, lastCheck = Date.now(); function sessionLost() { if (lostOpen) return; lostOpen = true; ME = null; toast('Your session ended. Sign in again to keep going.', true); signInFlow(() => location.reload()); } (function () { const f0 = window.fetch.bind(window); window.fetch = async function (input, init) { const r = await f0(input, init); try { const u = new URL(typeof input === 'string' ? input : input.url, location.href); if (r.status === 401 && u.origin === location.origin && /^\/api\//.test(u.pathname) && !/^\/api\/(auth|me$)/.test(u.pathname) && !/^\/api\/admin\//.test(u.pathname)) sessionLost(); } catch (e) {} return r; }; })(); document.addEventListener('visibilitychange', async () => { if (document.visibilityState !== 'visible' || lostOpen || !ME || !ME.signedIn || Date.now() - lastCheck < 60000) return; lastCheck = Date.now(); const m = await me(true); if (!m || !m.signedIn) sessionLost(); }); // Errors stay until the member closes them (Michael Camire 2026-11-14: a failed top-up's reason vanished after 2 s, // before he could read it); other notes stay long enough to read, a little longer for long ones. function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; document.body.appendChild(t); } const text = String(msg == null ? '' : msg); t.textContent = ''; const sp = document.createElement('span'); sp.className = 'toast-msg'; sp.textContent = text; t.appendChild(sp); const hide = () => { clearTimeout(toastT); t.classList.remove('on'); }; if (bad) { const x = document.createElement('button'); x.type = 'button'; x.className = 'toast-x'; x.setAttribute('aria-label', 'Close this message'); x.textContent = '\u00d7'; x.addEventListener('click', hide); t.appendChild(x); } t.setAttribute('role', bad ? 'alert' : 'status'); t.classList.toggle('bad', !!bad); t.classList.add('on'); clearTimeout(toastT); if (!bad) toastT = setTimeout(hide, Math.min(9000, Math.max(3500, 1500 + text.length * 45))); } async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; } async function get(path) { const r = await (await fetch(path, { headers: { Accept: 'application/json' } })).json(); if (r.error) throw new Error(r.error); return r; } function copy(text) { try { navigator.clipboard.writeText(text).then(() => toast('Copied'), () => toast('Select and copy: ' + text)); } catch (e) { toast('Select and copy: ' + text); } } function dialog(opts) { return new Promise(resolve => { let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); } host.innerHTML = ''; const back = document.createElement('div'); back.className = 'modal-back'; back.innerHTML = ''; host.appendChild(back); const done = v => { host.innerHTML = ''; resolve(v); }; back.querySelector('#dlgNo').addEventListener('click', () => done(null)); back.addEventListener('click', e => { if (e.target === back) done(null); }); back.querySelector('#dlgOk').addEventListener('click', () => { const out = {}; (opts.fields || []).forEach(f => { out[f.k] = back.querySelector('#dlg-' + f.k).value; }); done(opts.fields ? out : true); }); const first = back.querySelector('input,textarea'); if (first) { first.focus(); if (first.select) first.select(); } back.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target.tagName !== 'TEXTAREA') back.querySelector('#dlgOk').click(); if (e.key === 'Escape') done(null); }); }); } // the chat bubble on every Control Room screen (Marty, 2026-10-18: it vanished when /my was retired); once per page function chat() { if (document.getElementById('iapChat') || document.querySelector('script[src^="/assets/chat.js"]')) return; const s = document.createElement('script'); s.src = '/assets/chat.js?v=20261018c'; s.defer = true; document.body.appendChild(s); } function railActive(o) { let a = o.active; if (a === 'credits' && location.hash === '#refuel') a = 'refuel'; return a; } function mount(o) { const page = $('page'); if (!page) return; chat(); if (!document.getElementById('crFlashCss')) { const st = document.createElement('style'); st.id = 'crFlashCss'; st.textContent = '.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); } const act = railActive(o); const app = document.createElement('div'); app.className = 'app'; let railWide = true; try { railWide = localStorage.getItem('cr.rail') !== 'narrow'; } catch (e) {} if (railWide) app.classList.add('wide'); // expanded by default (Marty 2026-10-08), the choice remembered per browser app.innerHTML = '' + '
' + esc(o.crumb || 'Control room') + '

' + esc(o.title || '') + '

' + esc(o.sub || '') + '' + (o.actions || '') + '' + themeSeg('crTheme') + '
' // pre-launch notice (Marty, 2026-10-17): open to everyone from today, official launch November 15; date-driven since 2026-11-02 so it drops off by itself at midnight Central on launch day + (prelaunch() ? '
Pre-launch testing until November 15. Everything is live and working, but features and screens may change while we test. Questions? Use Help.
' : '') + arriveStrip() + '
' + '
rotator checkingserved today ·zones live ·network ·
'; page.parentNode.insertBefore(app, page); app.querySelector('#crBody').appendChild(page); if ($('crArriveX')) $('crArriveX').addEventListener('click', () => { const a = $('crArrive'); if (a) a.remove(); }); // the rail's Refuel item while already on Credits: only the hash changes, so scroll by hand (and again on a repeat click) const paintRail = () => { const a2 = railActive(o); app.querySelectorAll('.rail a[href]').forEach(x => { const k = x.getAttribute('href') === '/credits#refuel' ? 'refuel' : x.getAttribute('href') === '/credits' ? 'credits' : null; if (k) { x.classList.toggle('on', k === a2); if (k === a2) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current'); } }); }; app.querySelectorAll('.rail a[href="/credits#refuel"]').forEach(x => x.addEventListener('click', e => { if (location.pathname !== '/credits') return; e.preventDefault(); history.replaceState(null, '', location.pathname + location.search + '#refuel'); paintRail(); focusAnchor(); })); window.addEventListener('hashchange', () => { paintRail(); focusAnchor(); }); focusAnchor(); $('crRailTog').addEventListener('click', () => { const wide = !app.classList.contains('wide'); app.classList.toggle('wide', wide); try { localStorage.setItem('cr.rail', wide ? 'wide' : 'narrow'); } catch (e) {} }); $('crUserBtn').addEventListener('click', async e => { e.preventDefault(); if (!ME || !ME.signedIn) return signInFlow(() => location.reload()); const v = await dialog({ title: ME.username ? '@' + ME.username : (ME.email || 'Account'), text: 'Signed in on LinkSpin. Your classic dashboard is still at /my.', ok: 'Sign out', no: 'Close', danger: true }); if (v) { const all = await dialog({ title: 'Sign out where?', text: 'Only LinkSpin, or every network site (InstantAdPay, LinkSpin and the others) at once?', ok: 'Everywhere', no: 'Only LinkSpin' }); try { await api(all ? '/api/auth/logout-everywhere' : '/api/auth/logout'); } catch (er) {} location.reload(); } }); clock(); setInterval(clock, 30000); paintTheme(); } // status strip: the clock ticks locally (Central); the readouts come from /api/my/strip once the member is known function clock() { const c = $('stClock'); if (!c) return; try { c.textContent = new Date().toLocaleTimeString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', minute: '2-digit' }) + ' CT'; } catch (e) { c.textContent = ''; } } async function strip() { try { const s = await get('/api/my/strip'); $('stDot').className = 'dot' + (s.ok ? '' : ' off'); $('stHealth').textContent = s.ok ? 'healthy' : 'degraded'; $('stServed').textContent = fmt(s.served); $('stZones').textContent = fmt(s.zones); $('stNet').textContent = s.network ? 'on' : 'off'; } catch (e) { $('stHealth').textContent = 'offline'; } } function whoPaint(m) { const si = $('crArriveSi'); if (si) si.hidden = !!(m && m.signedIn); const w = $('crWho'), a = $('crAv'); if (!w) return; if (m && m.signedIn) { const name = m.username ? '@' + m.username : (m.email || '').split('@')[0]; w.textContent = name; a.textContent = (m.username || m.email || '?').replace(/^@/, '').slice(0, 2).toUpperCase(); } else { w.textContent = 'Sign in'; a.textContent = ''; } } const sub = t => { const s = $('crSub'); if (s) s.textContent = t; }; // ── appearance (2026-11-01): Light / Dark / Auto. The head script (themehead.js) owns window.LSTheme and localStorage // ls.theme; this paints every .theme-seg on the page, saves the choice to the account when signed in, and at sign-in lets // the account value win over the local one (a local choice is pushed up when the account has none yet). const THEMES = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]; function themeSeg(id) { return '' + THEMES.map(([k, l]) => '').join('') + ''; } function storedTheme() { try { const v = localStorage.getItem('ls.theme'); return v === 'light' || v === 'dark' || v === 'auto' ? v : null; } catch (e) { return null; } } function paintTheme() { const c = window.LSTheme ? LSTheme.get() : 'light'; document.querySelectorAll('.theme-seg [data-theme]').forEach(b => { const on = b.dataset.theme === c; b.classList.toggle('on', on); b.setAttribute('aria-pressed', on ? 'true' : 'false'); }); } function themeSync(m) { if (!window.LSTheme) return; const acct = m && m.signedIn && (m.theme === 'light' || m.theme === 'dark' || m.theme === 'auto') ? m.theme : null; const local = storedTheme(); if (acct) { if (acct !== local) LSTheme.set(acct, true); } else if (m && m.signedIn && local) api('/api/my/profile', { theme: local }).catch(() => {}); paintTheme(); } document.addEventListener('click', e => { const b = e.target.closest && e.target.closest('.theme-seg [data-theme]'); if (!b || !window.LSTheme) return; const v = b.dataset.theme; LSTheme.set(v); if (ME && ME.signedIn) api('/api/my/profile', { theme: v }).catch(() => {}); }); window.addEventListener('ls-theme', paintTheme); if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', paintTheme); else paintTheme(); async function me(force) { if (ME && !force) return ME; try { ME = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) { ME = { signedIn: false }; } return ME; } // sign-in inside the shell: email -> six-digit code, on the same endpoints and guards as the dashboard. const FTS = Date.now(); async function signInFlow(onReady) { let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); } host.innerHTML = ''; const email = $('siEmail'), code = $('siCode'), go = $('siGo'), msg = $('siMsg'); let stage = 'email'; email.focus(); const say = (t, bad) => { msg.textContent = t; msg.className = bad ? 'bad' : 'muted'; }; async function step() { try { if (stage === 'email') { const e = email.value.trim(); if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)) return say('That email address does not look right.', true); go.disabled = true; say('Sending…'); // the sign-up guard refuses a form younger than a few seconds (bot defence); wait it out instead of bouncing the person const wait = FTS + 4500 - Date.now(); if (wait > 0) await new Promise(r => setTimeout(r, wait)); const r = await api('/api/auth/email/start', { email: e, fts: FTS, hp_field_x9: '', pick: null }); go.disabled = false; if (r.challenge) { say('One more check is needed for this address. Use the classic dashboard sign-in this once.', true); return; } $('siCodeRow').hidden = false; code.focus(); stage = 'code'; go.textContent = 'Sign in'; if (r.devCode) code.value = r.devCode; say(r.sent ? 'Code sent. Check your inbox, and spam the first time.' : 'Code filled in (local dev).'); } else { go.disabled = true; say('Checking…'); await api('/api/auth/email/verify', { email: email.value.trim(), code: code.value.trim() }); host.innerHTML = ''; ME = null; await me(true); toast('You are in'); try { window.dispatchEvent(new Event('cr:signedin')); } catch (er) {} onReady && onReady(ME); // panels that loaded signed out (Refuel, Engine Room) reload on this } } catch (e) { go.disabled = false; say(e.message, true); } } go.addEventListener('click', step); host.querySelector('.modal').addEventListener('keydown', e => { if (e.key === 'Enter') step(); }); } // login ad on the member's clock (Marty 2026-11-15): every Control Room page asks; the server answers with an ad only when the // last finished view is older than loginAdEveryHours (loginadclock.js), and the end of the countdown restarts that clock let laAsked = false; async function loginAd() { if (laAsked) return; laAsked = true; let ad = null; try { ad = (await get('/api/ads/slot?type=login')).ad; } catch (e) { return; } if (!ad || !ad.targetUrl) return; await new Promise(done => { const back = document.createElement('div'); back.className = 'modal-back'; back.innerHTML = ''; document.body.appendChild(back); back.querySelector('#laOpen').addEventListener('click', () => { window.open(ad.targetUrl, '_blank'); back.querySelector('#laOpen').disabled = true; let left = ad.dwell || 10; const t = back.querySelector('#laTimer'); t.hidden = false; t.textContent = left + ' s'; const iv = setInterval(() => { left -= 1; if (left > 0) { t.textContent = left + ' s'; return; } clearInterval(iv); t.textContent = 'done'; fetch('/api/ads/login/seen', { method: 'POST' }).catch(() => {}); back.querySelector('#laStatus').textContent = 'Thanks for the look.'; back.querySelector('#laGo').hidden = false; }, 1000); }); back.querySelector('#laGo').addEventListener('click', () => { back.remove(); done(); }); }); } // first run: a member needs a username before anything else (it becomes the invite link; permanent once set) async function ensureUsername(m) { if (!m || !m.signedIn || m.username) return m; let suggest = ''; try { suggest = (await get('/api/my/username-suggest')).suggest || ''; } catch (e) {} for (let i = 0; i < 3; i++) { const v = await dialog({ title: 'Pick your username', text: 'This is how your team sees you and it becomes your invite link. It is permanent once saved. Letters, numbers and underscores, 3 to 20 characters.', fields: [{ k: 'username', label: 'Username', value: suggest, placeholder: 'yourname' }], ok: 'Save and continue', no: 'Later' }); if (!v) return m; try { await api('/api/my/profile', { username: String(v.username || '').trim() }); const fresh = await me(true); whoPaint(fresh); toast('Saved. Your invite link is /join/' + fresh.username); return fresh; } catch (e) { toast(e.message, true); suggest = String(v.username || ''); } } return m; } // Holding tank on the rail (Marty 2026-11-11): only for members who can adopt (their own qualifying package, payouts on), // a badge with how many can be adopted right now, and the at-one-time cap from the site setting in its title and on the card function badgeCss() { if (!document.getElementById('crHelpCss')) { const st = document.createElement('style'); st.id = 'crHelpCss'; st.textContent = '.rail a .rbadge{position:absolute;top:3px;right:3px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--sig);color:#fff;font:700 10px/16px var(--mono);text-align:center;box-sizing:border-box}.rail.wide a .rbadge,.app.wide .rail a .rbadge{right:8px;top:50%;transform:translateY(-50%)}'; document.head.appendChild(st); } } async function tankItem() { const a = $('crTank'); if (!a) return null; let r = null; try { r = await get('/api/my/tank/summary'); } catch (e) { return null; } if (!r || !r.adopter) { a.hidden = true; return r; } a.hidden = false; const cap = Number(r.cap) || 0; const t = 'Holding tank: ' + (r.waiting ? fmt(r.waiting) + ' waiting for a sponsor' : 'nobody waiting right now') + '. You can adopt up to ' + cap + ' people at a time.'; a.title = t; a.setAttribute('aria-label', t); badgeCss(); let b = a.querySelector('.rbadge'); if (!r.waiting) { if (b) b.remove(); } else { if (!b) { b = document.createElement('b'); b.className = 'rbadge'; a.appendChild(b); } b.textContent = r.waiting > 999 ? '999+' : String(r.waiting); } return r; } // Help badge on the rail: how many of the member's tickets have a reply from Marty they have not opened (helpdesk.js) async function helpBadge() { const a = $('crHelp'); if (!a) return 0; let n = 0; try { n = Number((await get('/api/my/support/unread')).unread) || 0; } catch (e) { return 0; } badgeCss(); let b = a.querySelector('.rbadge'); if (!n) { if (b) b.remove(); return 0; } if (!b) { b = document.createElement('b'); b.className = 'rbadge'; a.appendChild(b); } b.textContent = n > 9 ? '9+' : String(n); a.title = 'Help: ' + n + ' new repl' + (n === 1 ? 'y' : 'ies'); return n; } // "Who invited you?" (Marty approved 2026-11-07): a member with no sponsor and no member number can name who invited them. // LinkSpin members land on the Control Room, not on the /tools Overview, so it sits at the top of every screen, /tools included. // Soft: nothing waits for it. "Nobody invited me" hides it everywhere; a small link on /tools brings it back. function inviteCard(m) { if ($('crInvite')) $('crInvite').remove(); const ask = m && m.signedIn && !m.memberId && m.inviteAsk; const body = $('crBody'); if (!ask || !body) return; if (ask.dismissed && location.pathname !== '/tools') return; if (!$('crInviteCss')) { const st = document.createElement('style'); st.id = 'crInviteCss'; st.textContent = '.invite{margin:12px 24px;padding:12px 14px;border:1px solid var(--line);background:var(--panel)}.invite h2{font:700 16px Manrope,system-ui;margin:0 0 4px}.invite .row{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;align-items:center}.invite .field{flex:1 1 180px;max-width:280px;margin:0}.invite .bad{color:var(--bad,#c0392b)}@media(max-width:640px){.invite{margin:10px 16px}}'; document.head.appendChild(st); } const box = document.createElement('div'); box.id = 'crInvite'; box.className = 'invite'; body.insertBefore(box, body.firstChild); const full = () => { box.innerHTML = '

Who invited you?

You joined without a sponsor. If someone told you about LinkSpin, type their username and they become your sponsor. Do it before your payouts switch on or you buy: your sponsor locks on the contract at that point.
' + '
'; const say = (t, bad) => { const x = $('inviteMsg'); x.textContent = t || ''; x.classList.toggle('bad', !!bad); }; const go = async () => { say(''); try { const who = $('inviteWho').value; const chk = await api('/api/my/tank/invited', { who, check: true }); const yes = await dialog({ title: 'Who invited you?', text: chk.name + ' becomes your sponsor. ' + (m.address ? 'Your wallet is linked, so your payouts switch on under them right away, and that locks them in for good on the contract.' : 'Your sponsor locks on the contract when your payouts switch on or you buy, so check this is the right person.'), ok: 'Yes, ' + chk.name, no: 'Not them' }); if (!yes) return; const r = await api('/api/my/tank/invited', { who }); box.remove(); toast(r.name + ' is now your sponsor.'); setTimeout(() => location.reload(), 1400); } catch (e) { say(e.message, true); } }; $('inviteGo').addEventListener('click', go); $('inviteWho').addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); go(); } }); $('inviteNo').addEventListener('click', async () => { try { await api('/api/my/tank/invited/dismiss', {}); } catch (e) {} if (location.pathname === '/tools') small(); else box.remove(); }); }; const small = () => { box.innerHTML = 'Remembered who invited you? Tell us'; $('inviteBack').addEventListener('click', e => { e.preventDefault(); full(); $('inviteWho').focus(); }); }; if (ask.dismissed) small(); else full(); } // a network sign-in hop waiting on this sign-in (another site asked "Sign in with LinkSpin" while signed out here): finish it // after the login ad, back to the site and page it came from, never left on the Control Room (2026-11-15) const hopBack = m => { if (m && m.signedIn && m.nssoBack && m.username) { location.href = '/sso/resume'; return true; } return false; }; async function requireSession(onReady) { let m = await me(); whoPaint(m); themeSync(m); if (m && m.signedIn) { strip(); helpBadge(); tankItem(); m = await ensureUsername(m); await loginAd(); if (hopBack(m)) return; inviteCard(m); return onReady(m); } signInFlow(async r => { whoPaint(r); themeSync(r); strip(); helpBadge(); let m2 = await me(true); m2 = await ensureUsername(m2); await loginAd(); if (hopBack(m2)) return; inviteCard(m2); onReady(m2 && m2.signedIn ? m2 : r); }); } // tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first function sparkline(series) { const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return ''; const W = 74, H = 26, max = Math.max(...s), min = Math.min(...s); const pts = s.map((v, i) => [(i / (s.length - 1)) * W, H - 2 - ((v - min) / ((max - min) || 1)) * (H - 4)]); const line = pts.map(p => p[0].toFixed(1) + ',' + p[1].toFixed(1)).join(' '); return ''; } function delta(now, before, label) { now = Number(now) || 0; before = Number(before) || 0; if (!before && !now) return null; if (!before) return { text: 'new' + (label ? ' ' + label : ''), cls: 'flat' }; const pct = Math.round((now - before) / before * 100); return { text: (pct > 0 ? '+' : '') + pct + '%' + (label ? ' ' + label : ''), cls: pct > 0 ? '' : pct < 0 ? 'down' : 'flat' }; } function tile(o) { return '
' + esc(o.k) + '
' + o.v + (o.unit ? '' + esc(o.unit) + '' : '') + '' + sparkline(o.series) + '
' + (o.delta ? '' + esc(o.delta.text) + '' : '') + (o.note ? '' + esc(o.note) + '' : '') + '
'; } return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta, helpBadge, tankItem }; })(); // Network links (2026-11-13): a click on a link to InstantAdPay goes through /go/iap, which signs a signed-in member in over there and is a // plain redirect for everyone else. Rewritten at click time only, so links people copy to share stay clean. data-nogo opts a link out. (function () { if (window.__netlinks) return; window.__netlinks = 1; const HOSTS = ['instantadpay.com', 'www.instantadpay.com']; document.addEventListener('click', e => { if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; const a = e.target && e.target.closest ? e.target.closest('a[href]') : null; if (!a || a.hasAttribute('download') || a.hasAttribute('data-nogo')) return; let u; try { u = new URL(a.href); } catch (x) { return; } if (u.protocol !== 'https:' || !HOSTS.includes(u.hostname)) return; a.href = '/go/iap?to=' + encodeURIComponent(u.pathname + u.search + u.hash); }, true); })();