Zones: ad slots on members' own sites (LinkSpin campaign > Network Ad Space > house waterfall, viewable-impression credits, /zones screen)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ window.CR = (function () {
|
||||
];
|
||||
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end
|
||||
const FALLBACK = { pages: '/my#promo', zones: '/my#campaigns', team: '/my#line', wallet: '/my#wallet' };
|
||||
const BUILT = new Set(['links', 'pages', 'reports', 'team', 'wallet']);
|
||||
const BUILT = new Set(['links', 'pages', 'zones', 'reports', 'team', 'wallet']);
|
||||
let ME = null, toastT;
|
||||
function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); } t.textContent = msg; t.style.background = bad ? '#FF7A7A' : ''; t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 2000); }
|
||||
async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; }
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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 || {};
|
||||
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, capped at ' + (RATE.capPerVisitorDay || 50) + ' credited views per visitor per zone per day. House banners are not paid. Bots never count.';
|
||||
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>' : '') + '<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>') + (!z.active ? ' <span class="tag warn">OFF</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">×</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 · network frequency: one credited view per visitor per zone per day up to the cap';
|
||||
$('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.'; $('tagCopy').onclick = () => CR.copy(tag(z)); $('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)); }; }
|
||||
$('newBtn').addEventListener('click', async () => {
|
||||
const v = await dialog({ title: 'Add a zone', text: 'One zone per spot on a page. Pick the size that fits the space.', fields: [{ k: 'name', label: 'Name', placeholder: 'My blog · sidebar', max: 60 }, { k: 'site', label: 'Site it lives on', 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); }
|
||||
});
|
||||
CR.requireSession(load);
|
||||
})();
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="160" height="600" viewBox="0 0 160 600" role="img" aria-label="LinkSpin, one link, every page you promote"><rect width="160" height="600" rx="6" fill="#0B1220"/><rect x="0.5" y="0.5" width="159" height="599" rx="6" fill="none" stroke="#2A3A56"/><circle cx="136" cy="18" r="8" fill="none" stroke="#3B9DFF" stroke-width="3" stroke-dasharray="30 12"/><text x="80" y="60" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="800" font-size="22" fill="#E6EDF7">Link<tspan fill="#3B9DFF">Spin</tspan></text><text x="80" y="110" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="14" fill="#AFC0D8">One link.</text><text x="80" y="132" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="14" fill="#AFC0D8">Every page</text><text x="80" y="154" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-size="14" fill="#AFC0D8">you promote.</text><rect x="20" y="480" width="120" height="34" rx="6" fill="#3B9DFF"/><text x="80" y="502" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="700" font-size="13" fill="#061225">Get your link</text></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="250" viewBox="0 0 300 250" role="img" aria-label="LinkSpin, one link, every page you promote"><rect width="300" height="250" rx="6" fill="#0B1220"/><rect x="0.5" y="0.5" width="299" height="249" rx="6" fill="none" stroke="#2A3A56"/><circle cx="284" cy="234" r="8" fill="none" stroke="#3B9DFF" stroke-width="3" stroke-dasharray="30 12"/><text x="24" y="70" font-family="Segoe UI,Arial,sans-serif" font-weight="800" font-size="30" fill="#E6EDF7">Link<tspan fill="#3B9DFF">Spin</tspan></text><text x="24" y="110" font-family="Segoe UI,Arial,sans-serif" font-size="16" fill="#AFC0D8">One link. Every page you promote, in turn.</text><text x="24" y="134" font-family="Segoe UI,Arial,sans-serif" font-size="14" fill="#6E82A3">Weights, hours, health checks, real numbers.</text><rect x="24" y="170" width="140" height="38" rx="6" fill="#3B9DFF"/><text x="94" y="195" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="700" font-size="14" fill="#061225">Get your link</text></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="50" viewBox="0 0 320 50" role="img" aria-label="LinkSpin, one link, every page you promote"><rect width="320" height="50" rx="6" fill="#0B1220"/><rect x="0.5" y="0.5" width="319" height="49" rx="6" fill="none" stroke="#2A3A56"/><circle cx="304" cy="34" r="8" fill="none" stroke="#3B9DFF" stroke-width="3" stroke-dasharray="30 12"/><text x="18" y="30" font-family="Segoe UI,Arial,sans-serif" font-weight="800" font-size="16" fill="#E6EDF7">Link<tspan fill="#3B9DFF">Spin</tspan></text><rect x="192" y="11" width="110" height="28" rx="5" fill="#3B9DFF"/><text x="247" y="30" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="700" font-size="12" fill="#061225">Get your link</text></svg>
|
||||
|
After Width: | Height: | Size: 768 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="468" height="60" viewBox="0 0 468 60" role="img" aria-label="LinkSpin, one link, every page you promote"><rect width="468" height="60" rx="6" fill="#0B1220"/><rect x="0.5" y="0.5" width="467" height="59" rx="6" fill="none" stroke="#2A3A56"/><circle cx="452" cy="44" r="8" fill="none" stroke="#3B9DFF" stroke-width="3" stroke-dasharray="30 12"/><text x="18" y="37" font-family="Segoe UI,Arial,sans-serif" font-weight="800" font-size="22" fill="#E6EDF7">Link<tspan fill="#3B9DFF">Spin</tspan></text><text x="132" y="34" font-family="Segoe UI,Arial,sans-serif" font-size="13" fill="#AFC0D8">One link. Every page you promote, in turn.</text><rect x="340" y="16" width="110" height="28" rx="5" fill="#3B9DFF"/><text x="395" y="35" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="700" font-size="12" fill="#061225">Get your link</text></svg>
|
||||
|
After Width: | Height: | Size: 908 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="728" height="90" viewBox="0 0 728 90" role="img" aria-label="LinkSpin, one link, every page you promote"><rect width="728" height="90" rx="6" fill="#0B1220"/><rect x="0.5" y="0.5" width="727" height="89" rx="6" fill="none" stroke="#2A3A56"/><circle cx="712" cy="74" r="8" fill="none" stroke="#3B9DFF" stroke-width="3" stroke-dasharray="30 12"/><text x="18" y="52" font-family="Segoe UI,Arial,sans-serif" font-weight="800" font-size="22" fill="#E6EDF7">Link<tspan fill="#3B9DFF">Spin</tspan></text><text x="132" y="49" font-family="Segoe UI,Arial,sans-serif" font-size="13" fill="#AFC0D8">One link. Every page you promote, in turn.</text><rect x="600" y="31" width="110" height="28" rx="5" fill="#3B9DFF"/><text x="655" y="50" text-anchor="middle" font-family="Segoe UI,Arial,sans-serif" font-weight="700" font-size="12" fill="#061225">Get your link</text></svg>
|
||||
|
After Width: | Height: | Size: 908 B |
+32
@@ -0,0 +1,32 @@
|
||||
/* LinkSpin zone tag. One line on your site: <script async src="https://linkspin.app/z.js" data-zone="ls-xxxxxx"></script>
|
||||
Renders a banner from the LinkSpin ad pool in place, reports one viewable impression (half the banner on screen for
|
||||
one second), nothing else. No cookies, no personal data. */
|
||||
(function () {
|
||||
var s = document.currentScript; if (!s) return;
|
||||
var zone = s.getAttribute('data-zone') || ''; if (!/^ls-[a-f0-9]{6}$/.test(zone)) return;
|
||||
var base = (s.src || '').replace(/\/z\.js.*$/, '');
|
||||
var box = document.createElement('div'); box.style.cssText = 'display:inline-block;line-height:0;max-width:100%'; s.parentNode.insertBefore(box, s);
|
||||
function load() {
|
||||
var r = new XMLHttpRequest(); r.open('GET', base + '/api/zone/serve?z=' + encodeURIComponent(zone), true);
|
||||
r.onload = function () {
|
||||
if (r.status !== 200) return; var ad; try { ad = JSON.parse(r.responseText).ad; } catch (e) { return; } if (!ad || (!ad.img && !ad.frame)) return;
|
||||
var el;
|
||||
if (ad.frame) { // a network ad: rendered inside our own frame so its script lands in a page we control
|
||||
el = document.createElement('iframe'); el.src = base + ad.frame; el.width = ad.w; el.height = ad.h; el.title = 'Advertisement'; el.setAttribute('scrolling', 'no'); el.setAttribute('frameborder', '0'); el.style.cssText = 'max-width:100%;border:0;display:block;overflow:hidden'; el.sandbox = 'allow-scripts allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation';
|
||||
box.innerHTML = ''; box.appendChild(el);
|
||||
} else {
|
||||
var a = document.createElement('a'); a.href = base + ad.click; a.target = '_blank'; a.rel = 'noopener nofollow sponsored';
|
||||
var img = document.createElement('img'); img.src = /^https?:/.test(ad.img) ? ad.img : base + ad.img; img.alt = ad.alt || 'Advertisement'; img.width = ad.w; img.height = ad.h; img.style.cssText = 'max-width:100%;height:auto;border:0;display:block';
|
||||
a.appendChild(img); box.innerHTML = ''; box.appendChild(a); el = img;
|
||||
}
|
||||
var sent = false, timer = null;
|
||||
function ping() { if (sent) return; sent = true; try { navigator.sendBeacon(base + '/api/zone/seen?i=' + ad.imp); } catch (e) { var q = new XMLHttpRequest(); q.open('GET', base + '/api/zone/seen?i=' + ad.imp, true); q.send(); } }
|
||||
if ('IntersectionObserver' in window) {
|
||||
var io = new IntersectionObserver(function (es) { es.forEach(function (e) { if (e.intersectionRatio >= 0.5) { if (!timer) timer = setTimeout(function () { ping(); io.disconnect(); }, 1000); } else if (timer) { clearTimeout(timer); timer = null; } }); }, { threshold: [0, 0.5, 1] });
|
||||
io.observe(el);
|
||||
} else { setTimeout(ping, 1500); }
|
||||
};
|
||||
r.send();
|
||||
}
|
||||
load();
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<title>Zones · LinkSpin</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/cr.css?v=20260929b">
|
||||
<style>
|
||||
.body{padding:16px 24px;display:grid;gap:16px}
|
||||
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
|
||||
.zl .hd,.zl .rw{grid-template-columns:minmax(0,2fr) 90px 90px 80px 90px 90px 120px}
|
||||
.q{display:inline-flex;gap:2px;vertical-align:middle;margin-right:6px} .q i{display:block;width:4px;height:10px;background:var(--line)} .q i.on{background:currentColor}
|
||||
@media (max-width:900px){.two{grid-template-columns:1fr}.zl .hd{display:none}.zl .rw{grid-template-columns:1fr 1fr}.body{padding:12px 16px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="body">
|
||||
<div class="tiles" id="tiles"></div>
|
||||
<div class="two">
|
||||
<div class="tbl zl"><div class="hd"><span>Zone</span><span>Size</span><span class="r">Views</span><span class="r">Viewable</span><span class="r">Credits</span><span>Quality</span><span></span></div><div id="rows"></div><div class="ft" id="foot"></div></div>
|
||||
<div style="display:grid;gap:16px;align-content:start">
|
||||
<div class="panel" id="tagPanel" hidden><h2 id="tagTitle">Embed tag</h2><div class="code" id="tagCode" style="display:block;font-size:11px;line-height:1.6;word-break:break-all"></div><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn sm" type="button" id="tagCopy">Copy tag</button><button class="btn sm" type="button" id="tagCheck">Check it is live</button></div><div class="muted" id="tagNote">Paste it where the banner should appear. It sizes itself.</div></div>
|
||||
<div class="panel"><h2>What runs here</h2><div class="ink2">Three tiers, in order: a LinkSpin member campaign (the same pool the ad viewer serves), then a Network Ad Space ad for 728x90 and 468x60 zones, then a LinkSpin house banner. Your site carries the whole network, not just LinkSpin.</div><div class="muted" id="rateNote"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
||||
<script src="/assets/zones-screen.js?v=20260929a"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user