Files
viraladblitz/public/assets/kitpage.js
T
Marty Bostick 001878bdae ViralAdBlitz v1 (viraladblitz.com rebuild, Marty approved 2026-11-14): the network's text-ad home, local build, not deployed
- Free text ad for network members (InstantAdPay / LinkSpin sign-in or wallet, membership through the hub), one per member
- Member pages viraladblitz.com/<username>: own ad + the first 5 people above in the hub line with a live ad (by place) + 2 Boosted places
- Front page: amber ticker (Boosted starred), Top ads this week by verified clicks, today's numbers, ledger, contract proof
- Verified visitors / views / clicks (ticket + dwell + per-visitor dedupe + per-connection cap + bot filter, owner excluded)
- Boost $5 = 500 guaranteed views through VABShop: keeper-signed EIP-712 line voucher from the hub line, watcher, delivery
  counted per verified view with an audit row each, Network Ad Space text-ad finishing after 30 days (vabnas.js)
- Trust pack: /ledger, /contract, toasts, Telegram card per Boost (once), Terms / Earnings Disclaimer / Privacy (TrustClickz),
  network footer from the hub with tracked links, promo kit (21 creatives) + /promote, LinkSpin zone placeholders, hub report
- Old YFW links via the oldrefs map (admin load route); docstore MySQL documents + row tables
- qa/smoke.mjs 162/162 (stand-in hub, chain, Telegram, NAS; Playwright desktop + phone), qa/chain.mjs 20/20 (real VABShop on anvil)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 13:52:03 -06:00

52 lines
5.3 KiB
JavaScript

// 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 => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[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 '<button type="button" class="btn small ' + (cls || 'sec') + '" data-kc="' + (TXT.length - 1) + '">' + esc(label || 'Copy') + '</button>'; };
// 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) => '<div class="kit-row"><div class="kit-l"><span class="kit-lab">' + esc(label) + '</span><code class="kit-url">' + esc(url) + '</code></div>' + cb(url, 'Copy link', cls) + '</div>';
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 += '<div class="card"><h3>Your links</h3>' + (k.username ? '<p class="muted small">Every link, creative and line below carries <b>' + esc(k.username) + '</b>.</p>' : '<p class="muted small">Add your network username above so these links carry it.</p>')
+ 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) ? '<p class="muted small">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.</p>' : '') + '</div>';
h += '<div class="card"><h3>Creatives</h3><p class="muted small">Download them, or copy the HTML: it already links to you.</p><div class="kit-tabs" role="tablist">'
+ angles.map((c, i) => '<button type="button" class="kit-tab' + (i ? '' : ' on') + '" data-ka="' + esc(c.angle) + '">' + esc(c.angleLabel) + '</button>').join('') + '</div>';
angles.forEach((a, i) => {
h += '<div class="kit-set" data-ks="' + esc(a.angle) + '"' + (i ? ' hidden' : '') + '>' + by[a.angle].map(c =>
'<figure class="kit-fig kit-' + esc(c.shape) + '"><a href="' + esc(c.url) + '" target="_blank" rel="noopener"><img src="' + esc(local(c.url, k)) + '" alt="' + esc(k.name + ', ' + c.label) + '" width="' + c.w + '" height="' + c.h + '" loading="lazy"></a>'
+ '<figcaption><b>' + esc(c.label) + '</b> <span class="muted">' + c.w + 'x' + c.h + '</span><span class="kit-acts"><a class="btn small sec" href="' + esc(c.url) + '" download>Download</a>' + cb(c.url, 'Copy URL') + cb(c.html, 'Copy HTML') + '</span></figcaption></figure>').join('') + '</div>';
});
h += '</div>';
h += '<div class="card"><h3>Short lines</h3><p class="muted small">For chats, comments, text ads and signatures.</p>' + k.lines.map(t => '<div class="kit-row"><p class="kit-txt">' + esc(t) + '</p>' + cb(t) + '</div>').join('') + '</div>';
h += '<div class="card"><h3>Headlines</h3>' + k.headlines.map(t => '<div class="kit-row"><p class="kit-txt"><b>' + esc(t) + '</b></p>' + cb(t) + '</div>').join('') + '</div>';
h += '<div class="card"><h3>Email</h3><div class="kit-row"><p class="kit-txt"><span class="kit-lab">Subject</span>' + esc(k.email.subject) + '</p>' + cb(k.email.subject, 'Copy subject') + '</div>'
+ '<pre class="kit-pre">' + esc(k.email.body) + '</pre><div class="kit-row" style="justify-content:flex-end">' + cb(k.email.body, 'Copy email') + '</div></div>';
h += '<div class="card"><h3>Social posts</h3>' + k.posts.map(t => '<div class="kit-post"><pre class="kit-pre">' + esc(t) + '</pre><div class="kit-row" style="justify-content:flex-end">' + cb(t, 'Copy post') + '</div></div>').join('') + '</div>';
if (k.note) h += '<p class="muted small kit-note">' + esc(k.note) + '</p>';
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 };
})();