// Front page: the ticker, today's numbers, "Top ads this week" by verified clicks (with "On the wire" and "Boosted" views of the // ads the ticker already shows), the live ledger and the contract box. (async function () { VAB.renderNav('/'); VAB.renderFooter(); const $ = VAB.$, esc = VAB.esc; const d = await VAB.wire('front').catch(() => ({})); const t = d.today || {}; $('stViews').textContent = VAB.n(t.views); $('stClicks').textContent = VAB.n(t.vclicks); $('stBoosts').textContent = VAB.n(t.boosts); $('stAds').textContent = VAB.n(t.ads); const items = (d.board && d.board.items) || []; const wireAds = d.ticker || []; const views = { clicks: () => items.length ? items.map(x => VAB.paper(x, '#' + x.rank, 'board', VAB.n(x.clicks) + ' verified click' + (x.clicks === 1 ? '' : 's'))).join('') : '

No verified clicks yet this week. The first ad clicked by a verified visitor takes #1.

', wire: () => wireAds.length ? wireAds.map(x => VAB.paper(x, x.boosted ? '' : 'LIVE', 'wire')).join('') : '

The wire is quiet. Post the first text ad.

', boosted: () => { const b = wireAds.filter(x => x.boosted); return b.length ? b.map(x => VAB.paper(x, '', 'wire')).join('') : '

No Boosted ads on the wire right now. A Boost stars your ad here and on the ticker.

'; } }; const show = k => { $('boardCards').innerHTML = views[k](); document.querySelectorAll('#board [data-sort]').forEach(b => { const on = b.dataset.sort === k; b.classList.toggle('on', on); b.setAttribute('aria-pressed', on ? 'true' : 'false'); }); VAB.decorate(); }; document.querySelectorAll('#board [data-sort]').forEach(b => { b.onclick = () => show(b.dataset.sort); }); show('clicks'); // the ledger: the newest Boost rows and their payouts const L = await VAB.getJSON('/api/ledger?n=6').catch(() => ({})); const ex = L.explorer || 'https://polygonscan.com'; const who = (a, nm) => nm ? '@' + esc(nm) : esc(VAB.short(a || '')); const rows = []; for (const r of (L.items || [])) { const link = 'verify'; rows.push('' + VAB.when(r.at) + 'Boost bought' + who(r.buyer, r.buyerName) + '' + VAB.polOf(r.weiPaid) + '' + link + ''); for (const p of r.pays || []) if (p.level > 0) rows.push('Paid level ' + p.level + '' + (p.failed ? ' (waiting to be claimed)' : '') + '' + (p.to ? who(p.to, p.name) : 'sponsor') + '' + VAB.polOf(p.wei) + '' + link + ''); } $('ledgerMini').querySelector('tbody').innerHTML = rows.length ? rows.slice(0, 12).join('') : 'No Boosts yet. The first one shows here within a minute of its transaction.'; if (L.contract) { $('cAddr').textContent = 'Polygon · ' + L.contract + ' · read it live'; $('cLink').textContent = 'View the contract proof'; } })();