My line: section pills and 10-row pages on every list

A sticky pill row at the top of My line jumps to each section (built from
the cards marked data-jump; hidden cards get no pill; the one in view is
lit). Every list on the page pages at 10: your line, downline levels,
holding tank, coach directs, prospects, both link-stats tables; upline
messages at 5. qa/line-pager.mjs checks it in a real browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-26 18:56:20 -05:00
parent cf5a9674a2
commit 7873d752d3
4 changed files with 122 additions and 15 deletions
+39 -3
View File
@@ -236,6 +236,36 @@
// opts per (default 25); tail: a selector for a drawer that follows its row and pages
// with it; focus: a row predicate, opens on whichever page holds that row
const PAGE_SIZE = 25;
// My line is the longest page on the dashboard: its lists page at 10 (Marty, 2026-09-26)
const LINE_PER = 10;
// Section pills at the top of My line: one per visible card marked data-jump, the one in view lit up.
// Cards that show or hide themselves (sponsor, upline messages) rebuild the row when they change.
let lineJumpObs = null;
function buildLineJump() {
const nav = document.getElementById('lineJump'); const pane = document.getElementById('pane-line'); if (!nav || !pane) return;
const cards = [...pane.querySelectorAll(':scope > .card[data-jump]')].filter(c => !c.hidden);
nav.innerHTML = cards.map(c => '<button type="button" class="chip-t" data-jumpto="' + c.id + '">' + esc(c.dataset.jump) + '</button>').join('');
nav.hidden = cards.length < 2;
const top = document.querySelector('.bo-top'); nav.style.setProperty('--jumpTop', (top ? top.offsetHeight : 0) + 'px'); pane.style.setProperty('--jumpTop', (top ? top.offsetHeight : 0) + 'px');
nav.querySelectorAll('[data-jumpto]').forEach(b => b.addEventListener('click', () => {
const c = document.getElementById(b.dataset.jumpto); if (!c) return;
c.scrollIntoView({ behavior: 'smooth', block: 'start' });
nav.querySelectorAll('.chip-t').forEach(x => x.classList.toggle('on', x === b));
}));
if (lineJumpObs) lineJumpObs.disconnect();
if ('IntersectionObserver' in window) {
const seen = new Map();
lineJumpObs = new IntersectionObserver(ents => {
for (const e of ents) seen.set(e.target.id, e.isIntersecting ? e.boundingClientRect.top : null);
let best = null; for (const [id, t] of seen) if (t != null && (best == null || t < seen.get(best))) best = id;
if (best) { nav.querySelectorAll('.chip-t').forEach(x => x.classList.toggle('on', x.dataset.jumpto === best)); const on = nav.querySelector('.chip-t.on'); if (on && nav.scrollWidth > nav.clientWidth) nav.scrollLeft = on.offsetLeft - 16; }
}, { rootMargin: '-120px 0px -55% 0px' });
cards.forEach(c => lineJumpObs.observe(c));
}
}
{ const pane = document.getElementById('pane-line');
if (pane && 'MutationObserver' in window) new MutationObserver(() => buildLineJump()).observe(pane, { subtree: false, childList: false, attributes: true, attributeFilter: ['hidden'] });
if (pane) pane.querySelectorAll(':scope > .card[data-jump]').forEach(c => { if ('MutationObserver' in window) new MutationObserver(() => buildLineJump()).observe(c, { attributes: true, attributeFilter: ['hidden'] }); }); }
const PAGE_AT = {};
function pageList(key, host, rowSel, opts) {
if (!host) return; opts = opts || {}; const per = opts.per || PAGE_SIZE;
@@ -602,7 +632,7 @@
+ '<td>' + new Date(r.joined).toLocaleDateString() + '</td>'
+ '<td><span class="badge' + (r.status === 'joined free' ? ' amber' : '') + '">' + r.status + '</span></td></tr>').join('');
wrap.appendChild(t);
pageList('roster', wrap, 'table.roster tr');
pageList('roster', wrap, 'table.roster tr', { per: LINE_PER });
}
// overview recent-activity widget: chain events + line joins, newest first
try {
@@ -697,7 +727,7 @@
if (name === 'earn') setEarnSub(earnSub); // refresh whichever sub-tab is active
else if (vidState.token) stopVideo();
if (name === 'profile') loadLineBanner();
if (name === 'line') { loadLineage(); loadUplineMessages(); loadCoach(); loadLinkStats(); loadProspects(); }
if (name === 'line') { buildLineJump(); loadLineage(); loadUplineMessages(); loadCoach(); loadLinkStats(); loadProspects(); }
if (name === 'campaigns') ['cTarget', 'cImage', 'cVideoUrl'].forEach(id => { if ($(id)) $(id).value = ''; }); // no residual URL between visits
if (name === 'training') loadTraining();
if (name === 'pipeline') loadPipeline();
@@ -1457,6 +1487,7 @@
+ '<span class="em">joined ' + ago(w.joined) + '</span>'
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('');
pageList('tank', el, ':scope > .lin-row', { per: LINE_PER });
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the InstantAdPay holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
if (note === null) return;
@@ -1548,6 +1579,7 @@
+ (x.free && x.address ? ' <button class="btn small" type="button" title="Pay it forward: send POL from your wallet to theirs for their first package" data-pif="' + esc(x.email) + '" data-pname="' + esc(x.name) + '" data-paddr="' + esc(x.address) + '">PIF</button>' : '')
+ (x.free && x.rescue ? ' <button class="btn sec small" type="button" title="Reached them by phone, text or in person? Mark it so the rescue clock resets." data-contacted="' + esc(x.email) + '" data-cname="' + esc(x.name) + '">Contacted them</button>' : '')
+ (x.free ? ' <button class="btn sec small" type="button" title="Pay it forward: give this free member to the holding tank so another member can coach them" data-release="' + esc(x.email) + '" data-rname="' + esc(x.name) + '">Release to tank</button>' : '') + '</div>').join('');
pageList('coach', el, ':scope > .lin-row', { per: LINE_PER });
el.querySelectorAll('[data-contacted]').forEach(b => b.addEventListener('click', async () => {
try { await api('/api/my/tank/contacted', { email: b.dataset.contacted }); IAP.status('Marked: you have contacted ' + b.dataset.cname + '.', 'ok'); loadCoach(); }
catch (e) { IAP.status(e.message, 'bad'); }
@@ -1610,7 +1642,9 @@
st.innerHTML = src.length ? '<tr><th>Source</th><th>Views (30d)</th><th>Views (all)</th><th>Joined</th><th>Qualifying buyers</th></tr>'
+ src.map(x => '<tr><td>' + esc(x.source) + '</td><td class="mono">' + x.views30 + '</td><td class="mono">' + x.views + '</td><td class="mono">' + x.joins + '</td><td class="mono">' + x.buyers + '</td></tr>').join('')
: '<tr><td class="muted small">Sources appear as visits arrive.</td></tr>';
pageList('linksrc', st.parentElement, 'table tr:has(td)', { per: LINE_PER });
}
pageList('linkangles', t.parentElement, 'table tr:has(td)', { per: LINE_PER });
} catch (e) {}
}
// ── prospects: the member's own follow-up list ──
@@ -1704,6 +1738,7 @@
+ '<input type="date" class="small" data-pnext="' + p.id + '" value="' + (p.nextTs ? new Date(p.nextTs).toISOString().slice(0, 10) : '') + '">'
+ '<button class="btn sec small" type="button" data-pdel="' + p.id + '">Remove</button></div>'; }).join('');
const save = async (id, patch) => { const p = list.find(x => x.id === Number(id)); if (!p) return; try { await api('/api/my/prospects', Object.assign({}, p, patch)); } catch (e) { IAP.status(e.message, 'bad'); } };
pageList('prospects', el, ':scope > .lin-row', { per: LINE_PER });
el.querySelectorAll('[data-pstatus]').forEach(s => s.addEventListener('change', () => save(s.dataset.pstatus, { status: s.value })));
el.querySelectorAll('[data-pnext]').forEach(i => i.addEventListener('change', () => save(i.dataset.pnext, { next: i.value, nextTs: i.value ? Date.parse(i.value + 'T12:00:00') : null })));
el.querySelectorAll('[data-pdel]').forEach(b => b.addEventListener('click', async () => { try { await api('/api/my/prospects/remove', { id: b.dataset.pdel }); loadProspects(); } catch (e) { IAP.status(e.message, 'bad'); } }));
@@ -1768,7 +1803,7 @@
b.addEventListener('click', () => openConvo(b.dataset.cemail, b.dataset.cname)));
el.querySelectorAll('[data-act]').forEach(b => b.addEventListener('click', () => toggleLineActivity(b)));
const focusRef = LINE_FOCUS_REF ? LINE_FOCUS_REF.replace(/"/g, '') : null;
el.querySelectorAll('.lin-lvl').forEach((lv, i) => pageList('line-' + i, lv, ':scope > .lin-row', { tail: '.lin-act', focus: focusRef ? row => !!row.querySelector('[data-act="' + focusRef + '"]') : null }));
el.querySelectorAll('.lin-lvl').forEach((lv, i) => pageList('line-' + i, lv, ':scope > .lin-row', { per: LINE_PER, tail: '.lin-act', focus: focusRef ? row => !!row.querySelector('[data-act="' + focusRef + '"]') : null }));
if (LINE_FOCUS_REF) {
const ref = LINE_FOCUS_REF; LINE_FOCUS_REF = null;
const b = el.querySelector('[data-act="' + ref.replace(/"/g, '') + '"]');
@@ -1813,6 +1848,7 @@
+ '<div style="display:flex;justify-content:space-between;gap:10px"><b>' + esc(i.subject) + '</b>'
+ '<span class="small muted">' + esc(i.fromName) + ' · ' + new Date(i.sent).toLocaleDateString() + '</span></div>'
+ '<div class="ib-rich" style="margin-top:8px">' + (i.body || '') + '</div></div>').join('');
pageList('upmsg', list, ':scope > .promo-block', { per: 5 });
// opening the pane marks them read
for (const i of r.items) if (!i.read) fetch('/api/my/messages/' + i.id + '/read', { method: 'POST' }).catch(() => {});
} catch (e) {}