// Admin (2026-11-16): spot takedown and restore with a required reason, and the admin ledger. Read with the ADMIN_TOKEN (kept in this tab only). (function () { BL.renderNav(''); const $ = BL.$, esc = BL.esc; let tok = ''; try { tok = sessionStorage.getItem('bl.admin') || ''; } catch (e) {} const get = u => BL.getJSON(u, { headers: { 'x-admin-token': tok } }); const send = (u, body) => BL.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' : ''; const who = x => x.username ? '@' + x.username : BL.short(x.owner || ''); async function open() { const s = await get('/api/admin/actions?n=1'); if (s.error) { BL.status('That token was not accepted.', 'err'); return; } try { sessionStorage.setItem('bl.admin', tok); } catch (e) {} $('tokCard').hidden = true; $('adm').hidden = false; BL.status(''); actions(); } async function actions() { const a = await get('/api/admin/actions?n=200'); if (a.error) return; $('aActions').innerHTML = a.actions.length ? '
| When | Action | Spot | Owner | By | Reason | Credit |
|---|---|---|---|---|---|---|
| ' + esc(ct(e.at)) + ' | ' + esc(e.action) + ' | #' + e.spotId + ' | ' + esc(who(e)) + ' | ' + esc(e.by) + ' | ' + esc(e.reason || '') + ' | ' + esc(e.credit) + ' |
No takedowns yet.
'; } async function find() { const q = $('spQ').value.trim(); if (!q) return; const d = await get('/api/admin/spots?q=' + encodeURIComponent(q)); if (d.error) { $('spList').innerHTML = '' + esc(d.error) + '
'; return; } $('spList').innerHTML = ''; for (const s of d.spots) { const el = document.createElement('div'); el.className = 'spot-ed adm-spot'; const st = s.down ? 'TAKEN DOWN ' + ct(s.down.at) + ' by ' + s.down.by + ': ' + s.down.reason + ' (no credit)' : 'Showing (' + s.showing.from + ')'; const edits = s.edits.length ? '| When | What | Old | New |
|---|---|---|---|
| ' + esc(ct(e.at)) + ' | ' + esc(e.what) + ' (' + esc(e.via) + ') | ' + esc(e.old.link) + ' ' + esc(e.old.img) + ' | ' + esc(e.new.link) + ' ' + esc(e.new.img) + ' |
No edits yet.
'; el.innerHTML = '' + esc(st) + '
Link: ' + esc(s.link || '(default or none)') + '
' + s.views + ' of ' + s.owed + ' views, '
+ (s.clicks.organic + s.clicks.gate) + ' clicks. Bought ' + esc(ct(s.boughtAt)) + '.' + (s.downs.length ? ' Restored before: ' + s.downs.length + 'x.' : '') + '