Files
linkspin/public/assets/team.js
T
martbost f41d1ef384 Launch week: Founder badge + launch week contest (Marty approved 2026-11-05, PLAN.md options B and C)
Founder badge (cosmetic only: no credits, no POL, no perks, never posted to Telegram)
- Criterion: the account's earliest signed-in visit is before the launch moment (launchAt, default
  2026-11-15T06:00:00-06:00). Field: accounts.firstSeen, else lastSeen. Both are written only by
  accounts.touchSeen() on signed-in requests (dashboard, ping, chat); touchSeen now keeps firstSeen =
  the previous lastSeen on the next visit, so a pre-launch member who signs in again after launch still
  qualifies. Carried-over shells that never signed in have neither field and never qualify.
- Stored flag accounts.founder (JSON + MySQL column). Grant: launchweek.tick every 10 minutes from the
  launch moment, idempotent, one run per 10-minute slot across app copies (marks.claim); founderGrant '0'
  turns it off. Admin preview + "Grant Founder badges now" (refused before launch).
- Shown in the badge strip (on the way before launch, Share works, no Telegram post), wall (wall-founder.js),
  Team rows (my.js + team.js), the Team activity chip, and next to names on /leaderboard. Art:
  /badges/badge-founder.jpg, drawn in code in the existing card layout.

Launch week contest
- Window [launchContestStart or launchAt, launchContestEnd) = Sun Nov 15 6:00 AM to the end of Sat Nov 21,
  Central (end stored exclusive, 2026-11-22T00:00:00-06:00). Count = the weekly board's tier-1 TierPaid
  sales. Never counted: own positions, buys by linked positions (Qualified Start), the admin account and
  overrideHouseIds (as contestants or buyers), launchContestExcludeEmails/Ids. launchContestMinSales 2.
  Ties: sales, dollars, who got there first. Prizes launchContestPrizesPol '10,6,4'.
- Payout only by Admin > Launch week > Pay launch contest: the ranking is frozen on the first press, the
  admin's confirmed list must match it, balance + gas checked first, each place claimed once (marks.claim)
  and written as sending before award(memberId) from the Level 4 override payer wallet
  (override.payerHandle). Records tx hashes; resolve paid-with-tx or retry for blocked/failed/review.
  The prize email + feed line say "Launch week contest prize".
- /leaderboard panel from the launch moment until the prizes are paid; /launch copy states both rules.
- chatbot: CANNED founder-badge + launch-contest, FACTS lines (no amounts quoted before launch).
- qa/launchweek.test.cjs (16 checks: Central window bounds, exclusions, minimum, two-copy payout once,
  frozen result, Founder criterion + grant, touchSeen backfill); run.sh launchweek and in all.
- Versions: my.js?v=20261105fd, team.js?v=20261105fd, wall-founder.js?v=20261105fd,
  admin-launchweek.js?v=20261105lw (wall.js unchanged: the shared policy test pins it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:14:28 -06:00

47 lines
6.3 KiB
JavaScript

// LinkSpin Team: the line as a working table (dashboard + line + carry APIs from the engine).
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
let D = null, LINE = null, LEVEL = 1, FILTERS = new Set(), ME = null;
CR.mount({ active: 'team', title: 'Team', sub: 'loading' });
const dayStart = () => { const d = new Date(); d.setHours(0, 0, 0, 0); return d.getTime(); };
const ago = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + ' h ago'; const days = Math.floor(d / 86400e3); return days === 1 ? 'yesterday' : days + ' d ago'; };
const pol = wei => { try { return (Number(BigInt(wei || '0') / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } };
// same stage names and colours as the Pipeline board; quiet = not seen in 3+ days and not yet building
const STAGE = { joined: 'Joined', wallet: 'Wallet linked', payouts: 'Payouts on', bought: 'Bought', building: 'Building' };
const stageOf = m => m.buyers ? 'building' : m.bought ? 'bought' : m.activated ? 'payouts' : m.wallet ? 'wallet' : 'joined';
const quiet = m => stageOf(m) !== 'building' && (!m.lastSeen || Date.now() - m.lastSeen > 3 * 86400e3);
function rows() {
const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); let ms = L ? L.members.slice() : [];
const f = { today: m => (m.lastSeen || 0) >= dayStart(), wallet: m => !!m.wallet, nopay: m => !!m.wallet && !m.activated, nowallet: m => !m.wallet, quiet: m => quiet(m) };
for (const k of FILTERS) ms = ms.filter(f[k]);
ms.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0));
return ms;
}
function render() {
const ms = rows(); const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); const total = L ? L.members.length : 0;
$('rows').innerHTML = ms.length ? ms.map(m => { const today = (m.lastSeen || 0) >= dayStart();
const sg = stageOf(m), q = quiet(m);
return '<div class="rw st-row' + (q ? ' stalled' : '') + '" data-st="' + sg + '"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + (m.founder ? ' <span class="tag" title="Founder badge: signed in before LinkSpin launched" style="background:#ffc94d;color:#5a3f00">FOUNDER</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $25+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span></div>'
+ '<span class="mono ' + (today ? 'ok' : (m.lastSeen && Date.now() - m.lastSeen > 3 * 86400e3 ? 'warn' : '')) + '" style="font-size:12px">' + (today ? 'today' : ago(m.lastSeen)) + '</span>'
+ '<span><span class="stg" data-st="' + sg + '">' + STAGE[sg] + '</span>' + (q ? '<br><span class="stg quiet">' + (m.lastSeen ? 'quiet ' + Math.floor((Date.now() - m.lastSeen) / 86400e3) + 'd' : 'never signed in') + '</span>' : '') + '</span>'
+ '<span class="r num">' + (m.earnedWei && m.earnedWei !== '0' ? '+' + pol(m.earnedWei) + ' POL' : '<span class="muted">0</span>') + '</span>'
+ '<span class="muted" style="font-size:12px">' + (m.sponsor ? 'via ' + esc(m.sponsor) : (m.email ? esc(m.email) : '')) + '</span></div>'; }).join('')
: '<div class="rw"><span class="muted">' + (total ? 'Nobody matches those filters.' : 'Nobody on this level yet. Share your link, or put it in a spin.') + '</span></div>';
$('foot').textContent = 'level ' + LEVEL + ' · ' + ms.length + (ms.length !== total ? ' of ' + total : '') + ' · surf earnings and full activity are in the classic dashboard for now';
}
async function load() {
try { [D, LINE, ME] = await Promise.all([CR.get('/api/my/dashboard'), CR.get('/api/my/line'), CR.me()]); } catch (e) { CR.sub('could not load'); return; }
const counts = (LINE.counts || []); const refs = D.referrals || [];
CR.sub((counts[0] || 0) + ' direct' + (counts[0] === 1 ? '' : 's') + ' · ' + ((counts[1] || 0) + (counts[2] || 0)) + ' deeper');
$('tiles').innerHTML = [['Directs', fmt(counts[0] || 0), refs.filter(r => r.activated).length + ' with payouts on'], ['Levels 2 and 3', fmt((counts[1] || 0) + (counts[2] || 0)), (counts[1] || 0) + ' · ' + (counts[2] || 0)], ['Qualifying buyers', fmt(D.buyerCount || 0), (D.buyerCount || 0) >= 5 ? 'level 3 open' : (D.buyerCount || 0) >= 2 ? 'level 2 open' : 'level 2 at 2 buyers'], ['Paid by the line', pol(D.earnedWei || '0') + ' POL', (D.earnCount || 0) + ' payouts']]
.map(([k, v, n], i) => '<div class="tile' + (i === 3 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span><span class="muted mono" style="font-size:11px">' + n + '</span></div>').join('');
const inv = 'https://' + location.host + '/join/' + (ME.username || ME.refCode || ME.memberId || ''); $('invite').textContent = inv; $('copyInvite').onclick = () => CR.copy(inv);
$('sponsor').innerHTML = ME.sponsorName ? '<b>' + esc(ME.sponsorName) + '</b>' + (ME.sponsorId ? ' <span class="mono muted">#' + ME.sponsorId + '</span>' : '') + '<div class="muted">Carried over from the network where you first joined. Nothing to set up, nothing anyone can change.</div>' : (ME.sponsorId ? '<b>member #' + ME.sponsorId + '</b>' : '<span class="muted">Not set. Your first purchase locks a sponsor.</span>');
try { const c = await CR.get('/api/my/carry'); const cl = (c.claims || []).filter(x => x.sponsor === (ME.email || '').toLowerCase()); if (cl.length) { $('claimPanel').hidden = false; $('claims').innerHTML = cl.length + ' of your people can use every tool now; their first purchase waits up to ' + (c.claimDays || 3) + ' days for you to link a wallet and switch on payouts, then walks up your line.'; } } catch (e) {}
render();
}
document.querySelectorAll('.lvl [data-l]').forEach(b => b.addEventListener('click', () => { LEVEL = Number(b.dataset.l); document.querySelectorAll('.lvl [data-l]').forEach(x => x.classList.toggle('on', x === b)); render(); }));
$('chips').querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (FILTERS.has(k)) FILTERS.delete(k); else FILTERS.add(k); b.classList.toggle('on', FILTERS.has(k)); render(); }));
CR.requireSession(load);
})();