// Weekly leaderboards: top 10 by verified visitors sent, top 10 by distinct traffic sources (Central time week). (async function () { VBB.renderNav('/leaders'); VBB.renderFooter(); const $ = VBB.$, esc = VBB.esc; // weekly prize pot (Marty 2026-11-13): grows with sales from a floor; paid each Monday after an admin approves it (prize.js) const c = await VBB.getConfig().catch(() => ({})); const pz = c.prizes || {}; const place = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th']; const plist = (title, arr) => '

' + title + '

'; if ((pz.visitors || []).length || (pz.sources || []).length) { $('pz').innerHTML = ((pz.visitors || []).length ? plist('Most visitors sent', pz.visitors) : '') + ((pz.sources || []).length ? plist('Most traffic sources', pz.sources) : ''); if (pz.pot) $('potLbl').textContent = 'Prize pot this week: ' + (pz.atFloor ? 'at least ' : '') + '$' + VBB.n(pz.pot) + ', and it grows with sales. Half goes to each leaderboard, paid in POL to the top three (dollar value, converted to POL).'; $('prizes').hidden = false; } const d = await VBB.getJSON('/api/leaders'); if (d.error) return VBB.status(d.error, 'err'); const wk = new Date(d.week + 'T12:00:00Z').toLocaleDateString('en-US', { month: 'long', day: 'numeric', timeZone: 'UTC' }); $('weekLbl').textContent = 'Week of Monday ' + wk + ', Central time. Resets every Monday at 12:00 AM. Only verified visitors count: a real browser, on the page a few seconds, once a day per visitor.'; const table = (rows, main) => rows.length ? '' + rows.map((r, i) => '').join('') + '
#Member' + (main === 'visitors' ? 'Visitors' : 'Sources') + '' + (main === 'visitors' ? 'Sources' : 'Visitors') + '
' + (i + 1) + '' + esc(r.name) + '' + VBB.n(r[main]) + '' + VBB.n(main === 'visitors' ? r.sources : r.visitors) + '
' : '

Nobody yet this week. Share your link from My Banners and take the top spot.

'; $('lbVisitors').innerHTML = table(d.visitors, 'visitors'); $('lbSources').innerHTML = table(d.sources, 'sources'); // past weeks: winners and their payment transactions const pr = await VBB.getJSON('/api/prizes').catch(() => ({})); if (pr.past && pr.past.length) { const bn = { visitors: 'Most visitors sent', sources: 'Most traffic sources' }; $('past').innerHTML = pr.past.map(w => { const day = new Date(w.week + 'T12:00:00Z').toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric', timeZone: 'UTC' }); const rows = w.winners.map(x => '' + esc(bn[x.board] || x.board) + '' + x.place + '' + esc(x.name) + '$' + VBB.n(x.usd) + '' + esc(x.pol) + ' POL' + (pr.explorer ? '' + (x.confirmed ? 'Paid' : 'Sent') + '' : esc(x.tx.slice(0, 10))) + '').join(''); return '

Week of ' + esc(day) + '

Prize pot $' + VBB.n(w.potUsd) + (w.priceUsd ? ', POL at $' + Number(w.priceUsd).toFixed(4) : '') + '

' + rows + '
Board#MemberUSDPOLTransaction
'; }).join(''); $('pastCard').hidden = false; } })();