One swap per banner + admin takedown (Marty 2026-11-15: "allow the member to swap it only, and they can only do it one time. Admin takes down the option to credit back or none.")
Member swap: My Banners shows "Swap image or link" on a banner that is waiting or in the loop, usable once (then "Swap used"). POST /api/my/banners/<id>/swap changes the image and/or link (or a Banner Spin to another of the member's own 125x125/250x250 spins via lsspins), same checks as a new post (checkLink, probeLink, upload/https image checks); id, place, clicks and loop progress stay. Logged on the banner (swaps: old/new image + link, time). No withdraw, removal or refund for members.
Admin takedown: /admin finds banners (#id, wallet, username), POST /api/admin/banners/<id>/takedown {reason required, credit: back|none}. The banner is hidden at once (splash loop + waiting line show a house tile in its place, /go goes home, no look/teaser/swap); its place rides out on time so nobody moves, then it ends with no cycle, no network views, no prize count. My Banners shows "Taken down" with the reason. Restore reverses a given credit (when the owner still holds one) and, if its place rode out meanwhile, records the cycle then. Admin ledger: GET /api/admin/actions (who, when, reason, credit decision).
Chatbot: CANNED 'swap' + FACTS line (KNOWLEDGE_DATE already 2026-11-15), chat-qa entry. my.js?v=4, admin.js?v=3, vbb.css?v=8.
Tests: smoke section 15 (swap once, refused twice, keeps place, bad link/image refused, spin swap, takedown credit back vs none, others keep places, ride-out without a cycle, restore, admin ledger, phone UI): 308/308 with the committed networksso.js; chatbot.test 182/182; qa:chain 49/49.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+51
-1
@@ -13,7 +13,7 @@
|
||||
['Shifts today', s.today.shifts], ['Cycles today', s.today.cycles], ['Visitors today', s.today.visits], ['Cycles total', s.totals.cycles], ['Views recorded', VBB.n(s.ledger.views)], ['Views credited', VBB.n(s.ledger.credited)], ['Members', s.members]]
|
||||
.map(x => '<div class="stat"><b>' + esc(x[1]) + '</b><span>' + esc(x[0]) + '</span></div>').join('');
|
||||
$('aRaw').textContent = JSON.stringify(s, null, 2);
|
||||
prizes(); setInterval(prizes, 30000);
|
||||
prizes(); setInterval(prizes, 30000); actions();
|
||||
const l = await get('/api/admin/ledger?n=300');
|
||||
const who = r => r.username ? '@' + r.username : VBB.short(r.address || r.owner);
|
||||
$('aMembers').innerHTML = l.members && l.members.length ? '<table class="t"><tr><th>Member</th><th class="n">Cycles</th><th class="n">Views</th></tr>' + l.members.map(m => '<tr><td>' + esc(who(m)) + '</td><td class="n">' + m.cycles + '</td><td class="n">' + VBB.n(m.views) + '</td></tr>').join('') + '</table>' : '<p class="muted">No cycles yet.</p>';
|
||||
@@ -57,6 +57,56 @@
|
||||
const r = await VBB.getJSON('/api/admin/prizes/prepare', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: '{}' });
|
||||
VBB.status(r.error || 'Prepared the week of ' + r.week + '.', r.error ? 'err' : 'ok'); prizes();
|
||||
};
|
||||
// ---- banner takedown / restore (Marty 2026-11-15): reason required, credit back or none; restore takes a given credit back ----
|
||||
const send = (u, body) => VBB.getJSON(u, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: JSON.stringify(body) });
|
||||
const ct = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT' : '';
|
||||
async function actions() {
|
||||
const a = await get('/api/admin/actions?n=200'); if (a.error) return;
|
||||
$('aActions').innerHTML = a.actions.length ? '<table class="t"><tr><th>When (CT)</th><th>Action</th><th>Banner</th><th>Owner</th><th>By</th><th>Reason</th><th>Credit</th></tr>'
|
||||
+ a.actions.map(e => '<tr><td>' + esc(ct(e.at)) + '</td><td>' + esc(e.action) + (e.cycleRecorded ? ' (cycle recorded)' : '') + '</td><td>#' + e.bannerId + '</td><td>' + esc(e.username ? '@' + e.username : VBB.short(e.owner)) + '</td><td>' + esc(e.by) + '</td><td>' + esc(e.reason || '') + '</td><td>' + esc(e.credit) + '</td></tr>').join('') + '</table>'
|
||||
: '<p class="muted">No takedowns yet.</p>';
|
||||
}
|
||||
async function findBanners() {
|
||||
const q = $('bnQ').value.trim(); if (!q) return;
|
||||
const d = await get('/api/admin/banners?q=' + encodeURIComponent(q));
|
||||
if (d.error) { $('bnList').innerHTML = '<p class="note err small">' + esc(d.error) + '</p>'; return; }
|
||||
$('bnList').innerHTML = '';
|
||||
for (const b of d.banners) {
|
||||
const el = document.createElement('div'); el.className = 'adm-b';
|
||||
const st = b.down ? 'TAKEN DOWN ' + ct(b.down.at) + ' by ' + b.down.by + ': ' + b.down.reason + (b.down.creditBack ? ' (credit given back)' : ' (no credit)') + '. Slot: ' + b.state
|
||||
: b.state === 'queued' ? 'Waiting #' + b.position + ' of ' + b.of : b.state === 'loop' ? 'In the loop, place ' + b.place + ' of ' + b.of : b.state;
|
||||
el.innerHTML = '<img alt="Banner #' + b.id + '" width="72" height="72"><div class="s"><b>#' + b.id + '</b> ' + esc(b.username ? '@' + b.username : '') + ' <span class="mono small">' + esc(b.owner) + '</span><br>'
|
||||
+ esc(st) + '<br>Link: <span class="mono small">' + esc(b.link) + '</span><br><span class="muted small">' + VBB.n(b.clicks) + ' clicks. Posted ' + esc(ct(b.createdAt)) + '.'
|
||||
+ (b.swaps.length ? ' Swapped ' + esc(ct(b.swaps[0].at)) + ' from ' + esc(b.swaps[0].old.link) + '.' : '') + (b.downs.length ? ' Restored before: ' + b.downs.length + 'x.' : '') + '</span><div class="act"></div></div>';
|
||||
el.querySelector('img').src = b.img;
|
||||
const act = el.querySelector('.act');
|
||||
if (b.down) {
|
||||
act.innerHTML = '<div class="field"><label>Why restore (optional)</label><input class="rs"></div><button class="btn small">Restore this banner' + (b.down.creditBack ? ' (takes the credit back)' : '') + '</button>';
|
||||
act.querySelector('button').onclick = async () => {
|
||||
const r = await send('/api/admin/banners/' + b.id + '/restore', { reason: act.querySelector('.rs').value });
|
||||
VBB.status(r.error || ('Banner #' + b.id + ' restored.' + (r.creditReversed ? ' The credit was taken back.' : r.creditAlreadyUsed ? ' The owner already used the credit, so it was not taken back.' : '') + (r.cycle ? ' Its place had ridden out, so its cycle is recorded now.' : '')), r.error ? 'err' : 'ok');
|
||||
findBanners(); actions();
|
||||
};
|
||||
} else if (b.state === 'queued' || b.state === 'loop') {
|
||||
act.innerHTML = '<div class="field"><label>Reason (the owner sees it)</label><textarea class="why" maxlength="300"></textarea></div>'
|
||||
+ '<div class="row"><label class="small"><input type="radio" name="cr' + b.id + '" value="back"> Credit back</label><label class="small"><input type="radio" name="cr' + b.id + '" value="none"> No credit</label>'
|
||||
+ '<button class="btn small">Take down</button></div>';
|
||||
const bt = act.querySelector('button');
|
||||
bt.onclick = async () => {
|
||||
const reason = act.querySelector('.why').value.trim(); const c = act.querySelector('input[type=radio]:checked');
|
||||
if (reason.length < 3) return VBB.status('Write the reason first.', 'err');
|
||||
if (!c) return VBB.status('Choose credit back or no credit.', 'err');
|
||||
if (!bt.dataset.armed) { bt.dataset.armed = '1'; bt.textContent = 'Click again to take down #' + b.id; setTimeout(() => { if (bt.isConnected) { delete bt.dataset.armed; bt.textContent = 'Take down'; } }, 8000); return; }
|
||||
const r = await send('/api/admin/banners/' + b.id + '/takedown', { reason, credit: c.value });
|
||||
VBB.status(r.error || ('Banner #' + b.id + ' taken down' + (c.value === 'back' ? ', credit given back.' : ', no credit.')), r.error ? 'err' : 'ok');
|
||||
findBanners(); actions();
|
||||
};
|
||||
}
|
||||
$('bnList').appendChild(el);
|
||||
}
|
||||
}
|
||||
$('bnFind').onclick = findBanners;
|
||||
$('bnQ').addEventListener('keydown', e => { if (e.key === 'Enter') findBanners(); });
|
||||
$('tokBtn').onclick = () => { tok = $('tok').value.trim(); open(); };
|
||||
$('tok').addEventListener('keydown', e => { if (e.key === 'Enter') $('tokBtn').click(); });
|
||||
if (tok) open();
|
||||
|
||||
Reference in New Issue
Block a user