Banner Spin engine (phase 1): /i/ image with no-store + fresh ETag, /c/ click matching (visitor key + placement host note, 15 min) with fallback, /s/ exact-match script embed, impression counters flushed every 5 s (read-add-write), banner clicks with lsid conversions + source postbacks, tiers ($25 own package; Starter 2x5, Builder 5x15, Leader 10x25), member + admin API, admin kill switch per Banner Spin / per banner / global, Banner Spins in admin Member content

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-18 10:58:44 -05:00
parent e0e0bde1f9
commit 406113bc03
6 changed files with 507 additions and 11 deletions
+8 -2
View File
@@ -515,7 +515,7 @@
const ctHost = u => { try { return new URL(u, location.origin).hostname.replace(/^www\./, ''); } catch (e) { return ''; } };
const ctCut = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
const ctLabel = k => ((CT.data && CT.data.types) || []).reduce((m, t) => t.key === k ? t.label : m, k);
const CT_ONE = { page: 'Page', link: 'Link', source: 'Source', zone: 'Zone', ad: 'Ad', postback: 'Postback', upload: 'Upload', profile: 'Profile', message: 'Broadcast', audience: 'Audience', video: 'Video' };
const CT_ONE = { page: 'Page', link: 'Link', bannerspin: 'Banner Spin', source: 'Source', zone: 'Zone', ad: 'Ad', postback: 'Postback', upload: 'Upload', profile: 'Profile', message: 'Broadcast', audience: 'Audience', video: 'Video' };
function ctDetail(r) {
const d = r.detail || {}; const L = [];
const line = h => { if (h) L.push('<div class="ct-l">' + h + '</div>'); };
@@ -529,6 +529,11 @@
line(ctA(r.url, ctCut(r.url, 60)) + ' · <span class="mono">' + esc(d.code) + '</span> · ' + ds.length + ' destination' + (ds.length === 1 ? '' : 's') + (d.dayparted ? ' · dayparted' : '') + (d.expires ? ' · demo expires ' + ctWhen(d.expires) : ''));
line(ds.slice(0, 6).map(x => '<span class="ct-dest' + (x.active ? '' : ' off') + '">' + ctA(x.url, ctHost(x.url) || x.url) + (x.weight > 1 ? ' ×' + x.weight : '') + (!x.active ? ' <span class="muted">' + (x.autoPaused ? 'auto-paused' : 'paused') + '</span>' : '') + (x.health && x.health !== 'ok' && x.health !== 'live' ? ' <span class="bad">' + esc(x.health) + '</span>' : '') + '</span>').join(' ') + (ds.length > 6 ? ' <span class="muted">+' + (ds.length - 6) + ' more</span>' : ''));
if (d.fallback) line('Fallback: ' + ctA(d.fallback, ctCut(d.fallback, 70)));
} else if (r.type === 'bannerspin') {
const bs = d.banners || [];
line('<span class="chip-t">' + esc(d.size) + '</span> <span class="mono">' + esc(d.code) + '</span> · ' + (d.mode === 'visitor' ? 'one per visitor' : 'random by weight') + ' · ' + bs.length + ' banner' + (bs.length === 1 ? '' : 's') + (d.dayparted ? ' · dayparted' : '') + ' · ' + ctA(d.image, 'image URL') + ' · ' + ctA(d.click, 'click URL'));
line(bs.slice(0, 8).map(x => '<span class="ct-dest' + (x.active && !x.adminOff ? '' : ' off') + '">' + ctImg(x.image) + ' #' + x.id + ' ' + (x.link ? 'spin link #' + x.link : ctA(x.target, ctHost(x.target) || x.target)) + (x.weight > 1 ? ' ×' + x.weight : '') + (x.adminOff ? ' <span class="bad">offline</span>' : !x.active ? ' <span class="muted">paused</span>' : '') + '</span>').join(' ') + (bs.length > 8 ? ' <span class="muted">+' + (bs.length - 8) + ' more</span>' : ''));
line('Fallback: ' + (d.fallback ? ctA(d.fallback, ctCut(d.fallback, 70)) : '<span class="muted">none</span>') + (d.fallbackImage ? ' ' + ctImg(d.fallbackImage) : ''));
} else if (r.type === 'source') {
line(esc(d.template === 'custom' ? 'Custom source' : 'Template ' + d.template) + (d.site ? ' · ' + ctA('https://' + d.site, d.site) : '') + (d.costModel ? ' · ' + esc(d.costModel) : '') + ' · ' + ctN(d.params) + ' params');
line(d.postbackUrl ? 'Postback (' + esc(d.method) + ', ' + esc((d.events || []).join(', ')) + '): <span class="mono small">' + esc(ctCut(d.postbackUrl, 90)) + '</span>' : '<span class="muted">No postback</span>');
@@ -565,6 +570,7 @@
const c = r.counts || {}; const d = r.detail || {}; const k = (n, l) => '<div><b>' + (n == null ? '-' : n) + '</b> <span class="muted">' + l + '</span></div>';
if (r.type === 'page') return k(ctN(c.views), 'views') + k(ctN(c.uniques), 'uniques') + k(ctN(c.clicks), 'clicks out') + k(ctN(c.leads), 'leads');
if (r.type === 'link') return k(ctN(c.clicks7), 'clicks 7d') + k(ctN(c.clicks), 'all time') + (c.conversions ? k(ctN(c.conversions), 'conversions') : '') + (c.bots ? k(ctN(c.bots), 'bots') : '');
if (r.type === 'bannerspin') return k(ctN(c.imps), 'impressions') + k(ctN(c.clicks), 'clicks') + (c.conversions ? k(ctN(c.conversions), 'conversions') : '');
if (r.type === 'zone') return k(ctN(c.views30), 'imps 30d') + k(c.viewablePct == null ? '-' : c.viewablePct + '%', 'viewable') + k(ctN(c.clicks30), 'clicks') + k(ctN(c.credits), 'credits paid');
if (r.type === 'ad') return k(ctN(d.spent) + ' / ' + ctN(d.budget), 'spent') + k(ctN(c.imps) + (c.impsNas ? ' +' + ctN(c.impsNas) : ''), 'views') + k(ctN(c.clicks), 'clicks');
if (r.type === 'source' || r.type === 'postback') return k(ctN(c.sent), 'sent') + k(ctN(c.fails), 'fails');
@@ -594,7 +600,7 @@
+ '<td data-l="Created" class="small when">' + ctWhen(r.created) + '</td>'
+ '<td data-l="Status"><span class="st ' + esc(r.live ? 'active' : (r.status === 'draft' || r.status === 'paused' ? r.status : 'out')) + '">' + esc(r.status) + '</span></td>'
+ '<td data-l="Numbers" class="small ct-nums">' + ctNums(r) + '</td>'
+ '<td class="act">' + (r.actions || []).map((a, j) => '<button type="button" class="btn small ' + (/^Pause/.test(a.label) ? 'sec' : '') + '" data-ctact="' + i + ':' + j + '">' + esc(a.label) + '</button>').join('') + (r.open && r.type !== 'page' ? ctA(r.open, 'Open') : '') + '</td></tr>').join('')
+ '<td class="act">' + (r.actions || []).map((a, j) => '<button type="button" class="btn small ' + (/^Pause|offline$/.test(a.label) ? 'sec' : '') + '" data-ctact="' + i + ':' + j + '">' + esc(a.label) + '</button>').join('') + (r.open && r.type !== 'page' ? ctA(r.open, 'Open') : '') + '</td></tr>').join('')
: '<tr><td colspan="7" class="muted">Nothing matches.</td></tr>');
$('ctPager').innerHTML = d.pages > 1 ? '<button type="button" class="btn small sec" data-ctpage="' + (d.page - 1) + '"' + (d.page <= 1 ? ' disabled' : '') + '>&larr; Newer</button><span class="small muted">Page ' + d.page + ' of ' + d.pages + ' · ' + d.per + ' per page</span><button type="button" class="btn small sec" data-ctpage="' + (d.page + 1) + '"' + (d.page >= d.pages ? ' disabled' : '') + '>Older &rarr;</button>' : '';
}