// Promote page renderer (2026-11-14). Draws a promo kit (GET /api/promo-kit) into a container: links, creatives grouped by angle, // swipe lines, headlines, an email and social posts, each with a copy button. Same file on Downline Banners, Viral Banner Blitz and ViralAdBlitz; // the page script decides the username and the look comes from the site's own CSS (.card, .btn, .kit-*). window.KitPage = (function () { const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); async function copy(text, btn) { try { await navigator.clipboard.writeText(text); } catch (e) { const t = document.createElement('textarea'); t.value = text; document.body.appendChild(t); t.select(); try { document.execCommand('copy'); } catch (e2) {} t.remove(); } if (btn) { const o = btn.textContent; btn.textContent = 'Copied'; setTimeout(() => { btn.textContent = o; }, 1400); } } const TXT = []; const cb = (text, label, cls) => { TXT.push(text); return ''; }; // on the kit's own site, show creatives from this origin (same files; the copied URL stays absolute) function local(url, k) { try { const u = new URL(url); return u.hostname === k.site && location.hostname !== k.site ? u.pathname : url; } catch (e) { return url; } } const row = (label, url, cls) => '
' + esc(label) + '' + esc(url) + '
' + cb(url, 'Copy link', cls) + '
'; function render(root, k) { TXT.length = 0; const angles = []; const by = {}; (k.creatives || []).forEach(c => { if (!by[c.angle]) { by[c.angle] = []; angles.push(c); } by[c.angle].push(c); }); let h = ''; h += '

Your links

' + (k.username ? '

Every link, creative and line below carries ' + esc(k.username) + '.

' : '

Add your network username above so these links carry it.

') + k.links.map(l => row(l.label, l.url, '') + (l.tracked ? row(l.label + ', tracked', l.tracked, 'sec') : '')).join('') + (k.links.some(l => l.tracked) ? '

A tracked link goes through LinkSpin first, so the network can see which site sent the visit, then opens the same page with your username. Use either one.

' : '') + '
'; h += '

Creatives

Download them, or copy the HTML: it already links to you.

' + angles.map((c, i) => '').join('') + '
'; angles.forEach((a, i) => { h += '
' + by[a.angle].map(c => '
' + esc(k.name + ', ' + c.label) + '' + '
' + esc(c.label) + ' ' + c.w + 'x' + c.h + 'Download' + cb(c.url, 'Copy URL') + cb(c.html, 'Copy HTML') + '
').join('') + '
'; }); h += '
'; h += '

Short lines

For chats, comments, text ads and signatures.

' + k.lines.map(t => '

' + esc(t) + '

' + cb(t) + '
').join('') + '
'; h += '

Headlines

' + k.headlines.map(t => '

' + esc(t) + '

' + cb(t) + '
').join('') + '
'; h += '

Email

Subject' + esc(k.email.subject) + '

' + cb(k.email.subject, 'Copy subject') + '
' + '
' + esc(k.email.body) + '
' + cb(k.email.body, 'Copy email') + '
'; h += '

Social posts

' + k.posts.map(t => '
' + esc(t) + '
' + cb(t, 'Copy post') + '
').join('') + '
'; if (k.note) h += '

' + esc(k.note) + '

'; root.innerHTML = h; root.querySelectorAll('[data-kc]').forEach(b => b.addEventListener('click', () => copy(TXT[Number(b.dataset.kc)], b))); root.querySelectorAll('[data-ka]').forEach(b => b.addEventListener('click', () => { root.querySelectorAll('[data-ka]').forEach(x => x.classList.toggle('on', x === b)); root.querySelectorAll('[data-ks]').forEach(s => { s.hidden = s.dataset.ks !== b.dataset.ka; }); })); } async function load(root, u) { const r = await fetch('/api/promo-kit' + (u ? '?u=' + encodeURIComponent(u) : ''), { cache: 'no-store' }); const k = await r.json(); render(root, k); return k; } return { render, load, copy }; })();