// My page (the member dashboard): sign in (network or wallet), post or edit the one free text ad, the member's page link, their // line, Boost delivery, recent activity and what the contract has paid them. Every figure comes from /api/my; nothing is estimated. (async function () { VAB.renderNav('/my'); VAB.renderFooter(); VAB.wire('other').catch(() => {}); const $ = VAB.$, esc = VAB.esc; const c = await VAB.getConfig().catch(() => ({})); const me = await VAB.getJSON('/api/me'); if (!me.signedIn) { // signed in on InstantAdPay already? one quick hop there and back signs you in here too try { const ss = await VAB.getJSON('/api/sso/status'); if (ss && ss.check) { location.replace('/sso/start?mode=check&via=iap&to=' + encodeURIComponent('/my')); return; } } catch (e) {} $('signin').hidden = false; if (!c.sso) { $('viaIap').hidden = true; $('viaLs').hidden = true; } if (c.joinUrl) $('joinLink').href = c.joinUrl; $('viaWallet').onclick = async () => { try { VAB.status('Check your wallet for the sign-in message.'); await VABWallet.signIn(); location.reload(); } catch (e) { VAB.status(String(e && e.message || e).slice(0, 300), 'err'); } }; return; } $('signout').onclick = async () => { await VAB.post('/api/auth/logout'); location.reload(); }; $('signoutAll').onclick = async () => { $('signoutAll').disabled = true; await VAB.post('/api/auth/logout-everywhere'); location.reload(); }; const counter = (inp, out, max) => { const f = () => { out.textContent = inp.value.length + ' / ' + max; }; inp.addEventListener('input', f); f(); }; const copyText = (t, b) => { const o = b.textContent; try { navigator.clipboard.writeText(t); b.textContent = 'Copied'; setTimeout(() => { b.textContent = o; }, 1400); } catch (e) {} }; const ex = c.explorer || 'https://polygonscan.com'; const vlink = tx => 'verify'; const stat = (label, val, note, cls) => '
' + esc(why || '') + '
'; const c = ls.clicks; return 'Tracked with LinkSpin: ' + esc(ls.link.replace(/^https?:\/\//, '').replace(/\?.*$/, '')) + '' + (c ? ' · ' + VAB.n(c.hits) + ' clicks in all, ' + VAB.n(c.hits30) + ' in 30 days (' + VAB.n(c.unique30) + ' unique)' : ' · clicks show in your LinkSpin Reports') + ' · Open LinkSpin
'; }; // "Use one of my spin links" (2026-11-15): the member's own LinkSpin spin links as the ad link. A spin link is already tracked on // LinkSpin, so "Track with LinkSpin" is switched off (and greyed) while the link is one. The server checks the link is the member's own. let spins = null, spinAd = null; const isSpin = v => { v = String(v || '').trim().toLowerCase(); if (spinAd && v === String(spinAd).toLowerCase()) return true; return !!(spins && spins.some(x => x.url.toLowerCase() === v)); }; const spinMark = () => { const on = isSpin($('fLink').value); $('fTrack').disabled = on; $('trackNote').hidden = !on; $('fTrack').closest('label').style.opacity = on ? '0.6' : ''; }; $('fLink').addEventListener('input', spinMark); $('spinBtn').onclick = async () => { const box = $('spinList'); if (!box.hidden) { box.hidden = true; return; } box.hidden = false; box.innerHTML = 'Asking LinkSpin for your spin links...
'; const r = await VAB.getJSON('/api/my/spins').catch(() => ({ error: 'LinkSpin did not answer. Try again in a minute.' })); if (r.error) { box.innerHTML = '' + esc(r.error) + '
'; return; } spins = r.spins || []; if (!r.account) { box.innerHTML = 'No LinkSpin account was found for your network username yet. Open LinkSpin
'; return; } if (!spins.length) { box.innerHTML = 'You have no spin links on LinkSpin yet. Make one there (add every page you promote), then come back and pick it. Open LinkSpin
'; return; } box.innerHTML = 'Pick one. Your ad sends each click to the next page on that spin link.
' + spins.map((x, i) => '').join(''); box.querySelectorAll('button[data-i]').forEach(b => { b.onclick = () => { const x = spins[Number(b.dataset.i)]; $('fLink').value = x.url; spinMark(); box.hidden = true; VAB.status('Spin link picked. Save your ad to use it.', 'ok'); }; }); }; async function load() { const d = await VAB.getJSON('/api/my'); if (d.error) { VAB.status(d.error, 'err'); return; } $('dash').hidden = false; const a = d.ad; const lim = c.ad || { headline: 60, line: 90 }; const name = d.username ? '@' + d.username : VAB.short(d.address); const boosts = d.boosts || []; const active = boosts.filter(b => b.status === 'delivering'); $('dHello').textContent = 'Welcome back, ' + name; $('whoVia').textContent = d.netVerified ? 'Signed in through the network' : 'Signed in with your wallet'; $('whoName').textContent = name; $('whoAddr').textContent = VAB.short(d.address); // stat cards (lifetime figures of the member's own ad, Boost delivery, contract payouts) const bv = boosts.reduce((s, b) => s + (b.views || 0), 0), bd = boosts.reduce((s, b) => s + Math.min(b.delivered || 0, b.views || 0), 0); $('stats').innerHTML = stat('Verified views of your ad', VAB.n(a ? a.views : 0), 'real visitors, once a day each') + stat('Verified clicks', VAB.n(a ? a.vclicks : 0), 'never your own', 'red') + stat('Boost views delivered', VAB.n(bd), boosts.length ? 'of ' + VAB.n(bv) + ' guaranteed' : 'no Boost yet', 'blue') + stat('Paid to your wallet', VAB.polOf(d.earned && d.earned.wei) + ' POL', 'straight from the contract', 'dark'); // the page link $('pageCard').innerHTML = d.page ? 'Share it anywhere. It shows your ad and the five people above you, and everyone who joins through it shows your ad on their page.
' : 'Your page address uses your network username. Sign in through InstantAdPay or LinkSpin once and it is set.
'; if ($('copyPage')) $('copyPage').onclick = () => copyText(d.page, $('copyPage')); $('copyTop').hidden = !d.page; $('copyTop').onclick = () => copyText(d.page, $('copyTop')); // my text ad: badges, preview, the form (folded behind "Edit ad" once the ad exists) $('adBadges').innerHTML = a ? (a.status === 'live' ? 'LIVE' : '' + esc(a.status.toUpperCase()) + '') + (active.length ? ' ★ BOOSTED' : '') : ''; $('adPrev').innerHTML = a ? 'The people above you in the network, nearest first. Your page shows the first five who have an ad here, and your ad shows on the page of everyone you bring in.
' : '' + (d.lineOk === false ? 'The network line could not be read just now. Try again in a minute.' : 'No sponsor line is known for you in the network yet.') + '
'; // Boosts: the ring for the Boost being delivered now, then every Boost with its delivery const ring = b => { const pct = Math.min(100, Math.round((b.delivered || 0) / b.views * 100)); return 'Anything not delivered on ViralAdBlitz in ' + (c.deliverDays || 30) + ' days is finished through Network Ad Space.
' : 'A Boost is $' + (c.boost ? c.boost.usd : 5) + ' once and buys ' + VAB.n(c.boost ? c.boost.views : 500) + ' guaranteed network views for your ad, plus a starred spot on the ticker.
'); $('boostMore').textContent = boosts.length ? 'Add another Boost, $' + (c.boost ? c.boost.usd : 5) : 'Boost my ad, $' + (c.boost ? c.boost.usd : 5); // recent activity: real events only (payouts to this wallet, this member's Boosts, the ad going live) const ev = []; for (const x of (d.earned && d.earned.items) || []) ev.push({ at: x.at, cls: 'red', h: 'Level ' + x.level + ' paid you ' + VAB.polOf(x.wei) + ' POL', s: (x.buyerName ? '@' + esc(x.buyerName) : 'Someone in your team') + ' bought a Boost' + (x.failed ? ' (waiting in the contract for you to claim)' : '') + ' · ' + vlink(x.tx) }); for (const b of boosts) ev.push({ at: b.at, cls: 'gold', h: 'You bought a Boost', s: VAB.n(b.views) + ' guaranteed views · ' + esc(b.status.replace(/-/g, ' ')) }); if (a && a.createdAt) ev.push({ at: a.createdAt, cls: '', h: 'Your text ad went live', s: 'On your page and your team\'s pages' }); ev.sort((x, y) => (y.at || 0) - (x.at || 0)); $('acts').innerHTML = ev.length ? ev.slice(0, 6).map(e => 'Nothing yet. Post your free text ad to get started.
'; // what the contract paid $('earned').innerHTML = (d.earned && d.earned.items.length) ? d.earned.items.map(x => 'Nothing yet. The contract pays a level share in the same transaction when someone in your team buys a Boost, if you have bought one yourself. Advertising, not income. Nothing is promised.
'; } $('adForm').addEventListener('submit', async e => { e.preventDefault(); $('adSave').disabled = true; VAB.status('Checking your link...'); const r = await VAB.post('/api/my/ad', { headline: $('fHead').value, line1: $('fL1').value, line2: $('fL2').value, link: $('fLink').value, track: $('fTrack').checked }); $('adSave').disabled = false; if (r.error) return VAB.status(r.error, 'err'); VAB.status(r.created ? 'Posted. Your ad is live on your page and on your team\'s pages.' : 'Saved. Your ad shows the new text everywhere.', 'ok'); load(); }); await load(); })();