Files
5xyourteam/public/assets/common.js
T
martbost f6dbbfdcd3 5xYourTeam card + Draft Day art (2026-11-15, LOCAL ONLY): kie.ai tier frames, Envato rings/medals/holo/back, Draft Day confetti/spotlights/scoreboard, Champiun
- Trading cards: five kie.ai nano-banana-pro tier frames (Rookie steel, Starter silver, Pro gold trim, All-Star gold + holo,
  Hall of Fame ornate gold + laurels), F4 avatar ring + B1 rank medal per tier, F5 holo foil on Pro/All-Star/HoF, sized in cqw
- Card back from F1 (text layers hidden, green re-tinted gold): tap/Enter flips a card to the stats layout (team, how drafted,
  milestone, games played, the tier ladder); landscape, takes two grid slots. Milestones only, never earnings.
- Draft Day 1080 card: D2 spotlights, D1 gold confetti, D5 scoreboard plate (blank) for the totals
- Champiun (T3, Basic Latin WOFF subset) only for the ON THE CLOCK headline and pick numbers
- tools/derive-art.py builds the web derivatives from ../assets-src (raw packs stay out of public/); public/art/MANIFEST.md maps
  each file to its source item, author and license code; tools/art.mjs renders kit/OG/proof/tier art with the same cards
- ?v= tags bumped to 2; unit 62/62, smoke 156/156 (UI_FONTS=1), iap-tank 23/23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 07:45:43 -06:00

112 lines
12 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 => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[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 = '<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);
}
// 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> &middot; 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(' &middot; '); };
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> &middot; <a href="/team">My Team</a> &middot; <a href="/cards">Cards</a> &middot; <a href="/join">Get a Position</a> &middot; <a href="/promote">Promote</a></p>'
+ '<p class="legal-links"><a href="/terms">Terms</a> &middot; <a href="/disclaimer">Earnings Disclaimer</a> &middot; <a href="/privacy">Privacy</a> &middot; <a href="/contract">Contract</a> &middot; <a href="/ledger">Ledger</a> &middot; <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Support</a></p>'
+ '<p class="co">TrustClickz &middot; 615 Green Valley Drive, Moody, AL 35004</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&amp;via=iap&amp;to=' + t + '">Sign in with InstantAdPay</a><a class="btn-gold" href="/sso/start?mode=go&amp;via=linkspin&amp;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, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
})();