diff --git a/public/my.js b/public/my.js index 1403aa0..cd4b5f1 100644 --- a/public/my.js +++ b/public/my.js @@ -35,7 +35,10 @@ function pathId(){const m=location.pathname.match(/^\/my\/(\d+)$/);if(m)return m[1];const q=new URLSearchParams(location.search).get('id');if(q&&/^\d+$/.test(q))return q;try{return localStorage.getItem('ctb.myId')||''}catch(e){return ''}} - const treeUI={byId:{},parent:{},homeId:0,rootId:0,mode:'pyramid',zoom:null,_applied:1}; + const treeUI={byId:{},parent:{},depth:{},reach:7,homeId:0,rootId:0,mode:'pyramid',zoom:null,_applied:1}; + // Marty 2026-09-26: show only the generations this position can be paid from. A member at + // level L catches upgrades from generations 1..L (7 at most); deeper ones only confused people. + const reachOf=d=>Math.max(1,Math.min(7,Number(d&&d.level)||1)); // Zoom the matrix so it fits small screens. treeUI.zoom: null = auto-fit (shrink // to fit width, never enlarge), or a manual factor. Uses CSS `zoom` so the layout // reflows cleanly (no leftover box, centering + scroll keep working). @@ -62,7 +65,7 @@ if(fit)fit.addEventListener('click',()=>{treeUI.zoom=null;applyMatrixZoom()}); let t;window.addEventListener('resize',()=>{clearTimeout(t);t=setTimeout(()=>{if(treeUI.mode==='pyramid')applyMatrixZoom()},160)}); })(); - function indexTree(n,par){if(!n)return;treeUI.byId[n.id]=n;if(par)treeUI.parent[n.id]=par.id;indexTree(n.left,n);indexTree(n.right,n)} + function indexTree(n,par){if(!n)return;treeUI.byId[n.id]=n;treeUI.depth[n.id]=par?treeUI.depth[par.id]+1:0;if(par)treeUI.parent[n.id]=par.id;indexTree(n.left,n);indexTree(n.right,n)} function isSpill(n){return !!(n&&treeUI.parent[n.id]&&n.referrerId&&n.referrerId!==treeUI.parent[n.id])} function card(n,focus){ if(!n)return '
open
slot
'; @@ -79,11 +82,13 @@ const rows=[[root]]; for(let g=1;g<4;g++)rows.push(rows[g-1].flatMap(n=>n?[n.left||null,n.right||null]:[null,null])); if(!rows[3].some(Boolean))rows.pop(); + const base=treeUI.depth[root.id]||0; + while(rows.length>1&&base+rows.length-1>treeUI.reach)rows.pop(); out.innerHTML=`
${rows.map((r,i)=>`
${r.map(n=>card(n,i===0)).join('')}
`).join('')}
`; const path=[];let cur=treeUI.rootId; while(cur){path.unshift(cur);if(cur===treeUI.homeId)break;cur=treeUI.parent[cur]} nav.innerHTML=path.length>1?`Viewing: `+path.map((id,i)=>i===path.length-1?`#${id}`:``).join(' › ')+` `:''; - const wire=el=>el.querySelectorAll('[data-tid]').forEach(b=>b.addEventListener('click',()=>{const t=Number(b.dataset.tid);if(t&&treeUI.byId[t]){treeUI.rootId=t;renderTree()}})); + const wire=el=>el.querySelectorAll('[data-tid]').forEach(b=>b.addEventListener('click',()=>{const t=Number(b.dataset.tid);if(t&&treeUI.byId[t]&&(treeUI.depth[t]||0){ if(!n)return ''; - const ch=[n.left,n.right].filter(Boolean); + const ch=depth=2?'✓ ':''; const badge=n.tier===2?'P':'S'; const label=`${qmark}${badge} #${n.id} ${esc(n.levelName)} · ${n.directCount}/2 directs · ${fmt(n.earnedPol)} POL${n.downCount?` · ⬇ ${n.downCount} below (${fmt(n.downPol)} POL)`:''}${isSpill(n)?` · ↧ spillover (ref #${n.referrerId})`:''}`; @@ -118,7 +123,7 @@ const q=Object.values(treeUI.byId).filter(n=>n.id!==d.id&&n.directCount>=2).length; el.innerHTML=`
`+ `
Your organization${st.downCount.toLocaleString()} member${st.downCount===1?'':'s'}
`+ - `
Generations deep${gens}
`+ + `
Generations in your reach${Math.min(gens,reachOf(d))}
`+ `
Qualified below you${q}
`+ `
Earned below you${fmt(st.downPol)} POL
`+ (d.polUsd>0?`
≈ US dollars (POL @ $${d.polUsd<0.1?d.polUsd.toFixed(4):d.polUsd.toFixed(2)})$${(st.downPol*d.polUsd).toLocaleString(undefined,{maximumFractionDigits:0})}
`:'')+ @@ -156,7 +161,7 @@ `
Directs${d.directCount}/2${d.directCount>=2?' ✓ qualified':''}
`+ `
Team below you${d.subtree?`${d.subtree.downCount} member${d.subtree.downCount===1?'':'s'}`:'—'}
`+ `
Member since${date(d.joinedAt)}
`; - treeUI.byId={};treeUI.parent={};treeUI.homeId=d.id;treeUI.rootId=d.id; + treeUI.byId={};treeUI.parent={};treeUI.depth={};treeUI.reach=reachOf(d);treeUI.homeId=d.id;treeUI.rootId=d.id; indexTree(d.subtree,null); renderOrgBar(d); renderTree(); @@ -202,7 +207,8 @@ layer.forEach(n=>{if(n.left)next.push(n.left);if(n.right)next.push(n.right);}); if(!next.length)break;gens.push(next.length);layer=next; } - const rows=gens.map((c,i)=>{ + const reach=reachOf(d); + const rows=gens.slice(0,reach).map((c,i)=>{ const cap=Math.pow(2,i+1); const pays=i<7?`pays you at their ${LEVELS[i+1]} upgrade`:'beyond the 8 pay levels'; return `
Gen ${i+1}
${c}${cap<=1024?' of '+cap:''}${pays}
`;