cdb580c1f4
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
41 lines
2.8 KiB
JavaScript
41 lines
2.8 KiB
JavaScript
// Founding week checklist: members only; every item reads from the live account
|
|
// (IAP.launchChecks in common.js is shared with the dashboard's "launch ready" mark).
|
|
(async function () {
|
|
const $ = id => document.getElementById(id);
|
|
try { await IAP.renderNav('training'); } catch (e) {}
|
|
let me = null, cfg = {};
|
|
try { me = await (await fetch('/api/me')).json(); } catch (e) {}
|
|
// buyerCount and the referral list live on the dashboard endpoint; merge it in
|
|
if (me && me.signedIn) { try { const d = await (await fetch('/api/my/dashboard')).json(); if (d && !d.error) me = Object.assign({}, me, d, { signedIn: true, email: me.email }); } catch (e) {} }
|
|
try { cfg = await IAP.getConfig(); } catch (e) {}
|
|
const signedIn = !!(me && me.signedIn && me.email);
|
|
$('gate').style.display = signedIn ? 'none' : 'block';
|
|
$('body').style.display = signedIn ? 'block' : 'none';
|
|
if (!signedIn) return;
|
|
const pb = $('printBtn'); if (pb) pb.addEventListener('click', () => window.print());
|
|
const tok = me.username || me.refCode || me.memberId;
|
|
if (tok) document.querySelectorAll('[data-link]').forEach(el => { el.textContent = location.origin + '/join/' + tok; });
|
|
|
|
// launch moment (admin: Settings > launchAt, ISO 8601 with offset)
|
|
const at = cfg.launchAt ? new Date(cfg.launchAt) : null;
|
|
if (at && !isNaN(at)) {
|
|
$('lwWhen').hidden = false;
|
|
$('lwWhenAt').textContent = at.toLocaleString([], { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
|
|
const tick = () => { const ms = at - Date.now(); if (ms <= 0) { $('lwWhenIn').textContent = 'doors are open'; return; }
|
|
const d = Math.floor(ms / 86400000), h = Math.floor(ms % 86400000 / 3600000), m = Math.floor(ms % 3600000 / 60000);
|
|
$('lwWhenIn').textContent = (d ? d + 'd ' : '') + h + 'h ' + m + 'm to go'; };
|
|
tick(); setInterval(tick, 30000);
|
|
}
|
|
|
|
function render() {
|
|
const items = IAP.launchChecks(me);
|
|
const done = items.filter(i => i.done).length;
|
|
$('lwDone').textContent = done; $('lwBar').style.width = Math.round(done / items.length * 100) + '%';
|
|
$('chk').innerHTML = items.map((i, n) => '<li class="' + (i.done ? 'done' : '') + '"><div class="box">' + (i.done ? '✓' : (n + 1)) + '</div>'
|
|
+ '<div><h3>' + i.title + '</h3><p>' + i.how + '</p><div class="why">' + i.why + '</div>' + (i.note ? '<p class="small" style="margin-top:4px">' + i.note + '</p>' : '') + '</div>'
|
|
+ '<div class="act">' + (i.manual ? '<button class="btn small ' + (i.done ? 'sec' : '') + '" type="button" data-manual="' + i.key + '">' + (i.done ? 'Undo' : 'Mark done') + '</button>' : '<a class="btn small sec" href="' + i.href + '">' + i.cta + '</a>') + '</div></li>').join('');
|
|
$('chk').querySelectorAll('[data-manual]').forEach(b => b.addEventListener('click', () => { IAP.launchToggle(b.dataset.manual); render(); }));
|
|
}
|
|
render();
|
|
})();
|