diff --git a/public/start.js b/public/start.js index 62b9a4e..3bdb2d1 100644 --- a/public/start.js +++ b/public/start.js @@ -13,9 +13,21 @@ function invitedBy(){ }catch(e){} return null; } +function placementChoice(){ + try{ + const q=new URLSearchParams(location.search).get('direct'); + if(q==='1'||q==='0')return q; + const m=document.cookie.match(/(?:^|;\s*)rmc_direct=([01])/); + if(m)return m[1]; + }catch(e){} + return null; +} async function load(){ try{ const ref=invitedBy(); + // an explicit ?direct=1/0 from the invite link wins over the position's default, and it + // has to be in scope for the join button further down — not just the display block + const dq=placementChoice(); const [cr,sr]=await Promise.all([ fetch('/api/public/config'), fetch(ref?('/api/public/member?id='+encodeURIComponent(ref)):'/api/public/current-sponsor') @@ -26,10 +38,6 @@ async function load(){ // Route exactly the way that member's own invite page would: their moving link sends // the join to the next position in their leg, unless their position is set to take // direct placements. Same rules, so the two pages can never disagree. - // an explicit ?direct=1/0 from the invite link wins over the position's default - const dq=(function(){try{const q=new URLSearchParams(location.search).get('direct'); - if(q==='1'||q==='0')return q; - const m=document.cookie.match(/(?:^|;\s*)rmc_direct=([01])/);return m?m[1]:null;}catch(e){return null}})(); const goDirect=dq==='1'||(dq!=='0'&&(s.directDefault||!s.joinTarget)); const t=goDirect?{id:s.id,referralUrl:s.referralUrl,directCount:s.directCount}:s.joinTarget; currentSponsor={id:t.id,name:null,directs:(t.directCount!==undefined?t.directCount:0),goal:2,referralUrl:t.referralUrl};