Files
martbost f63a37947a Publisher program (/publishers + zone tiers), chatbot rewritten for LinkSpin, $25 qualification copy fixes
Publisher program (Marty's zone-owner offer for outside site owners):
- /publishers public page: what a zone is, the nine sizes, the waterfall (member ads, network ads, house),
  what pays (viewable only, bots never, warm-up 100 views at 40%, cap), what credits buy, install in four steps
  with the origin lock explained, Standard/Verified tiers, FAQ, and a live "Network right now" strip
- GET /api/public/publishers: zones installed/live, viewable impressions and credits paid in the last 7 days,
  live rates, sizes, warm-up; computed in zones.js and cached a minute
- zones.js: per-zone tier (default standard); verified zones earn network views at nasViewsPerCreditVerified
  (default 8) instead of nasViewsPerCredit (10); member-campaign views stay at viewsPerCredit (5) on both tiers;
  rateFor/tierOf exported; a pay log (zones.json "pay") so credits can be reported by day; publisherTotals(days)
  returns {zones, live, views, viewable, credits, byDay, byZone} with Central day keys for the Reports screen
- admin: Tier select per zone in the Zones pane, saved via POST /api/admin/zones/:id (tier) or the alias
  /api/admin/zones/:id/tier; the admin list carries the 7-day publisher totals
- Zones screen: first-run "Add your site" card (site, size, copy the tag, check it is live) for new accounts and
  for /zones?start=1 from the publisher page; Verified tag on zone rows; rate note mentions the verified rate
- /partners (downline-builder kit) keeps its URL, gets the real LinkSpin ladder ($10 door to $500 Network, $25
  qualifies), the 10% + 10% admin split, and a cross-link to the publisher program

Chatbot: every canned answer and the AI knowledge block now describe LinkSpin (spin links, pages, zones and the
publisher tiers, audiences, promo tools with the five hook angles, blog; the six packages, the 50/20/10/10+10 split,
$25 qualification, pass-ups, the contract; email codes, Control Room screens, sponsor carry-over from the network
registry, free activation). InstantAdPay-only mechanics removed (dormant-lead rescue, Five Dollar Friday, Wired
Wednesday, games, mint passes, surf earn tab); the holding tank stays because /tools > My line still runs it here.

Copy: "Level 2 opens after two of your people buy a $25 or larger package" on the home page, contract, launch,
earning, my, plays pages and promo.js (the $20 figures that remain are the $100 example split amounts).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 11:34:42 -05:00

67 lines
12 KiB
JavaScript

// LinkSpin Zones screen: list, create, embed tag, live check, quality grade.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
let Z = [], SEL = null, HOST = location.host, SIZES = [], RATE = {};
CR.mount({ active: 'zones', title: 'Zones', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ Add a zone</button>' });
const ago = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + ' h ago'; return Math.floor(d / 86400e3) + ' d ago'; };
const tag = z => '<script async src="https://' + HOST + '/z.js" data-zone="' + z.id + '"></script>';
async function load() {
let r; try { r = await CR.get('/api/my/zones'); } catch (e) { CR.sub('could not load'); return; }
Z = r.zones || []; HOST = r.host || HOST; SIZES = r.sizes || []; RATE = r.rates || {}; RATE.warmup = r.warmup || 100;
const t = Z.reduce((a, z) => { a.v += z.views30; a.ok += z.viewable30; a.k += z.clicks30; a.c += z.credits; return a; }, { v: 0, ok: 0, k: 0, c: 0 });
CR.sub(Z.length + ' zone' + (Z.length === 1 ? '' : 's') + ' · ' + fmt(t.v) + ' views in 30 days');
$('tiles').innerHTML = [['Views served, 30 d', fmt(t.v)], ['Viewable', t.v ? Math.round(t.ok / t.v * 100) + '%' : '0%'], ['Clicks out', fmt(t.k)], ['Credits earned', fmt(t.c)]].map(([k, v], i) => '<div class="tile' + (i === 3 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
$('rateNote').textContent = 'You earn 1 credit per ' + (RATE.viewsPerCredit || 5) + ' viewable views of a LinkSpin campaign and 1 per ' + (RATE.nasViewsPerCredit || 10) + ' viewable views of a network ad (1 per ' + (RATE.nasViewsPerCreditVerified || 8) + ' on a Verified zone), capped at ' + (RATE.capPerVisitorDay || 50) + ' credited views per visitor per zone per day. House banners are not paid. Bots never count. Every zone starts Standard; a reviewed site can be marked Verified by the admin.';
firstRun();
const q = g => '<span class="q ' + (g === 'A' ? 'ok' : g === 'B' ? 'warn' : g === 'C' ? 'bad' : 'muted') + '">' + [1, 2, 3, 4, 5].map(i => '<i class="' + (g === 'A' ? (i <= 5 ? 'on' : '') : g === 'B' ? (i <= 3 ? 'on' : '') : g === 'C' ? (i <= 1 ? 'on' : '') : '') + '"></i>').join('') + '</span>' + (g || '');
$('rows').innerHTML = Z.length ? Z.map(z => '<div class="rw' + (z.id === SEL ? ' on' : '') + '"><div><b>' + esc(z.name) + '</b>' + (z.site ? ' <span class="muted">· ' + esc(z.site) + '</span>' : '') + (z.tier === 'verified' ? ' <span class="tag ok">Verified</span>' : '') + '<br><span class="mono muted" style="font-size:11px">' + z.id + ' · ' + (z.lastSeen ? 'last view ' + ago(z.lastSeen) : 'no views yet') + (z.views30 ? ' · mix: ' + fmt(z.campaign30 || 0) + ' LinkSpin / ' + fmt(z.nas30 || 0) + ' network / ' + fmt(z.house30 || 0) + ' house' : '') + '</span></div><span class="mono">' + z.size + '</span><span class="r num">' + fmt(z.views30) + '</span><span class="r num">' + (z.viewablePct == null ? '<span class="muted">·</span>' : z.viewablePct + '%') + '</span><span class="r num">' + fmt(z.credits) + '</span><span class="mono" style="font-size:11px">' + (z.grade ? q(z.grade) : '<span class="muted">no data</span>') + ' <span class="tag ' + (z.status === 'earning' ? 'ok' : z.status === 'warming' ? '' : 'warn') + '">' + esc(z.statusLabel || '') + '</span>' + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap"><button class="btn sm" type="button" data-tag="' + z.id + '">Tag</button><button class="btn sm" type="button" data-tog="' + z.id + '">' + (z.active ? 'Off' : 'On') + '</button><button class="btn sm danger" type="button" data-del="' + z.id + '" aria-label="Remove">&times;</button></span></div>').join('')
: '<div class="rw"><span class="muted">No zones yet. Add one, paste the tag on your site, and the banner is live.</span></div>';
$('foot').textContent = 'viewable = at least half the banner on screen for one second, reported by the tag · quality: A 60%+ viewable, B 40%+, C below · paid ads serve only on the declared site; a zone earns after its first 100 on-site views with 40%+ viewable and goes on hold below that';
$('rows').querySelectorAll('[data-tag]').forEach(b => b.addEventListener('click', () => showTag(b.dataset.tag)));
$('rows').querySelectorAll('[data-tog]').forEach(b => b.addEventListener('click', async () => { const z = Z.find(x => x.id === b.dataset.tog); try { await api('/api/my/zones/' + z.id, { active: !z.active }); load(); } catch (e) { toast(e.message, true); } }));
$('rows').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this zone?', text: 'The tag on your site stops showing ads. Credits already earned stay.', ok: 'Remove', danger: true })) return; try { await api('/api/my/zones/' + b.dataset.del, { remove: true }); SEL = null; $('tagPanel').hidden = true; load(); } catch (e) { toast(e.message, true); } }));
if (SEL && Z.find(z => z.id === SEL)) showTag(SEL);
}
function showTag(id) { const z = Z.find(x => x.id === id); if (!z) return; SEL = id; $('tagPanel').hidden = false; $('tagTitle').textContent = 'Embed tag · ' + z.name; $('tagCode').textContent = tag(z); $('tagNote').textContent = 'Paste it where the banner should appear (' + z.size + '). It sizes itself and never loads more than one ad. Tip: do not wrap it in an element whose class or id contains "ad", "banner" or "sponsor" (ad blockers hide those), and if you test with an ad blocker on, pause it for your own site first.'; $('tagCopy').onclick = () => { CR.copy(tag(z)); COPIED = true; LS.set('ls.zoneTagCopied', '1'); firstRun(); }; $('tagCheck').onclick = async () => { await load(); const zz = Z.find(x => x.id === id); toast(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3 ? 'Live: last view ' + ago(zz.lastSeen) : 'No view in the last hour. Is the tag on a page people open?', !(zz && zz.lastSeen && Date.now() - zz.lastSeen < 3600e3)); }; }
async function addZone() {
const v = await dialog({ title: 'Add a zone', text: 'One zone per spot on a page. Paid ads only serve on the site you name here; anywhere else the tag shows the house banner.', fields: [{ k: 'name', label: 'Name', placeholder: 'My blog · sidebar', max: 60 }, { k: 'site', label: 'Site it lives on (required)', placeholder: 'myblog.com', max: 80 }, { k: 'size', label: 'Size: ' + (SIZES.join(', ') || '728x90, 468x60, 300x250, 160x600, 320x50'), value: '728x90', mono: true }], ok: 'Create' });
if (!v) return; try { const r = await api('/api/my/zones', v); SEL = r.zone.id; toast('Zone created. Copy the tag.'); load(); } catch (e) { toast(e.message, true); }
}
$('newBtn').addEventListener('click', addZone);
// ---- first-run card (publisher onboarding, 2026-10-10): site, size, copy the tag, check it is live. Shows while the
// account has no zone with a view, or when /zones?start=1 (the /publishers Start button) asks for it; Hide remembers.
const START = /[?&]start=1\b/.test(location.search); const LS = { get: k => { try { return localStorage.getItem(k); } catch (e) { return null; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch (e) {} } };
let COPIED = LS.get('ls.zoneTagCopied') === '1';
function firstRun() {
const fr = $('firstRun'); if (!fr) return;
const live = Z.some(z => z.lastSeen); const hidden = LS.get('ls.zonesFirstRunHidden') === '1';
if ((hidden || live) && !START) { fr.hidden = true; return; }
fr.hidden = false;
const step = !Z.length ? 1 : (!COPIED && !live) ? 3 : !live ? 4 : 5; // 1-2 site+size, 3 copy, 4 check, 5 done
const steps = [['Your site', 'The domain the tag will live on, exactly as the address bar shows it. Paid ads serve only there.'], ['Size', 'The banner size of the spot. 728x90 and 468x60 also get network ads.'], ['Copy the tag', 'Paste it where the banner should appear: a widget, a template, an HTML block.'], ['Check it is live', 'Open your page once, then press the button. The warm-up counter starts with that first view.']];
$('frSteps').innerHTML = steps.map(([t, d], i) => { const n = i + 1; const done = n < step || (n <= 2 && step > 2) || step === 5; const now = !done && (n === step || (step === 1 && n === 2)); return '<li class="' + (done ? 'done' : now ? 'now' : '') + '"><b><i>' + (done ? '✓' : n) + '</i>' + t + '</b><span class="muted">' + d + '</span></li>'; }).join('');
$('frTitle').textContent = step === 5 ? 'Your site is live' : 'Add your site';
$('frIntro').textContent = step === 5 ? 'The tag is serving. The zone earns after its first ' + (RATE.warmup || 100) + ' on-site views with 40% or more viewable; the status column tells you where it stands. Add another spot any time.' : step >= 3 ? 'Zone created. Copy the tag, paste it on ' + esc(Z[0].site) + ', then check it is live.' : 'Four steps and your site is carrying the network. Paid ads serve only on the site you name, and every viewable impression pays you ad credits.';
const go = $('frGo'); go.textContent = step === 1 ? 'Add your site' : step === 3 ? 'Show the tag' : step === 4 ? 'Check it is live' : 'Add another zone';
go.onclick = () => { if (step === 1 || step === 5) return addZone(); showTag(Z[0].id); if (step === 4) $('tagCheck').click(); };
$('frHide').onclick = () => { LS.set('ls.zonesFirstRunHidden', '1'); fr.hidden = true; };
}
// ---- audiences (first-party retargeting)
const ptag = a => '<script async src="https://' + HOST + '/p.js" data-aud="' + a.id + '"></script>';
async function loadAudiences() {
let r; try { r = await CR.get('/api/my/audiences'); } catch (e) { return; }
const A = r.audiences || []; HOST = r.host || HOST;
$('audList').innerHTML = A.map(a => '<div style="padding:8px 0;border-top:1px solid var(--line)"><div style="display:flex;justify-content:space-between;gap:8px;align-items:center"><b>' + esc(a.name) + '</b>'
+ '<span class="mono muted" style="font-size:11px">' + fmt(a.size30) + ' in 30 d · ' + fmt(a.size7) + ' in 7 d' + (a.soft ? ' · ' + fmt(a.soft) + ' without cookie (24 h)' : '') + '</span></div>'
+ (a.auto ? '<div class="muted" style="font-size:11.5px">Automatic: your pages and your zones feed it. You can also paste its pixel elsewhere.</div>' : '')
+ '<div class="code" style="display:block;font-size:10.5px;line-height:1.5;word-break:break-all;margin:6px 0">' + esc(ptag(a)) + '</div>'
+ '<div style="display:flex;gap:6px;flex-wrap:wrap"><button class="btn sm" type="button" data-copy="' + a.id + '">Copy pixel</button>'
+ (a.auto ? '' : '<button class="btn sm ghost" type="button" data-ren="' + a.id + '">Rename</button><button class="btn sm ghost danger" type="button" data-del="' + a.id + '">Remove</button>') + '</div></div>').join('');
$('audList').querySelectorAll('[data-copy]').forEach(b => b.addEventListener('click', () => CR.copy(ptag(A.find(a => a.id === b.dataset.copy)))));
$('audList').querySelectorAll('[data-ren]').forEach(b => b.addEventListener('click', async () => { const a = A.find(x => x.id === b.dataset.ren); const v = await dialog({ title: 'Rename audience', fields: [{ k: 'name', label: 'Name', value: a.name }], ok: 'Save' }); if (!v) return; try { await api('/api/my/audiences', { id: a.id, name: v.name }); toast('Renamed'); loadAudiences(); } catch (e) { toast(e.message, true); } }));
$('audList').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => { const a = A.find(x => x.id === b.dataset.del); if (!await dialog({ title: 'Remove ' + a.name + '?', text: 'Its visitor list is deleted. Campaigns that used it stop matching anyone.', ok: 'Remove', danger: true })) return; try { await api('/api/my/audiences', { id: a.id, remove: true }); toast('Removed'); loadAudiences(); } catch (e) { toast(e.message, true); } }));
}
$('audNew').addEventListener('click', async () => { const v = await dialog({ title: 'New audience', text: 'Name it after where the pixel will go, like "Blog readers" or "Checkout page".', fields: [{ k: 'name', label: 'Name', placeholder: 'Blog readers' }], ok: 'Create' }); if (!v) return; try { await api('/api/my/audiences', { name: v.name }); toast('Created. Paste its pixel on the site.'); loadAudiences(); } catch (e) { toast(e.message, true); } });
CR.requireSession(() => { load(); loadAudiences(); });
})();