47389a4169
Traffic exchanges, rotators and Massifly Adpoints show 5xyourteam.com inside another site's frame, where the browser drops the SameSite=Lax fx.ref and fx.sid cookies, so signing in, buying or joining from the frame lost the sponsor (Marty 2026-11-19). - common.js: framed (window.top !== window.self) -> /team, /join, /admin, /sso/ and off-site links get target=_blank rel=noopener (on load and again at click time); /team, /join and /sso/ links add ?ref= from the page's ?ref= (or ?r=), the coach page it is, or the cookie. The wallet buttons ([data-wallet-signin], Pay = [data-full-window]) open this page in a new tab with ?ref= instead of signing inside the frame. Public pages stay in the frame. - server: /sso/start?...&ref=<name> sets fx.ref first-party and 302s to the plain start; /sso/* sends X-Frame-Options DENY (/team and /admin already did). Sponsor rules unchanged. - coach.js marks the coach; join.js keeps Pay clickable when framed; asset tags bumped. Checked with the fake traffic-exchange harness (cross-site frame, JS a.click()): 11/11 flows open a new tab with the sponsor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
175 lines
17 KiB
JavaScript
175 lines
17 KiB
JavaScript
// Shared page helpers (FX namespace, modelled on the ViralAdBlitz / VBB common.js): nav, footer (legal links, the company line, the
|
|
// network line from the hub), toasts of real events, and small formatters. Every number on a page comes from the API.
|
|
window.FX = (function () {
|
|
let cfgP = null;
|
|
const $ = id => document.getElementById(id);
|
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
const getConfig = () => cfgP || (cfgP = fetch('/api/config').then(r => r.json()));
|
|
// Traffic exchanges, rotators and Massifly Adpoints show these pages inside another site's frame, where the browser drops the
|
|
// fx.ref and sign-in cookies (SameSite=Lax). Framed (Marty 2026-11-19, the IAP / PolHunter / ViralAdBlitz frame pattern): sign-in,
|
|
// Get a Position, My Team and off-site links open in a new tab, a new tab back to this site carries ?ref=<sponsor> so it sets the
|
|
// cookie first-party, and the wallet buttons (sign in, pay) open this page in a new tab instead. The sponsor: the page's own
|
|
// ?ref= (or ?r=), else the coach page it is, else the cookie.
|
|
const framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
|
|
const REF_RE = /^[A-Za-z0-9_.-]{2,40}$|^0x[0-9a-fA-F]{40}$/;
|
|
function pageRef() {
|
|
const q = new URLSearchParams(location.search); const r = q.get('ref') || q.get('r');
|
|
if (r && REF_RE.test(r)) return r;
|
|
const pg = document.body && document.body.dataset.pageRef; if (pg && REF_RE.test(pg)) return pg;
|
|
const c = /(?:^|;\s*)fx\.ref=([^;]+)/.exec(document.cookie); let v = ''; try { v = c ? decodeURIComponent(c[1]) : ''; } catch (e) {}
|
|
return REF_RE.test(v) ? v : '';
|
|
}
|
|
const withRef = url => { const r = pageRef(); return r ? url + (url.indexOf('?') < 0 ? '?' : '&') + 'ref=' + encodeURIComponent(r) : url; };
|
|
const NEW_TAB = /^\/(team|join|admin|sso)(\/|$)/; // sign-in, buying and member pages: never usable inside a frame
|
|
function frameLink(a) {
|
|
if (!framed || !a || !a.href || a.hasAttribute('download')) return;
|
|
let x; try { x = new URL(a.href, location.href); } catch (e) { return; }
|
|
if (!/^https?:$/.test(x.protocol)) return;
|
|
const own = x.origin === location.origin;
|
|
if (own && !NEW_TAB.test(x.pathname)) return; // public pages stay in the frame
|
|
if (own && /^\/(team|join|sso)(\/|$)/.test(x.pathname) && !x.searchParams.get('ref')) { const r = pageRef(); if (r) { x.searchParams.set('ref', r); a.setAttribute('href', x.pathname + x.search + x.hash); } }
|
|
a.target = '_blank'; if (!/noopener/.test(a.rel || '')) a.rel = ((a.rel || '') + ' noopener').trim();
|
|
}
|
|
const frameLinks = () => { if (framed) document.querySelectorAll('a[href]').forEach(frameLink); };
|
|
if (framed) {
|
|
document.addEventListener('click', e => {
|
|
const t = e.target.closest && e.target.closest('a[href], [data-wallet-signin], [data-full-window]'); if (!t) return;
|
|
if (t.tagName === 'A') return frameLink(t);
|
|
e.preventDefault(); e.stopImmediatePropagation(); window.open(withRef(location.pathname), '_blank', 'noopener');
|
|
}, true);
|
|
document.addEventListener('DOMContentLoaded', frameLinks);
|
|
}
|
|
const short = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
|
const n = x => Number(x || 0).toLocaleString('en-US');
|
|
function status(msg, cls, id) { const el = $(id || 'status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; }
|
|
async function getJSON(url, opts) { const r = await fetch(url, opts); let j = {}; try { j = await r.json(); } catch (e) {} if (!r.ok && !j.error) j.error = 'Request failed (' + r.status + ')'; j._status = r.status; return j; }
|
|
const post = (url, body) => getJSON(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) });
|
|
const polOf = (w, d) => { try { const k = BigInt(w || 0); if (k === 0n) return '0'; const v = Number(k / 10n ** 12n) / 1e6; return v.toFixed(d != null ? d : (v >= 100 ? 2 : v >= 1 ? 2 : 4)); } catch (e) { return '0'; } };
|
|
const when = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
|
|
// "today", "yesterday", "3 days ago" (Central days) or "not seen yet"
|
|
function ago(t, nowMs) {
|
|
if (!t) return 'not seen yet';
|
|
const day = x => new Date(x).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
|
const now = nowMs || Date.now(); const dd = Math.round((Date.parse(day(now)) - Date.parse(day(t))) / 86400000);
|
|
return dd <= 0 ? 'today' : dd === 1 ? 'yesterday' : dd + ' days ago';
|
|
}
|
|
function left(ms) { if (ms <= 0) return 'now'; const m = Math.ceil(ms / 60000); if (m < 60) return m + ' min'; const h = Math.floor(m / 60); if (h < 48) return h + ' h ' + (m % 60) + ' min'; return Math.round(h / 24) + ' days'; }
|
|
const initials = s => String(s || '?').replace(/[^A-Za-z0-9]/g, '').slice(0, 2).toUpperCase() || '?';
|
|
let weekLabel = '';
|
|
function renderNav(active, week) {
|
|
const nav = document.createElement('nav'); nav.className = 'top';
|
|
const links = [['/', 'Draft Board'], ['/team', 'My Team'], ['/cards', 'Card Collection'], ['/join', 'Get a Position'], ['/ledger', 'Ledger'], ['/contract', 'Contract'], ['/guides', 'Guides']];
|
|
nav.innerHTML = '<div class="wrap"><a class="brand" href="/" aria-label="5xYourTeam, the draft board"><span class="wm">5X<b>YOUR</b>TEAM</span><span class="wk" id="navWeek" hidden></span></a><div class="links">'
|
|
+ links.map(l => '<a href="' + l[0] + '"' + (l[0] === active ? ' class="on" aria-current="page"' : '') + '>' + l[1] + '</a>').join('') + '</div></div>';
|
|
document.body.prepend(nav);
|
|
if (week) setWeek(week);
|
|
// staging test mode (DRAFT_LIVE not 1): say so on every page, plainly
|
|
getConfig().then(c => { if (!c || !c.testMode || $('testMode')) return; const b = document.createElement('div'); b.id = 'testMode'; b.className = 'testmode'; b.setAttribute('role', 'status');
|
|
b.innerHTML = '<div class="wrap"><b>TEST MODE, nobody is adopted.</b> Picks on this site are previews: no one gets a new sponsor and no email is sent.</div>'; nav.after(b); }).catch(() => {});
|
|
}
|
|
// ISO-ish week number of a Monday date (the mockup's "DRAFT WEEK 46")
|
|
function weekNo(monday) { const d = new Date(monday + 'T12:00:00Z'); const t = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() + 3)); const y = new Date(Date.UTC(t.getUTCFullYear(), 0, 4)); return 1 + Math.round(((t - y) / 86400000 - 3 + ((y.getUTCDay() + 6) % 7)) / 7); }
|
|
function setWeek(monday) { const el = $('navWeek'); if (!el || !monday) return; weekLabel = 'DRAFT WEEK ' + weekNo(monday); el.textContent = weekLabel; el.hidden = false; }
|
|
const NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
|
|
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['viraladblitz', 'ViralAdBlitz', 'https://viraladblitz.com'], ['fivex', '5xYourTeam', 'https://5xyourteam.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] }));
|
|
function netLine(el) {
|
|
if (!el) return;
|
|
const paint = list => { el.innerHTML = '<b>Part of the network</b> · One account across the network: ' + list.map(s => (s.id === 'fivex' || /5xyourteam\.com/.test(s.url))
|
|
? '<span class="here" aria-current="page">' + esc(s.name) + '</span>' : '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join(' · '); };
|
|
paint(NET);
|
|
fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l.some(s => s.id === 'fivex') ? l : l.concat([NET[5]])); }).catch(() => {});
|
|
}
|
|
function renderFooter() {
|
|
const f = document.createElement('footer'); f.className = 'foot';
|
|
f.innerHTML = '<div class="wrap"><p><b>5xYourTeam</b>, the weekly draft for people who need a sponsor</p>'
|
|
+ '<p>A position buys a draft spot and coaching tools, not income. Nothing is promised.</p>'
|
|
+ '<p><a href="/">Draft Board</a> · <a href="/team">My Team</a> · <a href="/cards">Cards</a> · <a href="/join">Get a Position</a> · <a href="/promote">Promote</a> · <a href="/guides">Guides</a></p>'
|
|
+ '<p class="legal-links"><a href="/terms">Terms</a> · <a href="/disclaimer">Earnings Disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="/contract">Contract</a> · <a href="/ledger">Ledger</a> · <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Support</a></p>'
|
|
+ '<p class="co">© 2026 TrustClickz</p><p class="netline"></p></div>';
|
|
document.body.appendChild(f);
|
|
netLine(f.querySelector('.netline'));
|
|
toasts();
|
|
}
|
|
// live toasts: real new positions, picks and level-ups only, bottom-right, never older than 30 minutes
|
|
let toastsOn = false;
|
|
function toasts() {
|
|
if (toastsOn) return; toastsOn = true;
|
|
const seen = new Set(); let first = true;
|
|
const box = document.createElement('div'); box.className = 'toasts'; box.setAttribute('aria-live', 'polite'); document.body.appendChild(box);
|
|
const show = c => {
|
|
const el = document.createElement('a'); el.className = 'toast' + (c.kind === 'position' ? ' red' : '');
|
|
if (c.kind === 'position') { el.href = '/ledger'; el.innerHTML = '<b>' + (c.name ? '@' + esc(c.name) : 'A new coach') + ' joined The Draft</b><br><span>Paid on-chain, split by the contract in the same transaction</span>'; }
|
|
else if (c.kind === 'level') { el.href = '/cards'; el.innerHTML = '<b>@' + esc(c.person || 'a pick') + ' just made ' + esc(c.tierName) + (c.name ? ' on @' + esc(c.name) + '\'s team' : '') + '</b><br><span>' + (c.tierName === 'Starter' ? 'Wallet linked. One step from Pro.' : c.tierName === 'Pro' ? 'Payouts switched on.' : 'Leveling up.') + '</span>'; }
|
|
else { el.href = '/'; el.innerHTML = '<b>' + (c.name ? '@' + esc(c.name) : 'A coach') + ' drafted @' + esc(c.person || 'a player') + '</b><br><span>' + (c.slot ? 'Pick ' + esc(c.slot) : 'An instant pick') + '</span>'; }
|
|
box.appendChild(el); requestAnimationFrame(() => el.classList.add('in'));
|
|
setTimeout(() => { el.classList.remove('in'); setTimeout(() => el.remove(), 400); }, 7000);
|
|
};
|
|
const tick = async () => {
|
|
const d = await getJSON('/api/recent').catch(() => null); const all = (d && d.items) || [];
|
|
const fresh = all.filter(c => !seen.has(c.key)); all.forEach(c => seen.add(c.key));
|
|
const list = first ? fresh.slice(0, 1) : fresh.reverse(); first = false;
|
|
list.slice(0, 3).forEach((c, i) => setTimeout(() => show(c), 1500 + i * 8000));
|
|
};
|
|
tick(); setInterval(tick, 25000);
|
|
}
|
|
// a trading card (milestones only, never earnings)
|
|
// Front: the tier frame (public/art/tc, see public/art/MANIFEST.md), the avatar ring with initials, the rank medal, name + team
|
|
// + milestone. Tap or Enter flips it to the back (the stats layout: team, how drafted, milestone, games played, the tier ladder).
|
|
const CARD_TIERS = [['rookie', 'Rookie', 'Drafted'], ['starter', 'Starter', 'Wallet'], ['pro', 'Pro', 'Payouts'], ['allstar', 'All-Star', 'Purchase'], ['hof', 'Hall of Fame', 'Own team']];
|
|
function card(c, opts) {
|
|
const o = opts || {};
|
|
const how = c.round ? 'Round ' + esc(c.round) : c.kind === 'instant' ? 'Instant pick' : 'Drafted';
|
|
const games = c.plays == null ? 'not tracked yet' : n(c.plays);
|
|
const at = Math.max(0, CARD_TIERS.findIndex(t => t[0] === c.tier));
|
|
const back = c.status === 'returned' ? '<span class="dim">Back in the pool</span>' : '';
|
|
return '<article class="tc ' + esc(c.tier) + (c.status === 'returned' ? ' faded' : '') + '" tabindex="0" role="button" aria-pressed="false" aria-label="@' + esc(c.username || 'player') + ', ' + esc(c.tierName) + ' card. Flip for the stats.">'
|
|
+ '<div class="fr"><div class="tier">' + esc(c.tierName) + '</div><div class="face"><span>' + esc(initials(c.username)) + '</span></div><i class="medal" aria-hidden="true"></i>'
|
|
+ '<div class="info"><b>@' + esc(c.username || 'player') + '</b><span>Team @' + esc(c.coach) + (c.round ? ' · Round ' + esc(c.round) : c.kind === 'instant' ? ' · Instant pick' : '') + '</span><span>' + esc(c.milestone) + '</span>' + back + (o.extra || '') + '</div></div>'
|
|
+ '<div class="bk" aria-hidden="true"><b class="nm">@' + esc(c.username || 'player') + '</b><span class="tg">' + esc(c.tierName) + '</span>'
|
|
+ '<dl><dt>Team</dt><dd>@' + esc(c.coach) + '</dd><dt>Joined the team</dt><dd>' + how + '</dd><dt>Latest milestone</dt><dd>' + esc(c.milestone) + '</dd><dt>Games played</dt><dd>' + games + '</dd>' + (back ? '<dt>Status</dt><dd>' + back + '</dd>' : '') + '</dl>'
|
|
+ '<p class="cap">CARD LADDER</p><div class="lad">' + CARD_TIERS.map((t, i) => '<span' + (i <= at ? ' class="on"' : '') + '><em>' + esc(t[1]) + '</em><i>' + esc(t[2]) + '</i><u>' + (i <= at ? '✓' : '-') + '</u></span>').join('') + '</div>'
|
|
+ '<p class="ft">5xyourteam.com/cards · milestones only, never earnings</p></div></article>';
|
|
}
|
|
document.addEventListener('click', e => { const t = e.target.closest && e.target.closest('.tc'); if (t && !e.target.closest('a,button')) flip(t); });
|
|
document.addEventListener('keydown', e => { if ((e.key === 'Enter' || e.key === ' ') && e.target.classList && e.target.classList.contains('tc')) { e.preventDefault(); flip(e.target); } });
|
|
function flip(t) { const on = t.classList.toggle('flip'); t.setAttribute('aria-pressed', on ? 'true' : 'false'); t.querySelector('.bk').setAttribute('aria-hidden', on ? 'false' : 'true'); }
|
|
// signed in on InstantAdPay already? one quick hop there and back signs you in here too
|
|
async function silentSso(to) { try { const ss = await getJSON('/api/sso/status'); if (ss && ss.check) { location.replace('/sso/start?mode=check&via=iap&to=' + encodeURIComponent(to)); return true; } } catch (e) {} return false; }
|
|
function signInBlock(to) {
|
|
const t = encodeURIComponent(to);
|
|
return '<div class="signin"><a class="btn-gold" href="/sso/start?mode=go&via=iap&to=' + t + '">Sign in with InstantAdPay</a><a class="btn-gold" href="/sso/start?mode=go&via=linkspin&to=' + t + '">Sign in with LinkSpin</a><button class="btn-line" type="button" data-wallet-signin>Sign in with your wallet</button></div>'
|
|
+ '<p class="small">Your wallet: SafePal or any other crypto wallet. Signing in is free and cannot move funds.</p>';
|
|
}
|
|
function wireSignIn(root) {
|
|
(root || document).querySelectorAll('[data-wallet-signin]').forEach(b => { b.onclick = async () => {
|
|
try { status('Check your wallet for the sign-in message.'); await FXWallet.signIn(); location.reload(); } catch (e) { status(String(e && e.message || e).slice(0, 300), 'err'); } }; });
|
|
}
|
|
return { $, esc, getConfig, short, framed, pageRef, withRef, frameLink, frameLinks, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
|
|
})();
|
|
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub through
|
|
// /api/network-deals). Not on the 1080x1080 draft-day card or the admin page.
|
|
(function () {
|
|
if (/^\/(draftday|admin)/.test(location.pathname)) return;
|
|
var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117'; s.defer = true; s.setAttribute('data-site', 'fivex'); document.head.appendChild(s);
|
|
})();
|
|
|
|
// network ad zones (2026-11-17, the ViralAdBlitz pattern): LinkSpin zones on Marty's LinkSpin account for 5xyourteam.com, made through
|
|
// LinkSpin's named admin zone route: footer wide 728x90 (ls-e5d152), footer phone 320x50 (ls-1a1b1f), ledger 468x60
|
|
// (ls-20fdd0); the not-found page carries ls-a8a737. Admin pages get none.
|
|
(function () {
|
|
const ZONES = { footWide: 'ls-e5d152', footPhone: 'ls-1a1b1f', ledger: 'ls-20fdd0' };
|
|
function zone(el, id) {
|
|
if (!el || el.dataset.zoned) return; el.dataset.zoned = '1'; el.className = 'net-zone'; el.style.cssText = 'margin:18px auto;text-align:center;max-width:100%';
|
|
const lab = document.createElement('div'); lab.textContent = 'Network'; lab.style.cssText = 'font-size:11px;letter-spacing:1px;opacity:.7;margin-bottom:4px';
|
|
const s = document.createElement('script'); s.async = true; s.src = 'https://linkspin.app/z.js'; s.setAttribute('data-zone', id);
|
|
el.appendChild(lab); el.appendChild(s);
|
|
}
|
|
function run() {
|
|
const p = location.pathname.replace(/\/$/, '') || '/';
|
|
if (p === '/admin' || document.body.dataset.noZones) return;
|
|
if (p === '/ledger') { const t = document.getElementById('rows'); const sec = t && t.closest('section'); if (sec && sec.parentNode) { const d = document.createElement('div'); sec.parentNode.insertBefore(d, sec.nextSibling); zone(d, ZONES.ledger); } }
|
|
const za = document.createElement('div'); document.body.appendChild(za); zone(za, window.innerWidth >= 760 ? ZONES.footWide : ZONES.footPhone);
|
|
}
|
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
|
|
})();
|