// Shared page helpers (YPB namespace, the network common.js pattern): header, footer (legal, company line, the network line from the
// hub), verified visits, seed-packet cards, toasts of real events, the network ad zones, small formatters. The look lives in ypb.css.
window.YPB = (function () {
let cfgP = null, vt = null;
const I = window.YPBI || {};
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 framed = (() => { try { return window.top !== window.self; } catch (e) { return true; } })();
const n = x => Number(x || 0).toLocaleString('en-US');
const pct = bps => (Number(bps || 0) / 100).toFixed(Number(bps) % 100 ? 1 : 0) + '%';
const usd = c => '$' + (Number(c || 0) / 100).toFixed(2);
const month = t => t ? new Date(t).toLocaleDateString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric' }).toUpperCase() : '';
function status(msg, cls, id) { const el = $(id || 'status'); if (!el) return; el.hidden = !msg; el.className = 'note ' + (cls || ''); el.textContent = msg || ''; if (msg) el.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); }
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 MARK = '';
function renderNav(active) {
const h = document.createElement('header'); h.className = 'top wrap';
const links = [['/', 'Seed Bed'], ['/my?tab=plant', 'Plant a program'], ['/transplanted', 'Transplanted'], ['/spotlight', 'Spotlight'], ['/guides', 'Guides'], ['/my', 'My packets']];
h.innerHTML = 'Skip to content' + MARK + 'YourProgramBuilder'
+ ''
+ 'Sign in with the network';
document.body.prepend(h);
getConfig().then(c => { if (c.staging) { const b = document.createElement('div'); b.className = 'stage-bar wrap'; b.textContent = 'Staging copy for testing. No payouts, no mail, no contract: nothing here is real money.'; h.after(b); } }).catch(() => {});
getJSON('/api/me').then(m => { if (m.signedIn) { const a = $('navSign'); if (a) a.textContent = m.username ? '@' + m.username : short(m.address); } }).catch(() => {});
if (framed) document.querySelectorAll('a[href^="/my"]').forEach(a => { a.target = '_blank'; a.rel = 'noopener'; });
}
// the click relay: placement + the visitor's verified token once their visit has verified (+ the member whose page this is)
const goHref = (id, p, r) => '/go/' + id + '?p=' + encodeURIComponent(p || 'site') + (r ? '&r=' + encodeURIComponent(r) : '') + (vt ? '&v=' + vt : '');
function decorate() { document.querySelectorAll('a[data-go]').forEach(a => { a.href = goHref(a.dataset.go, a.dataset.p, a.dataset.r); }); }
const stageTag = x => x.stage === 'approved' ? 'Transplanted' : x.stage === 'review' ? 'Ready for review' : '';
// a seed packet. o = { place, r (member), spot, extra (html) }
function packetCard(x, o) {
o = o || {}; const spot = o.spot || !!x.spotlight;
const pctv = Math.min(100, Math.round(100 * (x.saves || 0) / (x.need || 10)));
const tags = [];
if (x.spotlight) tags.push('Spotlight ' + n(x.spotlight.delivered) + ' / ' + n(x.spotlight.views) + ' views');
tags.push(stageTag(x));
if (x.check === 'green') tags.push('Link checked');
tags.push('' + (x.cost === 'free' ? 'Free to join' : esc(x.costText || 'Paid')) + '');
if (x.contract) tags.push('Contract listed');
const by = x.mine ? 'your ID is saved' : x.own ? 'you planted this' : x.stage === 'review' ? 'in Marty\'s review queue' : x.planter ? 'planted by @' + esc(x.planter) : 'sponsor link first';
return ''
+ '
PACKET No. ' + esc(x.no) + ' · SOWN ' + esc(month(x.sownAt)) + '' + (I.iconOrganic || '') + '
'
+ '
' + tags.filter(Boolean).join('') + '
'
+ '
' + esc(x.desc) + '
'
+ '
Saved IDs' + n(x.saves) + ' / ' + n(x.need) + '
'
+ '
'
+ (o.extra || '') + '
';
}
// the page's data and its verified visit: packets come with a ticket; after visitSeconds of the page being visible the visit is sent once
async function wire(page, q) {
const src = document.referrer || '';
let hunt = /[?]ph=/.test(location.search + location.hash); try { hunt = hunt || !!sessionStorage.getItem('ph.token'); } catch (e) {}
const d = await getJSON('/api/wire?page=' + encodeURIComponent(page) + (q || '') + (src ? '&src=' + encodeURIComponent(src) : '') + (hunt ? '&hunt=1' : ''));
if (d.ticket) {
const need = (d.seconds || 6) * 1000; let seen = 0, last = Date.now(), sent = false;
const iv = setInterval(async () => {
const now = Date.now(); if (document.visibilityState === 'visible') seen += now - last; last = now;
if (!sent && seen >= need) { sent = true; clearInterval(iv); const r = await post('/api/visit/seen', { ticket: d.ticket, visibleMs: seen }).catch(() => ({})); if (r.vt) { vt = r.vt; decorate(); } document.dispatchEvent(new CustomEvent('ypb:verified', { detail: r })); }
}, 500);
document.addEventListener('visibilitychange', () => { last = Date.now(); });
}
return d;
}
function spotRow(el, d, r) { if (!el) return; const f = d.spotlights || []; el.hidden = !f.length; if (f.length) el.querySelector('.bed').innerHTML = f.map(x => packetCard(x, { place: 'spot', spot: true, r })).join(''); }
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'], ['viraladsource', 'ViralAdSource', 'https://viraladsource.com'], ['downlinehydra', 'DownlineHydra', 'https://downlinehydra.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] }));
const HERE = { id: 'yourprogrambuilder', name: 'YourProgramBuilder', url: 'https://yourprogrambuilder.com' };
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 === 'yourprogrambuilder'
? '' + esc(s.name) + '' : '' + esc(s.name) + '').join(''); };
paint(NET.concat([HERE]));
fetch('/api/network-sites').then(r => r.json()).then(l => { if (Array.isArray(l) && l.length) paint(l.some(s => s.id === 'yourprogrambuilder') ? l : l.concat([HERE])); }).catch(() => {});
}
function renderFooter() {
const f = document.createElement('footer'); f.className = 'foot wrap';
f.innerHTML = '
YourProgramBuilder The Seed Bed: bring your program, the network grows it. A directory of programs, not an income opportunity. Nothing is promised.
'
+ 'Seed BedPlant a programTransplantedSpotlightPromoteGuidesFAQ
'
+ ''
+ '© 2026 TrustClickz TermsEarnings disclaimerPrivacyContractLedgerSupport
';
document.body.appendChild(f);
netLine(f.querySelector('.netline'));
toasts();
}
let toastsOn = false;
function toasts() {
if (toastsOn || /^\/admin/.test(location.pathname)) 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 who = c => c.name ? '@' + esc(c.name) : 'A member';
const show = c => {
const el = document.createElement('a'); el.className = 'toast';
if (c.kind === 'spotlight') { el.href = '/ledger'; el.innerHTML = '' + who(c) + ' spotlighted ' + esc(c.packet || 'a packet') + '
split on chain by the contract'; }
else if (c.kind === 'save') { el.href = '/p/' + c.id; el.innerHTML = '' + who(c) + ' saved an ID
in ' + esc(c.packet) + ''; }
else if (c.kind === 'review') { el.href = '/p/' + c.id; el.innerHTML = '' + esc(c.packet) + ' is ready for review
enough members saved an ID'; }
else { el.href = '/p/' + c.id; el.innerHTML = '' + who(c) + ' planted a program
' + esc(c.packet) + ''; }
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);
}
const polOf = (w, d) => { try { const k = BigInt(w || 0); const v = Number(k / 10n ** 12n) / 1e6; return v.toFixed(d != null ? d : (v >= 100 ? 2 : 4)); } catch (e) { return '0'; } };
const when = t => t ? new Date(t).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
async function copy(text, btn) { try { await navigator.clipboard.writeText(text); if (btn) { const o = btn.textContent; btn.textContent = 'Copied'; setTimeout(() => { btn.textContent = o; }, 1600); } } catch (e) { if (btn) { btn.textContent = 'Select the text to copy it'; } } }
return { I, MARK, $, esc, getConfig, short, framed, status, getJSON, post, n, pct, usd, month, renderNav, renderFooter, packetCard, wire, spotRow, decorate, goHref, polOf, when, copy };
})();
// every page: header, footer and the numbers from /api/config
(function () {
const boot = () => {
YPB.renderNav(document.body.dataset.nav || ''); YPB.renderFooter();
document.querySelectorAll('[data-icon]').forEach(el => { const svg = YPB.I[el.dataset.icon]; if (svg) el.outerHTML = svg; });
YPB.getConfig().then(c => {
const lv = (c.split || {}).levelBps || []; const sp = c.spotlight || {};
const V = { need: String(c.reviewSaves), spotUsd: '$' + sp.usd, spotViews: YPB.n(sp.views), sponsor: YPB.pct(lv[0]), levels: lv.slice(1).map(YPB.pct).join(' / '), lvlEach: YPB.pct(lv[1]),
company: YPB.pct(10000 - lv.reduce((t, x) => t + x, 0)), recheck: String(c.recheckHours), deliverDays: String(sp.deliverDays), quota: String(c.plantQuota) };
document.querySelectorAll('[data-cfg]').forEach(el => { const k = el.dataset.cfg; if (V[k] != null) el.textContent = V[k]; });
// network ad zones (the ViralAdSource pattern): LinkSpin zones on Marty's LinkSpin account, ids from LS_ZONES (none until made)
const Z = c.zones || {}; if (!Z.footWide || /^\/admin/.test(location.pathname) || document.body.dataset.noZones) return;
const zone = (el, id) => { el.className = 'net-zone'; el.style.cssText = 'margin:18px auto;text-align:center;max-width:100%'; el.innerHTML = 'Network
'; const s = document.createElement('script'); s.async = true; s.src = 'https://linkspin.app/z.js'; s.setAttribute('data-zone', id); el.appendChild(s); };
const za = document.createElement('div'); document.querySelector('footer.foot').before(za); zone(za, window.innerWidth >= 760 ? Z.footWide : (Z.footPhone || Z.footWide));
if (location.pathname === '/ledger' && Z.ledger) { const d = document.createElement('div'); const t = document.getElementById('ledgerBox'); if (t) { t.after(d); zone(d, Z.ledger); } }
}).catch(() => {});
};
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot();
})();
// Network Weekend ribbon: netweekend.js paints it only while a network event is live (dates from the hub through /api/network-deals)
(function () {
if (/^\/admin/.test(location.pathname)) return;
try { if (window.top !== window) return; } catch (e) { return; }
var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117'; s.defer = true; s.setAttribute('data-site', 'yourprogrambuilder'); document.head.appendChild(s);
})();