Banner Spin builder (phase 2) on the Links screen: Spin links / Banner Spins switch, New Banner Spin (size, fallback), uploads with real-size preview and size / 150 KB checks, targets (page or own spin link), weights, mode, hours, pause, fallback image, source, four copy-ready embeds, Gmail + paid-network notes, tier limits shown, simple stats by banner and placement; qa/bannerspin.mjs end-to-end test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
// LinkSpin Banner Spin builder (2026-10-18), the second view of the Links screen. One image address + one click address
|
||||
// rotate up to 25 banners, each with its own target. API: /api/my/bannerspins (bannerspin.js on the server). Uses the
|
||||
// Control Room shell (cr-shell.js) and the hours editor links.js shares as window.LSHours.
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
|
||||
let D = null, SPINS = [], SEL = null, STATS = {}, ROT = [], SRC = [], HOST = '', PEND = null, FB = null, BHE = null, HRS = null;
|
||||
const MAXB = () => (D && D.maxBytes) || 153600;
|
||||
const kb = n => Math.max(1, Math.round((n || 0) / 1024)) + ' KB';
|
||||
const sizeOf = s => s.size.split('x').map(Number);
|
||||
const pct = v => v == null ? '-' : v + '%';
|
||||
const health = s => s.adminOff ? { cls: 'bad', t: 'OFFLINE (ADMIN)' } : s.paused ? { cls: 'warn', t: 'PAUSED' } : !s.banners.some(b => b.active && !b.adminOff) ? { cls: 'bad', t: 'NO LIVE BANNER' } : { cls: 'ok', t: 'LIVE' };
|
||||
const base = () => 'https://' + (HOST || location.host);
|
||||
const imgUrl = s => base() + '/i/' + s.code + '.gif', clickUrl = s => base() + '/c/' + s.code, jsUrl = s => base() + '/s/' + s.code + '.js';
|
||||
|
||||
// ── view switch: Spin links | Banner Spins (hash #b or #b<id> opens this view) ──
|
||||
function setView(v) {
|
||||
const on = v === 'banners';
|
||||
$('vsw').querySelectorAll('button').forEach(b => b.classList.toggle('on', b.dataset.v === v));
|
||||
$('ws').hidden = on; $('bsWs').hidden = !on;
|
||||
const nb = $('newBtn'), bn = $('bsNewBtn'); if (nb) nb.hidden = on; if (bn) bn.hidden = !on;
|
||||
if (on) { if (!/^#b/.test(location.hash)) history.replaceState(null, '', '#b' + (SEL || '')); load(true); }
|
||||
else { if (/^#b/.test(location.hash)) history.replaceState(null, '', location.pathname); if (window.LSLinks) window.LSLinks.reload(); }
|
||||
}
|
||||
$('vsw').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setView(b.dataset.v)));
|
||||
|
||||
async function load(keep) {
|
||||
try { D = await CR.get('/api/my/bannerspins'); } catch (e) { toast(e.message, true); return; }
|
||||
SPINS = (D.spins || []).slice().sort((a, b) => (b.imps30 || 0) - (a.imps30 || 0));
|
||||
try { ROT = (await CR.get('/api/my/rotations')).rotations || []; } catch (e) { ROT = []; }
|
||||
try { SRC = (await CR.get('/api/my/sources')).sources || []; } catch (e) { SRC = []; }
|
||||
const hs = D.hosts || []; if (!HOST || !hs.some(h => h.host === HOST)) { const soc = hs.find(h => h.channel === 'social'); HOST = (soc || hs[0] || { host: location.host }).host; }
|
||||
renderTier(); renderList();
|
||||
if (!$('bsWs').hidden) CR.sub(SPINS.length + ' Banner Spin' + (SPINS.length === 1 ? '' : 's') + ' · ' + fmt(SPINS.reduce((n, x) => n + (x.imps30 || 0), 0)) + ' views in 30 days');
|
||||
const want = SEL != null ? SEL : (Number(location.hash.replace(/^#b/, '')) || null);
|
||||
if (want && SPINS.find(x => x.id === want)) return select(want, keep);
|
||||
if (!SPINS.length) { SEL = null; $('bsNoSel').hidden = false; $('bsSel').hidden = true; $('bsWs').classList.remove('focus'); return; }
|
||||
select(SPINS[0].id, true);
|
||||
}
|
||||
function renderTier() {
|
||||
const t = D.tier || {}; const used = SPINS.length;
|
||||
let h;
|
||||
if (!t.ok) h = '<div class="tierbar"><span class="tag warn">LOCKED</span><span>' + esc(t.reason || 'Banner Spin opens with your own package of $25 or more.') + '</span><a class="btn sm" href="/credits">Buy a package</a></div>';
|
||||
else h = '<div class="tierbar"><span class="tag ok">' + esc(t.label) + '</span><span><b>' + used + ' of ' + t.spins + '</b> Banner Spins, up to <b>' + t.banners + '</b> banners each.</span></div>'
|
||||
+ (t.next ? '<div class="muted" style="margin-top:4px">' + esc(t.next.label) + ': ' + t.next.spins + ' Banner Spins x ' + t.next.banners + ' banners, at ' + esc(t.next.need) + '.</div>' : '<div class="muted" style="margin-top:4px">Top tier. Free add-on, nothing to pay.</div>');
|
||||
if (D.off) h += '<div class="note" style="margin-top:6px">Banner Spin is switched off for maintenance. Your placements show a blank image until it is back.</div>';
|
||||
$('bsTier').innerHTML = h;
|
||||
$('bsNoSelText').textContent = t.ok ? 'One image address and one click address that rotate up to ' + t.banners + ' banners, each with its own target. Put it on your site, a forum signature or a safelist once; change the banners here any time.' : (t.reason || '') + ' Your tier then sets how many you can make: Starter 2 x 5 banners, Builder 5 x 15, Leader 10 x 25.';
|
||||
$('bsNewBtn2').hidden = !t.ok; const nb = $('bsNewBtn'); if (nb) nb.disabled = !t.ok || used >= t.spins;
|
||||
}
|
||||
function renderList() {
|
||||
$('bsCount').textContent = SPINS.length + ' Banner Spin' + (SPINS.length === 1 ? '' : 's');
|
||||
$('bsItems').innerHTML = SPINS.length ? SPINS.map(s => { const h = health(s); return '<div class="item' + (s.id === SEL ? ' on' : '') + '" data-id="' + s.id + '" role="button" tabindex="0"><div><div class="nm">' + esc(s.name) + (h.cls !== 'ok' ? ' <span class="tag ' + h.cls + '">' + h.t + '</span>' : '') + '</div><div class="cd">' + esc(s.size) + ' · ' + s.banners.length + ' banner' + (s.banners.length === 1 ? '' : 's') + ' · /i/' + esc(s.code) + '</div></div><div class="rt"><span class="n">' + fmt(s.imps30) + '</span><span class="muted" style="font-size:10px">views 30 d</span></div></div>'; }).join('')
|
||||
: '<div class="empty"><div class="muted">No Banner Spins yet.</div></div>';
|
||||
$('bsItems').querySelectorAll('.item').forEach(el => { const go = () => select(Number(el.dataset.id)); el.addEventListener('click', go); el.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); go(); } }); });
|
||||
}
|
||||
const cur = () => SPINS.find(x => x.id === SEL) || null;
|
||||
function select(id, quiet) {
|
||||
SEL = id; const s = cur(); if (!s) return;
|
||||
if (location.hash !== '#b' + id) history.replaceState(null, '', '#b' + id);
|
||||
$('bsNoSel').hidden = true; $('bsSel').hidden = false; $('bsWs').classList.add('focus');
|
||||
$('bsItems').querySelectorAll('.item').forEach(el => el.classList.toggle('on', Number(el.dataset.id) === id));
|
||||
$('bsName').textContent = s.name; $('bsSize').textContent = s.size;
|
||||
const h = health(s); $('bsLive').innerHTML = '<span class="' + h.cls + '"><span class="dot"></span>' + h.t + '</span>';
|
||||
$('bsPause').textContent = s.paused ? 'Resume' : 'Pause';
|
||||
$('bsHoursChip').textContent = LSHours.chip(s.hours, s.tz); $('bsHoursChip').classList.toggle('set', !!s.hours);
|
||||
$('bsOffNote').hidden = !s.adminOff; if (s.adminOff) $('bsOffNote').textContent = 'LinkSpin took this Banner Spin offline' + (s.adminNote ? ' (' + s.adminNote + ')' : '') + '. Placements show a blank image and clicks go to the fallback. Ask on Help if you think this is a mistake.';
|
||||
renderTiles(s, STATS[id]); renderBanners(s); renderSettings(s); renderCodes(s); renderAddLimit(s);
|
||||
if (!quiet) window.scrollTo({ top: 0 });
|
||||
loadStats(id);
|
||||
}
|
||||
function renderTiles(s, st) {
|
||||
const t = st && st.totals;
|
||||
$('bsTiles').innerHTML = [
|
||||
CR.tile({ k: 'Views, 30 d', v: fmt(s.imps30), hi: true }), CR.tile({ k: 'Views, all time', v: fmt(s.imps) }), CR.tile({ k: 'Clicks', v: fmt(s.clicks) }),
|
||||
CR.tile({ k: 'CTR', v: t && t.ctr != null ? t.ctr + '%' : (s.imps ? (Math.round(s.clicks / s.imps * 10000) / 100) + '%' : '-') }),
|
||||
CR.tile({ k: 'Click match rate', v: t ? pct(t.matchRate) : (s.clicks ? Math.round(s.matched / s.clicks * 100) + '%' : '-') }), CR.tile({ k: 'Conversions', v: fmt(s.conversions) }),
|
||||
CR.tile({ k: 'Live banners', v: s.banners.filter(b => b.active && !b.adminOff).length + ' / ' + s.banners.length })].join('');
|
||||
}
|
||||
const targetText = b => { if (b.link) { const r = ROT.find(x => x.id === b.link); return r ? 'Spin link: ' + r.name + ' (/r/' + r.code + ')' : 'Spin link (deleted)'; } return b.target; };
|
||||
function renderBanners(s) {
|
||||
const total = s.banners.filter(b => b.active && !b.adminOff).reduce((n, b) => n + b.weight, 0) || 1;
|
||||
const [W, H] = sizeOf(s);
|
||||
$('bsRows').innerHTML = s.banners.length ? s.banners.map(b => { const share = b.active && !b.adminOff ? Math.round(b.weight / total * 100) : 0;
|
||||
return '<div class="rw" data-bid="' + b.id + '"><div style="display:grid;gap:5px;min-width:0"><img class="bthumb" src="' + esc(b.image) + '" alt="" width="' + W + '" height="' + H + '" loading="lazy" referrerpolicy="no-referrer">'
|
||||
+ '<div style="font-weight:700">' + esc(b.label || 'Banner ' + b.id) + (b.hours ? ' <button class="hchip set" type="button" data-bh="' + b.id + '">' + esc(LSHours.text(b.hours)) + '</button>' : '') + '</div>'
|
||||
+ '<div class="mono muted" style="font-size:11px;overflow-wrap:anywhere">' + esc(targetText(b)) + '</div>'
|
||||
+ '<div style="font-size:11px">' + (b.w ? '<span class="' + (b.warn ? 'wm' : 'okm') + '">' + b.w + 'x' + b.h + (b.bytes ? ', ' + kb(b.bytes) : '') + (b.warn ? ', not ' + esc(s.size) : ', fits') + '</span>' : '<span class="muted">pasted image, size not checked</span>') + '</div></div>'
|
||||
+ '<div class="wrow"><div class="bar" style="width:60px"><i style="width:' + share + '%"></i></div><input class="field mono" type="number" min="1" max="100" value="' + b.weight + '" data-w="' + b.id + '" aria-label="Weight"><span class="mono muted" style="font-size:11px">' + share + '%</span></div>'
|
||||
+ '<span class="r num"><span class="ml">Views </span>' + fmt(b.imps) + '</span><span class="r num"><span class="ml">Clicks </span>' + fmt(b.clicks) + '</span>'
|
||||
+ '<span class="tag ' + (b.adminOff ? 'bad' : b.active ? 'ok' : 'dim') + '">' + (b.adminOff ? 'OFFLINE' : b.active ? 'LIVE' : 'PAUSED') + '</span>'
|
||||
+ '<span style="display:flex;gap:6px;justify-content:flex-end"><button class="btn sm" type="button" data-bh="' + b.id + '" title="Hours for this banner" aria-label="Hours for this banner"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></button><button class="btn sm" type="button" data-t="' + b.id + '">' + (b.active ? 'Pause' : 'Resume') + '</button><button class="btn sm danger" type="button" data-x="' + b.id + '" aria-label="Remove">×</button></span></div>'
|
||||
+ (BHE && BHE.sid === s.id && BHE.bid === b.id ? '<div class="rw edit" data-he="' + b.id + '"></div>' : ''); }).join('')
|
||||
: '<div class="rw"><span class="muted">No banners yet. Add the first one below. Until then every placement shows the fallback.</span></div>';
|
||||
$('bsFoot').textContent = 'weights are shares of the rotation · ' + (s.mode === 'visitor' ? 'one banner per visitor per day' : 'a fresh pick on every page view') + ' · fallback: ' + (s.fallback || 'none set') + (s.fallbackImps ? ' · fallback shown ' + fmt(s.fallbackImps) + ' times' : '');
|
||||
const heHost = $('bsRows').querySelector('[data-he]');
|
||||
if (heHost) { const b = s.banners.find(q => q.id === Number(heHost.dataset.he));
|
||||
LSHours.editor(heHost, { hours: b.hours, rotTz: s.tz, onCancel: () => { BHE = null; renderBanners(s); }, onSave: async hours => { try { await api('/api/my/bannerspins/' + s.id + '/banner/' + b.id, { hours }); BHE = null; toast(hours ? 'Hours saved' : 'Banner is always on'); load(true); } catch (e) { toast(e.message, true); } } }); }
|
||||
$('bsRows').querySelectorAll('[data-bh]').forEach(x => x.addEventListener('click', () => { const bid = Number(x.dataset.bh); BHE = BHE && BHE.bid === bid ? null : { sid: s.id, bid }; renderBanners(s); }));
|
||||
$('bsRows').querySelectorAll('[data-w]').forEach(i => i.addEventListener('change', async () => { try { await api('/api/my/bannerspins/' + s.id + '/banner/' + i.dataset.w, { weight: i.value }); toast('Weight saved'); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
$('bsRows').querySelectorAll('[data-t]').forEach(x => x.addEventListener('click', async () => { const b = s.banners.find(q => q.id === Number(x.dataset.t)); try { await api('/api/my/bannerspins/' + s.id + '/banner/' + b.id, { active: !b.active }); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
$('bsRows').querySelectorAll('[data-x]').forEach(x => x.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this banner?', text: 'Its numbers stay in the stats.', ok: 'Remove', danger: true })) return; try { await api('/api/my/bannerspins/' + s.id + '/banner/' + x.dataset.x, { remove: true }); toast('Removed'); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
// the "a click goes to" picker: a page address, or one of the member's spin links
|
||||
const sel = $('bsTgtKind'); const was = sel.value;
|
||||
sel.innerHTML = '<option value="url">A page address</option>' + ROT.map(r => '<option value="' + r.id + '">Spin link: ' + esc(r.name) + '</option>').join('');
|
||||
if ([...sel.options].some(o => o.value === was)) sel.value = was; $('bsTgtUrlWrap').hidden = sel.value !== 'url';
|
||||
}
|
||||
function renderAddLimit(s) {
|
||||
const t = D.tier || {}; const full = t.ok && s.banners.length >= t.banners;
|
||||
$('bsAddBtn').disabled = !t.ok || full;
|
||||
$('bsAddNote').innerHTML = !t.ok ? esc(t.reason || '') : full ? 'This Banner Spin holds ' + t.banners + ' banners on your ' + esc(t.label) + ' tier.' + (t.next ? ' ' + esc(t.next.label) + ' (' + esc(t.next.need) + ') holds ' + t.next.banners + '.' : '') : s.banners.length + ' of ' + t.banners + ' banners · uploads count toward your 10 files a day';
|
||||
}
|
||||
|
||||
// ── image checks: real size preview, wrong size / over limit warnings ──
|
||||
function measure(src) { return new Promise(res => { const im = new Image(); im.onload = () => res({ w: im.naturalWidth, h: im.naturalHeight }); im.onerror = () => res(null); im.referrerPolicy = 'no-referrer'; im.src = src; }); }
|
||||
function checkLine(s, d, bytes, kind) {
|
||||
const [W, H] = sizeOf(s); const out = [];
|
||||
if (kind && !/^image\/(png|jpeg|gif)$/.test(kind)) out.push('<span class="bm">Use a JPG, PNG or GIF file.</span>');
|
||||
if (bytes != null && bytes > MAXB()) out.push('<span class="bm">' + kb(bytes) + ' is over the 150 KB limit. Save it smaller (fewer colors or frames for a GIF).</span>');
|
||||
if (d && (d.w !== W || d.h !== H)) out.push('<span class="wm">This image is ' + d.w + 'x' + d.h + '; this Banner Spin is ' + W + 'x' + H + '. It would be stretched to fit. Use a ' + W + 'x' + H + ' image.</span>');
|
||||
if (d && d.w === W && d.h === H) out.push('<span class="okm">' + W + 'x' + H + (bytes != null ? ', ' + kb(bytes) : '') + ': fits this Banner Spin.</span>');
|
||||
if (!d) out.push('<span class="bm">That image did not load. Check the address.</span>');
|
||||
return out.join('<br>');
|
||||
}
|
||||
async function preview(host, s, src, bytes, kind) {
|
||||
const [W, H] = sizeOf(s);
|
||||
if (!src) { host.innerHTML = '<div class="bframe" style="width:' + W + 'px;height:' + H + 'px">' + W + 'x' + H + '</div><div class="muted" style="font-size:11px">Preview at real size</div>'; return null; }
|
||||
const d = await measure(src);
|
||||
host.innerHTML = (d ? '<img src="' + esc(src) + '" alt="" style="width:' + W + 'px;height:' + H + 'px" referrerpolicy="no-referrer">' : '') + '<div style="font-size:12px">' + checkLine(s, d, bytes, kind) + '</div><div class="muted" style="font-size:11px">Preview at real size, ' + W + 'x' + H + '</div>';
|
||||
return d;
|
||||
}
|
||||
async function pickFile(input, host, s, state) {
|
||||
const f = input.files && input.files[0]; if (!f) { state.file = null; return preview(host, s, null); }
|
||||
state.file = f; state.url = '';
|
||||
const u = URL.createObjectURL(f); const d = await preview(host, s, u, f.size, f.type); state.d = d; state.ok = !!d && f.size <= MAXB() && /^image\/(png|jpeg|gif)$/.test(f.type);
|
||||
}
|
||||
async function upload(f, s) {
|
||||
const r = await (await fetch('/api/my/bannerspins/upload?size=' + encodeURIComponent(s.size), { method: 'POST', headers: { 'Content-Type': f.type }, body: f })).json();
|
||||
if (r.error) throw new Error(r.error); return r;
|
||||
}
|
||||
// add a banner: upload first when a file is chosen, then save
|
||||
$('bsFile').addEventListener('change', () => { const s = cur(); if (!s) return; $('bsImgUrl').value = ''; PEND = PEND || {}; pickFile($('bsFile'), $('bsPrev'), s, PEND); });
|
||||
$('bsImgUrl').addEventListener('change', async () => { const s = cur(); if (!s) return; $('bsFile').value = ''; PEND = { url: $('bsImgUrl').value.trim() }; PEND.d = await preview($('bsPrev'), s, PEND.url || null); PEND.ok = !!PEND.d; });
|
||||
$('bsTgtKind').addEventListener('change', () => { $('bsTgtUrlWrap').hidden = $('bsTgtKind').value !== 'url'; });
|
||||
$('bsAddBtn').addEventListener('click', async () => {
|
||||
const s = cur(); if (!s) return; const P = PEND || {};
|
||||
if (!P.file && !P.url) { toast('Choose an image to upload or paste an image address', true); return; }
|
||||
if (P.file && !P.ok) { toast('Fix the image first (type, 150 KB limit)', true); return; }
|
||||
const body = { weight: $('bsWeight').value, label: $('bsLabel').value };
|
||||
if ($('bsTgtKind').value === 'url') { body.target = $('bsTgtUrl').value.trim(); if (!body.target) { $('bsTgtUrl').focus(); toast('Where should a click go?', true); return; } } else body.link = $('bsTgtKind').value;
|
||||
const b = $('bsAddBtn'); b.disabled = true;
|
||||
try {
|
||||
if (P.file) { const up = await upload(P.file, s); body.image = up.url; } else { body.image = P.url; if (P.d) { body.w = P.d.w; body.h = P.d.h; } }
|
||||
const r = await api('/api/my/bannerspins/' + s.id + '/banner', body);
|
||||
toast(r.warn ? 'Added. ' + r.warn : 'Banner added', !!r.warn);
|
||||
PEND = null; $('bsFile').value = ''; $('bsImgUrl').value = ''; $('bsLabel').value = ''; $('bsTgtUrl').value = ''; preview($('bsPrev'), s, null);
|
||||
await load(true);
|
||||
} catch (e) { toast(e.message, true); }
|
||||
b.disabled = false; renderAddLimit(cur() || s);
|
||||
});
|
||||
|
||||
// ── settings ──
|
||||
function renderSettings(s) {
|
||||
document.querySelectorAll('input[name="bsMode"]').forEach(r => { r.checked = r.value === (s.mode || 'weight'); });
|
||||
$('bsSrc').innerHTML = '<option value="">None</option>' + SRC.map(x => '<option value="' + x.id + '"' + (x.id === s.sourceId ? ' selected' : '') + '>' + esc(x.name) + (x.site ? ' · ' + esc(x.site) : '') + '</option>').join('');
|
||||
if (document.activeElement !== $('bsFallback')) $('bsFallback').value = s.fallback || '';
|
||||
if (!FB || FB.sid !== s.id) { FB = { sid: s.id }; $('bsFbFile').value = ''; $('bsFbUrl').value = /^https:/.test(s.fallbackImage || '') ? s.fallbackImage : ''; preview($('bsFbPrev'), s, s.fallbackImage || null); }
|
||||
$('bsFbClear').hidden = !s.fallbackImage;
|
||||
if (!(HRS && HRS.sid === s.id && HRS.dirty)) { HRS = { sid: s.id, dirty: false };
|
||||
LSHours.editor($('bsHours'), { hours: s.hours, tz: s.tz || 'visitor', onCancel: () => { HRS = null; renderSettings(s); }, onSave: async (hours, tz) => { try { await api('/api/my/bannerspins/' + s.id, { hours, tz }); HRS = null; toast(hours ? 'Hours saved' : 'Banner Spin is always on'); load(true); } catch (e) { toast(e.message, true); } } });
|
||||
$('bsHours').addEventListener('pointerdown', () => { if (HRS) HRS.dirty = true; }, { once: true }); }
|
||||
}
|
||||
document.querySelectorAll('input[name="bsMode"]').forEach(r => r.addEventListener('change', async () => { const s = cur(); if (!s || !r.checked) return; try { await api('/api/my/bannerspins/' + s.id, { mode: r.value }); toast(r.value === 'visitor' ? 'One banner per visitor per day' : 'Random by weight on every view'); load(true); } catch (e) { toast(e.message, true); } }));
|
||||
$('bsSrc').addEventListener('change', async () => { const s = cur(); if (!s) return; try { await api('/api/my/bannerspins/' + s.id, { sourceId: $('bsSrc').value }); toast($('bsSrc').value ? 'Source saved' : 'Source removed'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
$('bsFbFile').addEventListener('change', () => { const s = cur(); if (!s) return; $('bsFbUrl').value = ''; FB = { sid: s.id }; pickFile($('bsFbFile'), $('bsFbPrev'), s, FB); });
|
||||
$('bsFbUrl').addEventListener('change', async () => { const s = cur(); if (!s) return; $('bsFbFile').value = ''; FB = { sid: s.id, url: $('bsFbUrl').value.trim() }; FB.d = await preview($('bsFbPrev'), s, FB.url || null); });
|
||||
$('bsFbSave').addEventListener('click', async () => {
|
||||
const s = cur(); if (!s) return; const body = { fallback: $('bsFallback').value.trim() };
|
||||
try {
|
||||
if (FB && FB.file) { if (!FB.ok) { toast('Fix the fallback image first', true); return; } body.fallbackImage = (await upload(FB.file, s)).url; }
|
||||
else if (FB && FB.url) body.fallbackImage = FB.url;
|
||||
await api('/api/my/bannerspins/' + s.id, body); FB = null; toast('Fallback saved'); load(true);
|
||||
} catch (e) { toast(e.message, true); }
|
||||
});
|
||||
$('bsFbClear').addEventListener('click', async () => { const s = cur(); if (!s) return; try { await api('/api/my/bannerspins/' + s.id, { fallbackImage: '' }); FB = null; toast('Fallback image removed'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
|
||||
// ── the four embeds ──
|
||||
function renderCodes(s) {
|
||||
const hs = (D && D.hosts) || [];
|
||||
$('bsHost').innerHTML = hs.map(h => '<option value="' + esc(h.host) + '"' + (h.host === HOST ? ' selected' : '') + '>' + esc(h.host) + ' · ' + esc(h.label || h.channel) + '</option>').join('');
|
||||
const hh = hs.find(h => h.host === HOST); $('bsHostNote').textContent = hh && hh.note ? 'Meant for: ' + hh.note : '';
|
||||
const [W, H] = sizeOf(s); const src = SRC.find(x => x.id === s.sourceId);
|
||||
const qs = src && (src.params || []).length ? '?' + src.params.map(p => p.key + '=' + p.token).join('&') : '';
|
||||
const blocks = [
|
||||
['Image address + click address', 'For any place that asks for an image URL and a link URL (safelists, traffic exchanges, forum profiles).', imgUrl(s) + '\n' + clickUrl(s) + qs],
|
||||
['HTML snippet', 'For your own website or blog.', '<a href="' + clickUrl(s) + qs + '" target="_blank" rel="noopener"><img src="' + imgUrl(s) + '" width="' + W + '" height="' + H + '" alt="" style="border:0"></a>'],
|
||||
['Script tag (exact match)', 'Writes the banner and its own click link together, so every click lands on the right target. Use it wherever scripts are allowed.', '<script src="' + jsUrl(s) + '"></script>'],
|
||||
['Forum BBCode', 'For forum signatures and posts.', '[url=' + clickUrl(s) + qs + '][img]' + imgUrl(s) + '[/img][/url]']];
|
||||
$('bsCodes').innerHTML = blocks.map(([t, n, code], i) => '<div class="panel code-blk"><div class="hd2"><b>' + esc(t) + '</b><button class="btn sm pri" type="button" data-cp="' + i + '">Copy</button></div><div class="muted" style="font-size:12px">' + esc(n) + '</div><pre id="bsCode-' + i + '">' + esc(code) + '</pre>'
|
||||
+ (i === 0 ? '<div style="display:flex;gap:6px;flex-wrap:wrap"><button class="btn sm" type="button" data-cp1="img">Copy image address</button><button class="btn sm" type="button" data-cp1="click">Copy click address</button></div>' : '') + '</div>').join('')
|
||||
+ (src ? '<div class="muted" style="font-size:12px">The click address carries ' + esc(src.name) + '\'s macros, so its conversions fire that source\'s postback.</div>' : '');
|
||||
$('bsCodes').querySelectorAll('[data-cp]').forEach(b => b.addEventListener('click', () => CR.copy($('bsCode-' + b.dataset.cp).textContent)));
|
||||
$('bsCodes').querySelectorAll('[data-cp1]').forEach(b => b.addEventListener('click', () => CR.copy(b.dataset.cp1 === 'img' ? imgUrl(s) : clickUrl(s) + qs)));
|
||||
}
|
||||
$('bsHost').addEventListener('change', () => { HOST = $('bsHost').value; const s = cur(); if (s) renderCodes(s); });
|
||||
|
||||
// ── stats ──
|
||||
async function loadStats(id) {
|
||||
let st = STATS[id]; if (!st) { try { st = await CR.get('/api/my/bannerspins/' + id + '/stats'); } catch (e) { return; } STATS[id] = st; setTimeout(() => { delete STATS[id]; }, 30000); }
|
||||
if (SEL !== id) return; const s = cur(); if (s) renderTiles(s, st);
|
||||
const row = (name, o, extra) => '<div class="rw"><span style="overflow-wrap:anywhere">' + name + '</span><span class="r num">' + fmt(o.imps) + '</span><span class="r num">' + fmt(o.clicks) + '</span><span class="r num">' + (o.ctr == null ? '-' : o.ctr + '%') + '</span><span class="r num">' + (o.matchRate == null ? '-' : o.matchRate + '%') + '</span><span class="r num">' + (extra == null ? '' : fmt(extra)) + '</span></div>';
|
||||
$('bsStB').innerHTML = st.banners.length ? st.banners.map(b => row('<img src="' + esc(b.image) + '" alt="" style="max-height:28px;max-width:120px;vertical-align:middle;margin-right:6px" referrerpolicy="no-referrer">' + esc(b.label || 'Banner ' + b.id), b, b.conversions)).join('') + (st.fallback.imps || st.fallback.clicks ? row('<span class="muted">Fallback</span>', Object.assign({ matchRate: null }, st.fallback), null) : '') : '<div class="rw"><span class="muted">No banners yet.</span></div>';
|
||||
$('bsStP').innerHTML = st.placements.length ? st.placements.map(p => row(esc(p.host), p, null)).join('') : '<div class="rw"><span class="muted">No views yet. Put the code on a page and load it.</span></div>';
|
||||
const days = st.days || []; const dmax = Math.max(1, ...days.map(d => d.imps));
|
||||
$('bsDayBars').style.gridTemplateColumns = 'repeat(' + Math.max(1, days.length) + ',minmax(0,1fr))';
|
||||
$('bsDayBars').innerHTML = days.map(d => '<i style="height:' + Math.round(d.imps / dmax * 100) + '%" title="' + d.day + ' · ' + d.imps + ' views, ' + d.clicks + ' clicks"></i>').join('');
|
||||
$('bsDayAxis').innerHTML = days.length ? '<span>' + days[0].day + '</span><span>' + days[days.length - 1].day + '</span>' : '<span class="muted">no views recorded yet</span>';
|
||||
const t = st.totals; $('bsStNote').textContent = 'Views are counted on the server: bots and link previews are left out and one visitor reloading counts once a minute per banner. Matched = clicks we could tie to the banner that visitor saw (' + fmt(t.matched) + ' matched, ' + fmt(t.unmatched) + ' went to the fallback). About ' + fmt(t.uniquesSampled) + ' unique visitors (sampled).';
|
||||
}
|
||||
|
||||
// ── header actions ──
|
||||
async function newSpin() {
|
||||
const t = D && D.tier; if (!t || !t.ok) { toast((t && t.reason) || 'Banner Spin is locked', true); return; }
|
||||
if (SPINS.length >= t.spins) { toast('Your ' + t.label + ' tier holds ' + t.spins + ' Banner Spins', true); return; }
|
||||
let size = '468x60';
|
||||
const p = dialog({ title: 'New Banner Spin', text: 'One size per Banner Spin. Every banner in it should be that exact size.', html: '<label class="lbl">Size<select class="field mono" id="bsNewSize">' + ((D && D.sizes) || ['468x60']).map(z => '<option value="' + z + '"' + (z === size ? ' selected' : '') + '>' + z + '</option>').join('') + '</select></label>', fields: [{ k: 'name', label: 'Name (only you see it)', placeholder: 'Forum signature', max: 80 }, { k: 'fallback', label: 'Fallback page, where unmatched clicks go (you can set it later)', placeholder: 'https://', mono: true, type: 'url' }], ok: 'Create' });
|
||||
const ns = $('bsNewSize'); if (ns) ns.addEventListener('change', () => { size = ns.value; });
|
||||
const v = await p; if (!v || !v.name.trim()) return;
|
||||
try { const r = await api('/api/my/bannerspins', { name: v.name, size, fallback: v.fallback }); SEL = r.spin.id; toast('Banner Spin created. Add your banners.'); await load(true); } catch (e) { toast(e.message, true); }
|
||||
}
|
||||
const nb = $('bsNewBtn'); if (nb) nb.addEventListener('click', newSpin); $('bsNewBtn2').addEventListener('click', newSpin);
|
||||
$('bsBack').addEventListener('click', () => $('bsWs').classList.remove('focus'));
|
||||
$('bsBack').hidden = !window.matchMedia('(max-width:760px)').matches;
|
||||
$('bsRename').addEventListener('click', async () => { const s = cur(); if (!s) return; const v = await dialog({ title: 'Rename', fields: [{ k: 'name', label: 'Name', value: s.name, max: 80 }], ok: 'Save' }); if (!v || !v.name.trim()) return; try { await api('/api/my/bannerspins/' + s.id, { name: v.name }); load(true); } catch (e) { toast(e.message, true); } });
|
||||
$('bsPause').addEventListener('click', async () => { const s = cur(); if (!s) return; try { await api('/api/my/bannerspins/' + s.id, { paused: !s.paused }); toast(s.paused ? 'Live again' : 'Paused: placements show the fallback'); load(true); } catch (e) { toast(e.message, true); } });
|
||||
$('bsDel').addEventListener('click', async () => { const s = cur(); if (!s) return; if (!await dialog({ title: 'Delete ' + s.name + '?', text: 'Every placement using this image and click address stops working. This cannot be undone.', ok: 'Delete', danger: true })) return; try { await api('/api/my/bannerspins/' + s.id, { remove: true }); SEL = null; history.replaceState(null, '', '#b'); toast('Deleted'); load(); } catch (e) { toast(e.message, true); } });
|
||||
$('bsHoursChip').addEventListener('click', () => { showTab('settings'); const h = $('bsHours'); if (h.scrollIntoView) h.scrollIntoView({ block: 'start', behavior: 'smooth' }); });
|
||||
const TABS = ['banners', 'settings', 'code', 'stats'];
|
||||
const showTab = name => { $('bsTabs').querySelectorAll('button').forEach(x => x.classList.toggle('on', x.dataset.tab === name)); TABS.forEach(t => { $('bs-' + t).hidden = t !== name; }); if (name === 'stats' && SEL) { delete STATS[SEL]; loadStats(SEL); } };
|
||||
$('bsTabs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => showTab(b.dataset.tab)));
|
||||
// links.js owns the session check and calls ready() once signed in (one sign-in flow per page)
|
||||
let READY = false;
|
||||
window.BannerSpin = { setView, showTab, load, ready: () => { if (READY) return; READY = true; if (/^#b/.test(location.hash)) setView('banners'); setInterval(() => { if (!document.hidden && !$('bsWs').hidden) load(true); }, 60000); } };
|
||||
})();
|
||||
@@ -2,7 +2,7 @@
|
||||
(function () {
|
||||
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt, api = CR.api, toast = CR.toast, dialog = CR.dialog;
|
||||
let ROT = [], HOSTS = [], SEL = null, STATS = {}, FILTER = '', PB = null, SRC = []; // SRC = the member's traffic sources (sources.js, 2026-10-12)
|
||||
CR.mount({ active: 'links', title: 'Links', sub: 'loading', actions: '<button class="btn pri" id="newBtn" type="button">+ New spin</button>' });
|
||||
CR.mount({ active: 'links', title: 'Links', sub: 'loading', actions: '<button class="btn pri" id="newBtn" type="button">+ New spin</button><button class="btn pri" id="bsNewBtn" type="button" hidden>+ New Banner Spin</button>' });
|
||||
const linkUrl = r => 'https://' + (HOSTS[0] || location.host) + '/r/' + r.code;
|
||||
const clicks7 = r => r.hits7 || 0;
|
||||
const health = r => r.paused ? { cls: 'warn', t: 'PAUSED' } : !r.destinations.some(d => d.active) ? { cls: 'bad', t: 'NO LIVE DESTINATION' } : { cls: 'ok', t: 'LIVE' };
|
||||
@@ -56,6 +56,7 @@
|
||||
host.heState = () => ({ hours: grid.map(d => d.join('')), tz }); // so a redraw can keep unsaved taps
|
||||
paint();
|
||||
}
|
||||
window.LSHours = { editor: hoursEditor, text: hoursText, chip: hoursChip }; // shared with the Banner Spin builder (banner-spin.js, 2026-10-18)
|
||||
// ── health readouts ──
|
||||
const ago = ts => { const s = Math.max(0, Math.round((Date.now() - ts) / 1000)); return s < 60 ? 'just now' : s < 3600 ? Math.round(s / 60) + ' min ago' : s < 86400 ? Math.round(s / 3600) + ' h ago' : Math.round(s / 86400) + ' d ago'; };
|
||||
const mdy = ts => new Date(ts).toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
||||
@@ -74,8 +75,9 @@
|
||||
try { const lh = await api('/api/my/link-hosts'); LH = (lh && lh.hosts) || []; } catch (e) { LH = []; } // link domains by channel (domains.js, 2026-10-10)
|
||||
try { SRC = (await CR.get('/api/my/sources')).sources || []; } catch (e) { SRC = []; }
|
||||
const tot7 = ROT.reduce((n, x) => n + clicks7(x), 0);
|
||||
CR.sub(ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days');
|
||||
if (!/^#b/.test(location.hash)) CR.sub(ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days');
|
||||
renderList();
|
||||
if (/^#b/.test(location.hash)) { renderList(); return; } // the Banner Spin view owns the page (banner-spin.js)
|
||||
const want = SEL != null ? SEL : (Number(location.hash.slice(1)) || null);
|
||||
if (want != null && ROT.find(x => x.id === want)) return select(want, true);
|
||||
if (!ROT.length) { $('noSel').hidden = false; $('sel').hidden = true; SEL = null; }
|
||||
@@ -235,5 +237,6 @@
|
||||
catch (e) { toast(e.message, true); } b.disabled = false; b.textContent = 'Check now'; });
|
||||
$('pbNew').addEventListener('click', () => pbForm(null));
|
||||
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
|
||||
CR.requireSession(() => { load(); loadPb(); setInterval(() => { if (!document.hidden) load(true); }, 60000); });
|
||||
window.LSLinks = { reload: () => load(true) }; // the Banner Spin view switches back here
|
||||
CR.requireSession(() => { load(); loadPb(); if (window.BannerSpin) window.BannerSpin.ready(); setInterval(() => { if (!document.hidden) load(true); }, 60000); });
|
||||
})();
|
||||
|
||||
+104
-1
@@ -52,10 +52,34 @@
|
||||
@media (max-width:760px){.ws{grid-template-columns:minmax(0,1fr)}.tabs{flex-wrap:wrap}.list{border-right:0;border-bottom:1px solid var(--line);max-height:44vh}.ws.focus .list{display:none}.ws:not(.focus) .detail{display:none}
|
||||
.dhead{padding:12px 16px}.dhead .code{flex:1 1 100%;word-break:break-all}.dbody{padding:12px 16px}
|
||||
.dest .rw{grid-template-columns:1fr}.dest .rw .r{text-align:left}#addRow{grid-template-columns:1fr}.tiles{grid-template-columns:repeat(2,minmax(0,1fr))}.kv{grid-template-columns:minmax(0,1fr) 50px 50px}}
|
||||
/* Banner Spin builder (2026-10-18) */
|
||||
.vsw{display:flex;gap:4px;padding:10px 16px 0;border-bottom:1px solid var(--line);background:var(--panel)}
|
||||
.vsw button{background:transparent;border:1px solid transparent;border-bottom:0;border-radius:8px 8px 0 0;color:var(--muted);font-family:var(--display);font-size:15px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:7px 14px;cursor:pointer;margin-bottom:-1px}
|
||||
.vsw button.on{background:var(--bg,#f6f8fb);border-color:var(--line);color:var(--accent-hi)}
|
||||
.vsw .nw{font-family:var(--mono);font-size:9px;letter-spacing:.06em;color:var(--sig-2);margin-left:4px}
|
||||
.bsr .hd,.bsr .rw{grid-template-columns:minmax(0,2.4fr) 140px 80px 80px 96px 130px}
|
||||
.bsr .rw.edit{grid-template-columns:1fr;background:var(--panel-2)}
|
||||
.bthumb{display:block;max-width:100%;max-height:96px;width:auto;height:auto;border:1px solid var(--line);border-radius:4px;background:repeating-conic-gradient(#eef1f5 0 25%,#fff 0 50%) 50%/12px 12px}
|
||||
.bprev{display:grid;gap:6px;justify-items:start;overflow:auto;max-width:100%}
|
||||
.bprev img{display:block;max-width:100%;height:auto;border:1px dashed var(--line-strong);background:repeating-conic-gradient(#eef1f5 0 25%,#fff 0 50%) 50%/12px 12px}
|
||||
.bframe{border:1px dashed var(--line-strong);display:grid;place-items:center;color:var(--muted);font-family:var(--mono);font-size:11px;max-width:100%;background:var(--panel-2)}
|
||||
.addg{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}
|
||||
.addg .full{grid-column:1/-1}
|
||||
.tgt{display:grid;grid-template-columns:180px minmax(0,1fr);gap:8px;align-items:end}
|
||||
.okm{color:var(--ok);font-size:12px} .wm{color:var(--warn);font-size:12px} .bm{color:var(--bad);font-size:12px}
|
||||
.code-blk{display:grid;gap:6px} .code-blk pre{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--mono);font-size:12px;background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:8px 10px}
|
||||
.code-blk .hd2{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
|
||||
.tierbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;font-size:12.5px}
|
||||
.modes{display:grid;gap:8px} .modes label{display:flex;gap:8px;align-items:flex-start;cursor:pointer} .modes input{margin-top:3px}
|
||||
.bsr .ml{display:none}
|
||||
.st3 .hd,.st3 .rw{grid-template-columns:minmax(0,2fr) 90px 80px 70px 80px 70px}
|
||||
@media (max-width:900px){.bsr .ml{display:inline;color:var(--muted);font-size:11px}.bsr .rw .r{text-align:left}.bsr .hd,.st3 .hd{display:none}.bsr .rw{grid-template-columns:1fr 1fr}.st3 .rw{grid-template-columns:1fr 1fr 1fr}.addg{grid-template-columns:1fr}}
|
||||
@media (max-width:760px){.bsr .rw{grid-template-columns:1fr}.tgt{grid-template-columns:1fr}.vsw{padding:8px 10px 0}.vsw button{padding:6px 10px;font-size:14px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="vsw" id="vsw" role="tablist" aria-label="Link type"><button type="button" class="on" data-v="links" role="tab">Spin links</button><button type="button" data-v="banners" role="tab">Banner Spins<span class="nw">NEW</span></button></div>
|
||||
<div class="ws" id="ws">
|
||||
<div class="list">
|
||||
<div class="hd"><h2 id="listCount">Links</h2><span class="muted mono" id="listSort">by clicks, 7 days</span></div>
|
||||
@@ -127,6 +151,84 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ws" id="bsWs" hidden>
|
||||
<div class="list">
|
||||
<div class="hd"><h2 id="bsCount">Banner Spins</h2><span class="muted mono" id="bsSort">by views, 30 d</span></div>
|
||||
<div class="flt" id="bsTier" style="font-size:12px"></div>
|
||||
<div class="items" id="bsItems"></div>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<div class="empty" id="bsNoSel"><div class="h-disp" style="font-size:18px">Banner Spin</div><div class="muted" id="bsNoSelText">One image address and one click address that rotate up to 25 banners, each with its own target. Put it on your site, a forum signature or a safelist once; change the banners here any time.</div><button class="btn pri" type="button" id="bsNewBtn2">+ New Banner Spin</button></div>
|
||||
<div id="bsSel" hidden>
|
||||
<div class="dhead">
|
||||
<button class="btn sm" type="button" id="bsBack" hidden>← Banner Spins</button>
|
||||
<h2 id="bsName">Banner Spin</h2>
|
||||
<span class="tag plain" id="bsSize"></span>
|
||||
<span class="mono" id="bsLive"></span>
|
||||
<button class="hchip" type="button" id="bsHoursChip" title="Hours this Banner Spin is on">Always on</button>
|
||||
<span class="grow"></span>
|
||||
<button class="btn sm" type="button" id="bsRename">Rename</button>
|
||||
<button class="btn sm" type="button" id="bsPause">Pause</button>
|
||||
<button class="btn sm danger" type="button" id="bsDel">Delete</button>
|
||||
</div>
|
||||
<div class="dbody">
|
||||
<div class="note" id="bsOffNote" hidden></div>
|
||||
<div class="tiles" id="bsTiles"></div>
|
||||
<div class="tabs" id="bsTabs">
|
||||
<button type="button" class="on" data-tab="banners">Banners</button>
|
||||
<button type="button" data-tab="settings">Settings</button>
|
||||
<button type="button" data-tab="code">Get the code</button>
|
||||
<button type="button" data-tab="stats">Stats</button>
|
||||
</div>
|
||||
<div id="bs-banners">
|
||||
<div class="tbl bsr">
|
||||
<div class="hd"><span>Banner and target</span><span>Weight</span><span class="r">Views</span><span class="r">Clicks</span><span>Status</span><span></span></div>
|
||||
<div id="bsRows"></div>
|
||||
<div class="ft" id="bsFoot"></div>
|
||||
</div>
|
||||
<div class="panel" style="margin-top:12px" id="bsAdd">
|
||||
<h2>Add a banner</h2>
|
||||
<div class="addg">
|
||||
<label class="lbl">Upload an image (JPG, PNG or GIF, animated is fine, up to 150 KB)<input class="field" id="bsFile" type="file" accept="image/png,image/jpeg,image/gif"></label>
|
||||
<label class="lbl">Or paste an image address<input class="field mono" id="bsImgUrl" type="url" placeholder="https://"></label>
|
||||
<div class="full bprev" id="bsPrev"></div>
|
||||
<div class="full tgt"><label class="lbl" style="margin:0">A click goes to<select class="field" id="bsTgtKind"><option value="url">A page address</option></select></label><label class="lbl" style="margin:0" id="bsTgtUrlWrap">Page address<input class="field mono" id="bsTgtUrl" type="url" placeholder="https://"></label></div>
|
||||
<label class="lbl">Label (only you see it)<input class="field" id="bsLabel" type="text" maxlength="60" placeholder="Gold offer, blue version"></label>
|
||||
<label class="lbl">Weight, 1 to 100<input class="field mono" id="bsWeight" type="number" min="1" max="100" value="10"></label>
|
||||
</div>
|
||||
<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap"><button class="btn pri" type="button" id="bsAddBtn">Add banner</button><span class="muted" id="bsAddNote" style="font-size:12px"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bs-settings" hidden>
|
||||
<div class="two">
|
||||
<div class="panel"><h2>Rotation</h2><div class="modes" id="bsModes">
|
||||
<label><input type="radio" name="bsMode" value="weight"><span><b>Random by weight</b><br><span class="muted">Every page view picks again. A banner with weight 20 shows twice as often as one with 10.</span></span></label>
|
||||
<label><input type="radio" name="bsMode" value="visitor"><span><b>One per visitor</b><br><span class="muted">Each visitor sees the same banner all day; different visitors get different banners by weight.</span></span></label></div></div>
|
||||
<div class="panel"><h2>Traffic source</h2><label class="lbl" style="margin:0">Network this Banner Spin runs on<select class="field" id="bsSrc"><option value="">None</option></select></label><div class="muted" style="font-size:12px">Conversions from its clicks fire that source's postback. Add the network's click macros to the click address (Get the code shows it).</div></div>
|
||||
</div>
|
||||
<div class="panel" style="margin-top:12px"><h2>Fallback</h2><div class="muted">Used when the Banner Spin is paused, outside its hours, or every banner is paused. A click we cannot match to a banner goes to the fallback page too.</div>
|
||||
<label class="lbl">Fallback page<input class="field mono" id="bsFallback" type="url" placeholder="https://"></label>
|
||||
<div class="addg"><label class="lbl">Fallback banner image (optional), upload<input class="field" id="bsFbFile" type="file" accept="image/png,image/jpeg,image/gif"></label><label class="lbl">or paste an image address<input class="field mono" id="bsFbUrl" type="url" placeholder="https://"></label></div>
|
||||
<div class="bprev" id="bsFbPrev"></div>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn pri" type="button" id="bsFbSave">Save fallback</button><button class="btn" type="button" id="bsFbClear">Remove fallback image</button></div>
|
||||
</div>
|
||||
<div class="panel" style="margin-top:12px"><h2>Hours this Banner Spin is on</h2><div class="muted">Outside these hours every placement shows the fallback banner. Each banner can have its own hours too (the clock button on its row).</div><div id="bsHours"></div></div>
|
||||
</div>
|
||||
<div id="bs-code" hidden>
|
||||
<div class="panel" style="padding:10px 12px"><div style="display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end"><label class="lbl" style="margin:0">Link domain<select class="field" id="bsHost"></select></label><span class="muted mono" id="bsHostNote" style="font-size:11px"></span></div></div>
|
||||
<div id="bsCodes" style="display:grid;gap:10px;margin-top:10px"></div>
|
||||
<div class="note" style="margin-top:10px" id="bsGmail"><b>Using it in email?</b> Gmail fetches an image once through its own image proxy and keeps that copy, so Gmail readers stop seeing the rotation. For email, make a Banner Spin with a single banner and swap that banner when you want a change. Other mail apps load the image fresh on each open.</div>
|
||||
<div class="note" style="margin-top:10px"><b>Paid ad networks</b> copy your image to their own servers when you upload a creative, so it will not rotate there. Use the script tag or the image address on sites, blogs, forums and safelists that load the image from us.</div>
|
||||
</div>
|
||||
<div id="bs-stats" hidden>
|
||||
<div class="panel"><h2>By banner</h2><div class="tbl st3"><div class="hd"><span>Banner</span><span class="r">Views</span><span class="r">Clicks</span><span class="r">CTR</span><span class="r">Matched</span><span class="r">Conv</span></div><div id="bsStB"></div></div></div>
|
||||
<div class="panel" style="margin-top:12px"><h2>By placement (the page the banner sits on)</h2><div class="tbl st3"><div class="hd"><span>Placement</span><span class="r">Views</span><span class="r">Clicks</span><span class="r">CTR</span><span class="r">Matched</span><span></span></div><div id="bsStP"></div></div></div>
|
||||
<div class="panel" style="margin-top:12px"><h2>Views by day, Central time, last 30</h2><div class="bars" id="bsDayBars"></div><div class="axis" id="bsDayAxis"></div><div class="muted" style="font-size:11.5px" id="bsStNote"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dbody" id="pbWrap" style="border-top:1px solid var(--line)">
|
||||
<div class="panel pbpanel">
|
||||
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap"><h2>Postbacks</h2><span class="muted">Tell your tracker or traffic network when a click converts. Fired server to server with the click id that came in on the link.</span><span class="grow"></span><button class="btn sm" type="button" id="pbNew">+ Postback</button></div>
|
||||
@@ -136,6 +238,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261018c"></script>
|
||||
<script src="/assets/links.js?v=20261012a"></script>
|
||||
<script src="/assets/links.js?v=20261018bs"></script>
|
||||
<script src="/assets/banner-spin.js?v=20261018bs"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user