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:
martbost
2026-10-18 10:58:45 -05:00
parent 406113bc03
commit 1d1740c7f9
4 changed files with 646 additions and 4 deletions
+6 -3
View File
@@ -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); });
})();