// Shared page helpers (VBB namespace, modelled on Downline Banners' common.js): nav, footer, toasts, fetch helpers. window.VBB = (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())); 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 || {}) }); const n = x => Number(x || 0).toLocaleString('en-US'); function renderNav(active) { const nav = document.createElement('nav'); nav.className = 'top'; const links = [['/', 'The loop'], ['/leaders', 'Leaderboards'], ['/how', 'How it works'], ['/packages', 'Packages'], ['/promote', 'Promote'], ['/my', 'My Banners']]; nav.innerHTML = '
Viral Banner Blitz' + 'Part of the Crypto Team Build Network
'; document.body.prepend(nav); // inside a traffic-exchange frame, the member page opens in a new tab if (framed) document.querySelectorAll('nav a[href="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; }); } // network ad zones (Marty 2026-11-14, the Downline Banners pattern): LinkSpin zones on Marty's account, one per placement, each // mounted once with a small 'Network' label. Footer (wide / phone), Leaderboards, My Banners, How it works; the 404 zone is in // server.js. NEVER on the loop page (/) or admin. An empty id = that placement stays off. const ZONES = { footWide: '', footPhone: '', leaders: '', my: '', how: '' }; function zone(el, key) { if (!el || el.dataset.zoned || !ZONES[key]) return; el.dataset.zoned = '1'; el.classList.add('net-zone'); const lab = document.createElement('div'); lab.className = 'net-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 slot(after) { if (!after || !after.parentNode) return null; const d = document.createElement('div'); d.className = 'net-zone-slot'; after.parentNode.insertBefore(d, after.nextSibling); return d; } function pageZones() { const p = location.pathname.replace(/\/$/, '') || '/'; if (p === '/' || p === '/admin') return; const card = id => { const el = $(id); return el ? el.closest('.card') : null; }; if (p === '/leaders') zone(slot(card('lbVisitors')), 'leaders'); if (p === '/my') zone(slot($('stats')), 'my'); if (p === '/how') zone(slot(document.querySelectorAll('main .card')[1]), 'how'); const za = document.createElement('div'); za.className = 'wrap net-zone-foot'; document.body.appendChild(za); zone(za, window.innerWidth >= 760 ? 'footWide' : 'footPhone'); } function renderFooter() { pageZones(); const f = document.createElement('footer'); f.className = 'foot'; f.innerHTML = '

Viral Banner Blitz, part of the Crypto Team Build Network

' + '

A banner that cycles earns advertising across the network, not cash. Nothing here is an income opportunity.

' + '

The loop · Leaderboards · How it works · Packages · Promote · My Banners

'; document.body.appendChild(f); toasts(); } // live cycle toasts: real cycles from the ledger only, bottom-left, one at a time, never older than 30 minutes let toastsOn = false; function toasts() { if (toastsOn) return; toastsOn = true; const seen = new Set(); let first = true; const box = document.createElement('div'); box.className = 'toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box); const show = c => { const el = document.createElement('a'); el.className = 'toast'; el.href = '/how'; el.innerHTML = '' + (c.name ? esc(c.name) + '\'s banner' : 'A banner') + ' just cycled
' + n(c.views) + ' network ad views earned for its owner'; 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/recent'); } catch (e) { return; } if (!d || !d.cycles) return; const fresh = d.cycles.filter(c => !seen.has(c.id)); d.cycles.forEach(c => seen.add(c.id)); const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false; list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000)); }; tick(); setInterval(tick, 25000); } function tile(t, extra) { const a = document.createElement('a'); a.className = 'tile' + (extra && extra.cls ? ' ' + extra.cls : ''); a.href = t.href; a.target = '_blank'; a.rel = 'noopener'; a.innerHTML = '' + esc(t.owner ? 'Banner by ' + t.owner : 'Member banner #' + t.id) + '' + (extra && extra.pos ? '' + esc(extra.pos) + '' : '') + (t.owner ? '' + esc(t.owner) + '' : ''); const img = a.querySelector('img'); img.src = t.img; img.onerror = () => { img.onerror = null; img.src = '/art/tile-fallback.svg'; }; return a; } return { $, esc, getConfig, short, framed, status, getJSON, post, n, renderNav, renderFooter, tile }; })();