// Admin: status + the cycle reward ledger, read with the ADMIN_TOKEN (kept in this tab only). (function () { VBB.renderNav(''); const $ = VBB.$, esc = VBB.esc; let tok = ''; try { tok = sessionStorage.getItem('vbb.admin') || ''; } catch (e) {} const get = u => VBB.getJSON(u, { headers: { 'x-admin-token': tok } }); async function open() { const s = await get('/api/admin/status'); if (s.error) { VBB.status('That token was not accepted.', 'err'); return; } try { sessionStorage.setItem('vbb.admin', tok); } catch (e) {} $('tokCard').hidden = true; $('adm').hidden = false; VBB.status(''); $('aStats').innerHTML = [['Loop filled', s.loop.filled + ' / ' + s.loop.size], ['Waiting', s.queue.length], ['Next shift', s.progress + ' / ' + s.config.perShift + (s.held ? ' (held)' : '')], ['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 => '
| Member | Cycles | Views |
|---|---|---|
| ' + esc(who(m)) + ' | ' + m.cycles + ' | ' + VBB.n(m.views) + ' |
No cycles yet.
'; $('aLedger').innerHTML = l.entries && l.entries.length ? '| When (CT) | Entry | Banner | Member | Views | Status |
|---|---|---|---|---|---|
| ' + esc(new Date(e.at).toLocaleString('en-US', { timeZone: 'America/Chicago' })) + ' | ' + esc(e.id) + ' | #' + e.bannerId + ' | ' + esc(who(e)) + ' | ' + VBB.n(e.views) + ' | ' + esc(e.status) + ' |
The ledger is empty.
'; } $('tokBtn').onclick = () => { tok = $('tok').value.trim(); open(); }; $('tok').addEventListener('keydown', e => { if (e.key === 'Enter') $('tokBtn').click(); }); if (tok) open(); })();