// 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) => '
  • ' + (i.done ? '✓' : (n + 1)) + '
    ' + '

    ' + i.title + '

    ' + i.how + '

    ' + i.why + '
    ' + (i.note ? '

    ' + i.note + '

    ' : '') + '
    ' + '
    ' + (i.manual ? '' : '' + i.cta + '') + '
  • ').join(''); $('chk').querySelectorAll('[data-manual]').forEach(b => b.addEventListener('click', () => { IAP.launchToggle(b.dataset.manual); render(); })); } render(); })();