a428075330
Edits (POST /api/my/spot/<id>, /api/my/default, uploads): still any number of times. Every change now gets the full check:
checkLink, then (LINK_PROBE on) the link must answer (safety.probeLink, up to 3 redirects each checked) and an image address must
download as a real 468x60 image of 150 KB or less (safety.probeImage; the address is kept, a Banner Spin image rotates). The
Banner Spin image + click link LinkSpin just handed the member are not fetched (that would count a LinkSpin click). safety.js gains
privateIp + safeLookup with the Node 20 fix VBB/ViralAdBlitz needed (honors opts.all, answers an array). Every real change is
logged on the spot (or the default): old and new link and image, time, via edit/upload; the owner sees the newest 10. 120 changes
an hour per connection (each one fetches the link).
Admin takedown (the Viral Banner Blitz way, 8e6d2f9): /admin (new page) finds a spot by #number, wallet or network username;
POST /api/admin/spots/<id>/takedown {reason (required, the owner sees it), credit}. Hidden everywhere at once: the board shows a
house tile in its place (nobody else moves), the gate gives its step to a house site, /go/<id> goes home, its Network Ad Space
banner is paused (approved = 0) and no new one is placed. No views or clicks count while down. My Spots shows "Taken down" with
the reason and no edit controls. Restore (POST .../restore) reverses it (NAS resumed). Admin ledger: GET /api/admin/actions (who,
when, reason, credit decision). The contract is never touched.
CREDIT BACK IS NOT BUILT: a spot is a $5 on-chain purchase and this site has no free replacement spot or post credit, so
credit: "back" is refused with a note until Marty decides what it means here; takedowns are "no credit".
Chatbot: CANNED takedown + banner answer (unlimited checked, logged edits) + FACTS EDITS/TAKEDOWN lines, KNOWLEDGE_DATE 2026-11-16.
line.css?v=9, my.js?v=z3.
Tests: smoke section 10 (the lookup shape, edit log, unlimited edits, refusals: unreachable, 404, private address, http redirect,
shortener, bad image size/404/unreachable; redirect followed; same link logs nothing; upload logged; default checked + logged;
takedown: token, reason, credit choice, credit back refused, held house tile, image nowhere, /go home, gate, no views, owner view,
no edits while down, ledger, restore, /admin) against a stand-in internet preloaded into the app (qa/out/probe-stub.cjs, nothing
leaves the machine), plus phone renders of My Spots taken down and /admin: 193/193 with UI. chatbot.test 181/181.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
9.4 KiB
JavaScript
99 lines
9.4 KiB
JavaScript
// My Spots + dashboard: wallet signature sign-in, per-spot image + link editing, default creative, payouts, directs.
|
|
(async function () {
|
|
await BL.renderNav('/my'); BL.renderFooter();
|
|
const $ = BL.$, esc = BL.esc;
|
|
const ROLE = { 0: 'sponsor share', 1: 'line level', 2: 'company A', 3: 'company B', 4: 'fund' };
|
|
const KIND = { 0: 'paid', 1: 'bought for you', 2: 'fund gift', 3: 'fund kept' };
|
|
const c = await BL.getConfig();
|
|
const me = await BL.getJSON('/api/me');
|
|
if (!me.signedIn) {
|
|
// network sign-in (2026-11-13): signed in on InstantAdPay already? One quick hop there and back signs you in here too
|
|
try { const ss = await BL.getJSON('/api/sso/status'); if (ss && ss.check) { location.replace('/sso/start?mode=check&to=' + encodeURIComponent('/my' + location.hash)); return; } } catch (e) {}
|
|
$('signin').hidden = false;
|
|
$('signBtn').onclick = async () => {
|
|
try { BL.status('Check your wallet for the sign-in message.'); await BLWallet.signIn(); location.reload(); }
|
|
catch (e) { BL.status(String(e && e.message || e).slice(0, 300), 'err'); }
|
|
};
|
|
return;
|
|
}
|
|
$('outBtn').onclick = async () => { await BL.post('/api/auth/logout'); location.reload(); };
|
|
$('outAllBtn').onclick = async () => { $('outAllBtn').disabled = true; await BL.post('/api/auth/logout-everywhere'); location.reload(); };
|
|
async function load() {
|
|
const d = await BL.getJSON('/api/my');
|
|
if (d.error) return BL.status(d.error, 'err');
|
|
$('dash').hidden = false; BL.zone($('zMySpots'), 'mySpots'); $('me').textContent = d.username ? '@' + d.username + ' (' + BL.short(d.address) + ')' : d.address;
|
|
const delivered = d.spots.reduce((t, s) => t + s.views, 0);
|
|
$('stats').innerHTML = [['Spots owned', d.spots.length], ['Views delivered', delivered + ' of ' + d.spots.filter(s => s.kind !== 3).length * c.viewsOwed],
|
|
['POL paid in', BL.fmtPol(d.paidInWei)], ['POL paid out to you', BL.fmtPol(d.paidOutWei)]]
|
|
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
|
$('share').value = d.share;
|
|
$('copyBtn').onclick = () => { $('share').select(); try { navigator.clipboard.writeText(d.share); } catch (e) { document.execCommand('copy'); } BL.status('Link copied.', 'ok'); };
|
|
const box = $('spots'); box.innerHTML = '';
|
|
if (!d.spots.length) box.innerHTML = '<p>You have no spots yet. <a href="/join">Get one</a>.</p>';
|
|
for (const s of d.spots) box.appendChild(editor('spot', s));
|
|
$('defaults').innerHTML = ''; $('defaults').appendChild(editor('default', { img: d.defaults.img || '', link: d.defaults.link || '', showing: { img: d.defaults.img || '/art/house-line.svg' } }));
|
|
$('payouts').innerHTML = d.payouts.length ? '<table class="tbl"><tr><th>Spot sold</th><th>Why</th><th>POL</th><th>Tx</th></tr>' + d.payouts.map(p => '<tr><td>#' + p.spotId + '</td><td>' + esc(ROLE[p.role] || p.role) + '</td><td>' + BL.fmtPol(p.amount, 6) + '</td><td class="mono small">' + txLink(p.tx) + '</td></tr>').join('') + '</table>' : '<p class="muted">No payments yet. You are paid when spots sell after yours, or when someone you referred buys.</p>';
|
|
$('directs').innerHTML = d.directs.length ? '<table class="tbl"><tr><th>Member</th><th>Joined</th><th>Spots</th><th>Paid spots</th><th>POL paid in</th></tr>' + d.directs.map(m => '<tr><td class="mono small">' + esc(m.username ? '@' + m.username : BL.short(m.address)) + '</td><td>' + new Date(m.joinedAt).toLocaleDateString() + '</td><td>' + m.spots + '</td><td>' + m.paidSpots + '</td><td>' + BL.fmtPol(m.paidInWei) + '</td></tr>').join('') + '</table>' : '<p class="muted">Nobody has joined through your link yet.</p>';
|
|
}
|
|
const txLink = h => c.explorer ? '<a target="_blank" rel="noopener" href="' + esc(c.explorer + '/tx/' + h) + '">' + esc(h.slice(0, 10)) + '...</a>' : esc(h.slice(0, 10)) + '...';
|
|
function editor(kind, s) {
|
|
const el = document.createElement('div'); el.className = 'spot-ed';
|
|
const head = kind === 'spot' ? '<div class="row" style="justify-content:space-between"><b>Spot #' + s.id + '</b><span class="muted small">' + esc(KIND[s.kind] || '') + ' · ' + s.views + ' of ' + s.owed + ' views'
|
|
+ (s.kind === 3 ? '' : s.delivering ? ' · ' + s.daysLeft + ' days left' : ' · delivery finished') + ' · clicks ' + (s.clicks.organic + s.clicks.gate) + '</span></div>' : '';
|
|
// taken down by the admin (2026-11-16): the reason, and no edit controls (the spot keeps its place; a house banner shows there)
|
|
if (kind === 'spot' && s.down) {
|
|
el.innerHTML = head + '<div class="spot-down"><b>Taken down</b> ' + esc(new Date(s.down.at).toLocaleDateString()) + '. Reason: ' + esc(s.down.reason)
|
|
+ '<br><span class="small muted">It is hidden everywhere and counts no views while it is down; its place is kept. Questions: use the chat on this page.</span></div>';
|
|
return el;
|
|
}
|
|
const hist = kind === 'spot' && s.edits && s.edits.length ? '<p class="small muted">Last change ' + esc(new Date(s.edits[0].at).toLocaleString()) + ' (' + s.edits.length + (s.edits.length >= 10 ? '+' : '') + ' logged). Every change gets the full link check.</p>' : '';
|
|
el.innerHTML = head + hist + '<div class="lots" style="align-items:flex-start"></div>'
|
|
+ '<div class="field"><label class="small muted">Target link (https)</label><input data-k="link" placeholder="https://your-site.com/page" value="' + esc(s.link || '') + '"><span class="small muted">Tracking: {clickid}, {spot} and {type} in your link are filled on every click (LinkSpin has a Downline Banners source ready for this).</span></div>'
|
|
+ '<div class="field"><label class="small muted">Image address (https), or upload below</label><input data-k="img" placeholder="https://your-site.com/image.png" value="' + esc(String(s.img || '').startsWith('/art/u/') ? '' : s.img || '') + '"></div>'
|
|
+ '<div class="row"><button class="btn small" data-a="save">Save</button><label class="btn sec small">Upload image<input type="file" accept="image/png,image/jpeg,image/gif" hidden></label>'
|
|
+ '<button class="btn sec small" data-a="ls">Use a LinkSpin Banner Spin</button></div><div class="ls-pick" hidden></div>';
|
|
const prev = el.querySelector('.lots'); prev.appendChild(BL.tile({ t: 'x', img: (s.showing && s.showing.img) || '/art/house-line.svg', href: s.link || '#' }));
|
|
const url = kind === 'spot' ? '/api/my/spot/' + s.id : '/api/my/default';
|
|
// LinkSpin Banner Spin (2026-11-13): pick one of your 468x60 spins; the image and the tracking link fill in and save
|
|
const pick = el.querySelector('.ls-pick');
|
|
el.querySelector('[data-a=ls]').onclick = async () => {
|
|
pick.hidden = false; pick.innerHTML = '<p class="small muted">Looking up your LinkSpin Banner Spins...</p>';
|
|
const d = await BL.getJSON('/api/my/lsspins');
|
|
if (d.error) { pick.innerHTML = '<p class="note err small">' + esc(d.error) + '</p>'; return; }
|
|
const make = '<a href="https://linkspin.app/links#b" target="_blank" rel="noopener">make one on LinkSpin</a>';
|
|
if (!d.account) { pick.innerHTML = '<p class="small">No LinkSpin account holds this wallet yet. Join LinkSpin (free) with the same email as InstantAdPay, link this wallet there, then ' + make + '.</p>'; return; }
|
|
if (!d.spins.length) { pick.innerHTML = '<p class="small">You have no 468x60 Banner Spin yet: ' + make + ', then come back and tap the button again.</p>'; return; }
|
|
pick.innerHTML = '<p class="small muted">Pick a 468x60 Banner Spin. Its rotating image and tracking link go on this spot, and LinkSpin reports clicks under your Downline Banners source.</p><div class="row"></div>';
|
|
const row = pick.querySelector('.row');
|
|
for (const sp of d.spins) {
|
|
const bt = document.createElement('button'); bt.className = 'btn sec small'; bt.textContent = sp.name + ' (' + sp.banners + ' banners' + (sp.paused ? ', paused' : '') + ')';
|
|
bt.onclick = async () => {
|
|
BL.status('Connecting your Banner Spin...');
|
|
const u = await BL.post('/api/my/lsspins/use', { spinId: sp.id });
|
|
if (u.error || !u.use) return BL.status(u.error || 'Could not use that Banner Spin.', 'err');
|
|
el.querySelector('[data-k=link]').value = u.use.link; el.querySelector('[data-k=img]').value = u.use.img;
|
|
el.querySelector('[data-a=save]').click();
|
|
if (u.use.otherSource) BL.status('Saved. This Banner Spin already reports under another LinkSpin source, so clicks stay there.', 'ok');
|
|
};
|
|
row.appendChild(bt);
|
|
}
|
|
};
|
|
el.querySelector('[data-a=save]').onclick = async () => {
|
|
const link = el.querySelector('[data-k=link]').value.trim(), img = el.querySelector('[data-k=img]').value.trim();
|
|
const body = { link }; if (img || !String(s.img || '').startsWith('/art/u/')) body.img = img;
|
|
const r = await BL.post(url, body);
|
|
if (r.error) return BL.status(r.error, 'err');
|
|
BL.status('Saved.', 'ok'); load();
|
|
};
|
|
el.querySelector('input[type=file]').onchange = async ev => {
|
|
const f = ev.target.files[0]; if (!f) return;
|
|
if (f.size > 150 * 1024) return BL.status('That file is ' + Math.ceil(f.size / 1024) + ' KB. The limit is 150 KB.', 'err');
|
|
const r = await BL.getJSON('/api/my/upload?for=' + (kind === 'spot' ? s.id : 'default'), { method: 'POST', headers: { 'Content-Type': f.type || 'application/octet-stream' }, body: f });
|
|
if (r.error) return BL.status(r.error, 'err');
|
|
BL.status('Image uploaded.', 'ok'); load();
|
|
};
|
|
return el;
|
|
}
|
|
load();
|
|
})();
|