// Admin: checks (cost, timings, publish to "Network, checked"), test purchases with the sponsor line that would be paid, // voucher codes (create, disable, redemptions), and an admin-run check for our own contracts. The token stays in this browser. (function () { 'use strict'; var $ = WWI.$, esc = WWI.esc, tok = ''; try { tok = sessionStorage.getItem('wwi.admin') || ''; } catch (e) {} function api(path, body) { return fetch(path, { method: body ? 'POST' : 'GET', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: body ? JSON.stringify(body) : undefined }).then(function (r) { return r.json(); }); } var ct = function (t) { return t ? new Date(Number(t)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : ''; }; function load() { api('/api/admin/overview').then(function (j) { if (j.error) { $('out').innerHTML = '
| When | Kind | What | Status | Model | Cost | Time | Public |
|---|---|---|---|---|---|---|---|
| ' + ct(c.created) + ' | ' + esc(c.kind) + ' | ' + esc(c.website || '') + ' ' + esc(WWI.short(c.address) || '') + ' ' + esc(c.chain || '') + '' + (c.error ? ' ' + esc(c.error.slice(0, 160)) + '' : '') + ' | ' + esc(c.status) + (c.status !== 'done' ? ' (' + esc(c.step || '') + ')' : '') + ' | ' + esc(c.model || '') + ' | $' + Number(c.cost_usd || 0).toFixed(4) + ' | ' + (tm ? Math.round(tm.total_s) + ' s' : '') + ' | ' + '
| When | Ref | Opt-in | Back to | Status | Hub | |
|---|---|---|---|---|---|---|
| ' + ct(x.created) + ' | ' + esc(x.email) + ' | ' + esc(x.ref || '') + ' | ' + (x.optin ? 'yes' : 'no') + ' | ' + esc(x.to_path || '') + ' | ' + esc(x.status) + (x.mailed ? ', mailed' : '') + ' | ' + esc(x.hub_result || '') + ' |
| When | Buyer | Item | Via | Ref | Line source | Would pay | Company |
|---|---|---|---|---|---|---|---|
| ' + ct(p.at) + ' | ' + esc(p.buyer_username ? '@' + p.buyer_username : p.buyer || 'visitor') + ' | ' + esc(p.item) + ' $' + Number(p.usd).toFixed(2) + ' | ' + esc(p.via) + ' | ' + esc(p.ref || '') + ' | ' + esc(l.source || '') + (l.ok === false ? ' (hub partial)' : '') + ' ' + (l.line || []).map(function (x) { return (x.username ? '@' + esc(x.username) : esc(WWI.short(x.wallet) || '?')) + (x.qualified ? ' (bought)' : ' (passed over)'); }).join(' > ') + ' | '
+ (s.levels || []).map(function (x) { return 'L' + x.level + ' ' + x.pct + '% $' + Number(x.usd).toFixed(2) + ' ' + (x.username ? '@' + esc(x.username) : 'company'); }).join(' ') + (s.note ? ' ' + esc(s.note) + '' : '') + ' | $' + Number(s.company || 0).toFixed(2) + ' |
| Code | Gives | Uses | Expires | Note | |
|---|---|---|---|---|---|
| ' + esc(p.code) + ' | ' + p.amount + ' ' + (p.kind === 'deep' ? 'deep' : 'free') + ' | ' + p.uses + ' / ' + p.max_uses + (p.per_holder_once ? ' (once each)' : '') + ' | ' + (p.expires ? ct(p.expires) : '') + ' | ' + esc(p.note || '') + ' |
| When | Code | Holder | Gave |
|---|---|---|---|
| ' + ct(r.at) + ' | ' + esc(r.code) + ' | ' + esc(String(r.holder).replace(/^t:(.{6}).*/, 'browser $1...')) + ' | ' + r.amount + ' ' + esc(r.kind) + ' |