// Shared page helpers (BL namespace, modelled on InstantAdPay common.js). window.BL = (function () { let cfgP = null; const $ = id => document.getElementById(id); const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json())); function fmtPol(wei, dp) { try { const w = BigInt(wei || 0); const whole = w / 10n ** 18n; const frac = (w % 10n ** 18n).toString().padStart(18, '0').slice(0, dp || 4).replace(/0+$/, ''); return whole.toString() + (frac ? '.' + frac : ''); } catch (e) { return '0'; } } const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : ''; const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })(); function status(msg, cls) { const el = $('status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; } async function getJSON(url, opts) { const r = await fetch(url, opts); let j = {}; try { j = await r.json(); } catch (e) {} if (!r.ok && !j.error) j.error = 'Request failed (' + r.status + ')'; return j; } const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); async function renderNav(active) { const c = await getConfig().catch(() => ({})); const n = document.createElement('nav'); const links = [['/', 'Home'], ['/board', 'Board'], ['/how', 'How it works'], ['/ledger', 'Ledger'], ['/join', 'Get a spot'], ['/promote', 'Promote'], ['/my', 'My Spots']]; n.innerHTML = '
' + '
'; document.body.prepend(n); if (c && c.chainId && c.chainId !== 137) { const r = document.createElement('div'); r.className = 'rehearsal'; r.innerHTML = 'Rehearsal: this runs on ' + esc(c.chainName) + '. Test POL only, no real money.'; n.after(r); } // inside a traffic-exchange frame, member and buy pages open in a new tab with the sponsor carried along if (framed) document.querySelectorAll('nav a[href="/join"], nav a[href="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; }); } function renderFooter() { const za = document.createElement('div'); za.className = 'wrap bl-zone-foot'; document.body.appendChild(za); zone(za, window.innerWidth >= 760 ? 'footWide' : 'footPhone'); const f = document.createElement('footer'); f.className = 'bl-foot'; f.innerHTML = '

Part of the Crypto Team Build Network

' + '

A spot buys 300 guaranteed views on the board and a place in the line. Nothing is promised: you are paid only when spots sell after yours, and a spot can earn back less than it cost.

' + '

How it works · Board · Live ledger · Contract proof · Promote · My Spots

' // trust pack (Marty 2026-11-14): legal + proof links, company line, and the network line served by the hub + '' + '

TrustClickz · 615 Green Valley Drive, Moody, AL 35004

'; document.body.appendChild(f); netLine(f.querySelector('.netline')); toasts(); } // "Part of the network": the list comes from the hub through /api/network-sites, the built-in copy if it does not answer const NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'], ['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] })); function netLine(el) { if (!el) return; const paint = list => { el.innerHTML = 'Part of the network · One account across the network: ' + list.map(s => (s.id === 'dlb' || /downlinebanners\.com/.test(s.url)) ? '' + esc(s.name) + '' : '' + esc(s.name) + '').join(' · '); }; paint(NET); fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l); }).catch(() => {}); } // one spot tile; href goes through the /go relay, which counts the click function tile(t, opts) { const a = document.createElement('a'); a.className = 'lot' + (t.t !== 'spot' ? ' house' : ''); a.href = t.href; a.target = '_blank'; a.rel = 'noopener'; const img = document.createElement('img'); img.src = t.img; img.width = 468; img.height = 60; img.alt = t.t === 'spot' ? 'Spot #' + t.id : (t.title || 'Network'); img.loading = 'lazy'; img.referrerPolicy = 'no-referrer'; img.onerror = () => { img.onerror = null; img.src = '/art/house-line.svg'; }; a.appendChild(img); if (opts && opts.meta) { const m = document.createElement('span'); m.className = 'lot-meta'; m.textContent = t.t === 'spot' ? '#' + t.id : 'network'; a.appendChild(m); } return a; } // live sale toasts (Marty 2026-11-13): real sales from the ledger only, bottom-left, one at a time, never older than 30 minutes let toastsOn = false; async function toasts() { if (toastsOn) return; toastsOn = true; const seen = new Set(); let first = true; const box = document.createElement('div'); box.className = 'bl-toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box); const show = it => { const top = it.pays.filter(p => !p.failed).sort((a, b) => (BigInt(b.wei) > BigInt(a.wei) ? 1 : -1))[0]; const name = it.ownerName ? '@' + esc(it.ownerName) : esc(String(it.owner || '').slice(0, 6) + '...' + String(it.owner || '').slice(-4)); // never a blank buyer (Marty 2026-11-14) const el = document.createElement('a'); el.className = 'bl-toast'; el.href = '/ledger'; el.innerHTML = '' + name + ' took spot #' + it.spotId + (top ? '
' + (it.pays.length > 1 ? it.pays.length + ' members paid, ' : '') + (top.name ? '@' + esc(top.name) : 'a member') + ' got ' + fmtPol(top.wei, 2) + ' POL' : '
paid on-chain, $5'); box.appendChild(el); requestAnimationFrame(() => el.classList.add('in')); setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000); }; const tick = async () => { let d; try { d = await getJSON('/api/ledger?n=5'); } catch (e) { return; } if (!d || !d.items) return; const fresh = d.items.filter(it => !seen.has(it.tx) && (!it.at || Date.now() - it.at < 30 * 60000)); d.items.forEach(it => seen.add(it.tx)); const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false; list.forEach((it, i) => setTimeout(() => show(it), 1500 + i * 8000)); }; tick(); setInterval(tick, 25000); } // network ad zones (Marty 2026-11-13): LinkSpin zones on Marty's account, one per placement, mounted once (never re-rendered, // so a view is counted once); a small 'Network' label so they never pass for a member's spot const ZONES = { ledger: 'ls-d53e5d', footWide: 'ls-fd1e0a', footPhone: 'ls-46cbab', bought: 'ls-03783e', mySpots: 'ls-50eaeb', how: 'ls-79e849', contract: 'ls-bd7632' }; function zone(el, key) { if (!el || el.dataset.zoned || !ZONES[key]) return; el.dataset.zoned = '1'; el.classList.add('bl-zone'); const lab = document.createElement('div'); lab.className = 'bl-zone-label'; lab.textContent = 'Network'; const s = document.createElement('script'); s.async = true; s.src = 'https://linkspin.app/z.js'; s.setAttribute('data-zone', ZONES[key]); el.appendChild(lab); el.appendChild(s); } function withRef(href, sponsor) { if (!sponsor) return href; return href + (href.includes('?') ? '&' : '?') + 'ref=' + encodeURIComponent(sponsor); } return { $, esc, getConfig, fmtPol, short, framed, status, getJSON, post, renderNav, renderFooter, tile, withRef, zone }; })();