diff --git a/ads.js b/ads.js index c1cecc4..cebbc00 100644 Binary files a/ads.js and b/ads.js differ diff --git a/public/assets/my.js b/public/assets/my.js index d955a78..c56e460 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -238,6 +238,51 @@ 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; + // Sortable + filterable member lists (Marty, 2026-09-29): the holding tank, "Your line" and the three-level + // downline share one toolbar. Every row carries joined, last seen, surf earnings and wallet/payout state so a + // sponsor can spot "joined days ago, signed in today, earning on their own, wallet linked but payouts off". + const LIST_UI = {}; + const dayStart = () => { const d = new Date(); d.setHours(0, 0, 0, 0); return d.getTime(); }; + const activeToday = m => (m.lastSeen || 0) >= dayStart(); + const LIST_SORTS = [ + { k: 'seen', label: 'Last seen', v: m => m.lastSeen || 0 }, + { k: 'joined', label: 'Joined', v: m => m.joined || 0 }, + { k: 'earned', label: 'Surf earnings', v: m => m.earned || 0 }, + { k: 'balance', label: 'Earned balance', v: m => m.balance || 0 }, + { k: 'name', label: 'Name', v: m => String(m.name || '').toLowerCase(), str: true }, + ]; + const LIST_FILTERS = [ + { k: 'today', label: 'Active today', t: m => activeToday(m) }, + { k: 'earning', label: 'Earning', t: m => (m.earned || 0) > 0 }, + { k: 'wallet', label: 'Wallet linked', t: m => !!m.wallet }, + { k: 'nopay', label: 'Wallet, payouts off', t: m => !!m.wallet && !m.activated }, + { k: 'payouts', label: 'Payouts on', t: m => !!m.activated }, + { k: 'nowallet', label: 'No wallet', t: m => !m.wallet }, + ]; + const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: 'seen', dir: -1, on: new Set() }); + function listApply(key, rows) { + const st = listState(key); const s = LIST_SORTS.find(x => x.k === st.sort) || LIST_SORTS[0]; + const out = (rows || []).filter(m => m.own || [...st.on].every(k => { const f = LIST_FILTERS.find(x => x.k === k); return !f || f.t(m); })); + out.sort((a, b) => { const x = s.v(a), y = s.v(b); return (s.str ? String(x).localeCompare(String(y)) : x - y) * st.dir; }); + return out; + } + function listBar(key, total, shown, rerender, opts) { + const st = listState(key); const hide = (opts && opts.hide) || []; + const bar = document.createElement('div'); bar.className = 'lst-bar'; + bar.innerHTML = '' + + '' + + '' + LIST_FILTERS.filter(f => !hide.includes(f.k)).map(f => '').join('') + '' + + '' + (shown === total ? total + (total === 1 ? ' person' : ' people') : shown + ' of ' + total) + ''; + bar.querySelector('select').addEventListener('change', e => { st.sort = e.target.value; st.dir = st.sort === 'name' ? 1 : -1; rerender(); }); + bar.querySelector('.lst-dir').addEventListener('click', () => { st.dir = -st.dir; rerender(); }); + bar.querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (st.on.has(k)) st.on.delete(k); else st.on.add(k); rerender(); })); + return bar; + } + const seenAgo = 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 + ' days ago'; }; + const seenChip = m => m.lastSeen ? '' + (activeToday(m) ? 'active today' : 'seen ' + seenAgo(m.lastSeen)) + '' : 'never signed in'; + const earnChip = m => '' + (m.earned || 0).toLocaleString() + ' cr earned'; + const walletChip = m => m.activated ? 'wallet · payouts on' : m.wallet ? 'wallet · payouts off' : 'no wallet'; + const memberChips = m => seenChip(m) + ' ' + earnChip(m) + ' ' + walletChip(m); // 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; @@ -491,6 +536,19 @@ } catch (e) {} } // visual line tree on the Overview: YOU + three levels, qualified directs in gold + function renderRoster(wrap, all) { + const rows = listApply('roster', all); + wrap.querySelectorAll(':scope > .lst-bar, :scope > table, :scope > .pgr, :scope > .lst-none').forEach(n => n.remove()); + wrap.appendChild(listBar('roster', all.length, rows.length, () => renderRoster(wrap, all))); + if (!rows.length) { wrap.insertAdjacentHTML('beforeend', '
Nobody in your line matches those filters.
'); return; } + const t = document.createElement('table'); t.className = 'roster'; + t.innerHTML = rows.map(r => 'The tank is empty. Anyone who joins from the public site without a sponsor lands here.
'; return; } - el.innerHTML = r.waiting.map(w => 'Nobody in the tank matches those filters.
'); + 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; + try { const rr = await api('/api/my/tank/adopt', { who: b.dataset.adopt, note }); IAP.status('You are now the sponsor for ' + rr.name + '. Chat and email sent.', 'ok'); loadTank(); loadCoach(); } + catch (e) { IAP.status(e.message, 'bad'); } + })); + } // The announcement cards at the top of the Overview are repeated on a timer, so a member who has read // one can put it away: dismissed for the rest of this browser session, back at the next sign-in // (Marty, 2026-09-22) so a message nobody has acted on is never gone for good. @@ -1817,17 +1874,29 @@ el.innerHTML = 'No one in your downline yet. Share your link and it fills in here.
'; return; } - el.innerHTML = r.levels.map(L => !L.members.length ? '' : + LINE_DATA = r; renderLineage(el); + } catch (e) {} + } + let LINE_DATA = null; + function renderLineage(el) { + const r = LINE_DATA; if (!r) return; + try { + const all = r.levels.reduce((n, L) => n + L.members.length, 0); + const shown = r.levels.map(L => ({ level: L.level, members: listApply('line', L.members) })); + const kept = shown.reduce((n, L) => n + L.members.length, 0); + el.innerHTML = ''; + el.appendChild(listBar('line', all, kept, () => renderLineage(el))); + el.insertAdjacentHTML('beforeend', !kept ? 'Nobody in your downline matches those filters.
' : shown.map(L => !L.members.length ? '' : 'Everyone who joined through your link, newest first. When they buy their +
Everyone who joined through your link. Sort or filter the list to spot who signed in today, who is earning + credits on their own, and who has a wallet linked but payouts still off. When they buy their first package of $20 or more, they count toward your qualification.
Nobody yet. Your link is ready above; share it and this list starts filling.