// 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())); 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']]; nav.innerHTML = '
5XYOURTEAM
'; 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 = '
TEST MODE, nobody is adopted. Picks on this site are previews: no one gets a new sponsor and no email is sent.
'; 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 = 'Part of the network · One account across the network: ' + list.map(s => (s.id === 'fivex' || /5xyourteam\.com/.test(s.url)) ? '' + esc(s.name) + '' : '' + esc(s.name) + '').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 = '

5xYourTeam, the weekly draft for people who need a sponsor

' + '

A position buys a draft spot and coaching tools, not income. Nothing is promised.

' + '

Draft Board · My Team · Cards · Get a Position · Promote

' + '' + '

© 2026 TrustClickz

'; 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 = '' + (c.name ? '@' + esc(c.name) : 'A new coach') + ' joined The Draft
Paid on-chain, split by the contract in the same transaction'; } else if (c.kind === 'level') { el.href = '/cards'; el.innerHTML = '@' + esc(c.person || 'a pick') + ' just made ' + esc(c.tierName) + (c.name ? ' on @' + esc(c.name) + '\'s team' : '') + '
' + (c.tierName === 'Starter' ? 'Wallet linked. One step from Pro.' : c.tierName === 'Pro' ? 'Payouts switched on.' : 'Leveling up.') + ''; } else { el.href = '/'; el.innerHTML = '' + (c.name ? '@' + esc(c.name) : 'A coach') + ' drafted @' + esc(c.person || 'a player') + '
' + (c.slot ? 'Pick ' + esc(c.slot) : 'An instant pick') + ''; } 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' ? 'Back in the pool' : ''; return '
' + '
' + esc(c.tierName) + '
' + esc(initials(c.username)) + '
' + '
@' + esc(c.username || 'player') + 'Team @' + esc(c.coach) + (c.round ? ' · Round ' + esc(c.round) : c.kind === 'instant' ? ' · Instant pick' : '') + '' + esc(c.milestone) + '' + back + (o.extra || '') + '
' + '
'; } 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 '
Sign in with InstantAdPaySign in with LinkSpin
' + '

Your wallet: SafePal or any other crypto wallet. Signing in is free and cannot move funds.

'; } 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, 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); })();