Files
martbost 6616680fc6 WebWorthIt staging: read-only contract + website check (Marty 2026-11-16)
Free check (DeepSeek v4.1 Flash scorecard) and deep report (Opus 5.5) over a generalised
evidence pack from the read-only chain tools; fact gate blocks any address, tx or number not
in the evidence; MySQL store; hub sign-in, sponsor line recorder, vouchers, ad slots in iframes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:54:08 -06:00

21 lines
3.3 KiB
JavaScript

// /my: signed-in member: checks, credits, the share box. Signed out: the network sign-in button.
(function () {
'use strict';
var out = WWI.$('out'), esc = WWI.esc;
fetch('/api/me').then(function (r) { return r.json(); }).then(function (j) {
if (!j.member) {
out.innerHTML = '<div class="card"><span class="t">Sign in with the network</span><span class="b">Use your InstantAdPay or LinkSpin account: one account across the network. Signing in never asks you to connect a wallet.</span>'
+ (j.sso ? '<a class="btn dark" style="align-self:flex-start" href="/sso/start?mode=go&amp;to=%2Fmy">Sign in with the network</a>' : '<span class="notice">Network sign-in is not switched on for this staging site yet.</span>') + '</div>';
return;
}
var m = j.member;
out.innerHTML = '<div class="card"><span class="t">' + (m.username ? '@' + esc(m.username) : 'Signed in') + '</span><span class="b">' + (m.wallet ? 'Wallet ' + esc(m.wallet) + '. ' : '') + (m.sponsor ? 'Sponsor @' + esc(m.sponsor) + '. ' : '') + 'Deep report credits: ' + ((j.credits || {}).deep || 0) + '.</span><button id="out1" class="btn line" style="align-self:flex-start" type="button">Sign out</button></div>'
+ (m.refLink ? '<div class="card" style="border:2px solid var(--good)"><span class="t">Share WebWorthIt</span><span class="b">Your referral link. When someone you referred buys a report, you earn 20% as their direct sponsor, plus 5% on levels 2 to 5 of your team. You earn only when people choose to buy.</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="ref" class="code" readonly style="flex:1 1 320px" value="' + esc(m.refLink) + '"><button id="cp" class="btn dark" type="button">Copy link</button></div></div>' : '')
+ '<div class="card"><span class="t">Your checks</span>' + ((j.checks || []).length ? '<div class="tblwrap"><table class="t"><thead><tr><th>When</th><th>Kind</th><th>What</th><th>Status</th></tr></thead><tbody>' + j.checks.map(function (c) { return '<tr><td>' + new Date(c.created).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT</td><td>' + esc(c.kind) + '</td><td><a href="/c/' + esc(c.id) + '">' + esc(c.website || WWI.short(c.address) || c.id) + '</a></td><td>' + esc(c.status) + '</td></tr>'; }).join('') + '</tbody></table></div>' : '<span class="b">No checks yet. <a href="/#check">Run one</a>.</span>') + '</div>'
+ '<div class="card"><span class="t">Redeem a voucher</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="v" class="code" placeholder="VOUCHER CODE" style="flex:1 1 180px"><button id="vb" class="btn dark" type="button">Redeem</button></div><span id="vm" class="b"></span></div>';
WWI.$('out1').addEventListener('click', function () { WWI.post('/api/signout').then(function () { location.href = '/'; }); });
var cp = WWI.$('cp'); if (cp) cp.addEventListener('click', function () { try { navigator.clipboard.writeText(WWI.$('ref').value); cp.textContent = 'Copied'; } catch (e) {} });
WWI.$('vb').addEventListener('click', function () { WWI.post('/api/redeem', { code: WWI.$('v').value.trim() }).then(function (r) { WWI.$('vm').textContent = r.ok ? 'Added ' + r.amount + (r.kind === 'deep' ? ' deep report(s).' : ' extra free check(s).') : (r.error || 'That code did not work.'); }); });
});
})();