Tiles get sparklines and delta chips (CR.tile/sparkline/delta): Reports unique + bots by day, Links 7-day clicks, Ads 7-day hourly views; bar charts capped in width, peak highlight only with 3+ days

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-29 19:14:37 -05:00
parent 6091f0b82a
commit 75758bf9ee
12 changed files with 74 additions and 26 deletions
+3 -3
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Ads · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
@@ -59,7 +59,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/ads-screen.js?v=20260929b"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/ads-screen.js?v=20260929c"></script>
</body>
</html>
+7 -1
View File
@@ -15,7 +15,13 @@
const cs = D.campaigns || []; const live = cs.filter(c => c.status === 'active');
const views = cs.reduce((n, c) => n + (c.imps || 0) + (c.impsNas || 0), 0);
CR.sub(live.length + ' live · ' + fmt(D.availableCredits) + ' credits available');
$('tiles').innerHTML = [['Credits available', fmt(D.availableCredits)], ['In live campaigns', fmt(D.inCampaigns)], ['Views delivered', fmt(views)], ['Today\'s viewing', EARN.views + ' / ' + EARN.target]].map(([k, v], i) => '<div class="tile' + (i === 0 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
const hours = new Array(24).fill(0); Object.values(D.hours || {}).forEach(a => (a || []).forEach((n, i) => { hours[i] += Number(n) || 0; })); // last 7 days by UTC hour, all campaigns
const week = hours.reduce((a, b) => a + b, 0);
$('tiles').innerHTML = [
CR.tile({ k: 'Credits available', v: fmt(D.availableCredits), hi: true, note: D.earnedCredits ? fmt(D.earnedCredits) + ' earned free to spend' : '' }),
CR.tile({ k: 'In live campaigns', v: fmt(D.inCampaigns), note: live.length + ' live ad' + (live.length === 1 ? '' : 's') }),
CR.tile({ k: 'Views delivered', v: fmt(views), series: week ? hours : null, note: week ? fmt(week) + ' in 7 days, by hour' : '' }),
CR.tile({ k: 'Today\'s viewing', v: EARN.views + ' / ' + EARN.target, note: EARN.streakDay > 1 ? 'streak day ' + EARN.streakDay : '' })].join('');
const r = D.rates || {};
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views, ' + r.loginCreditsPerDay + ' per day for the login spot. Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
const st = c => c.scheduled ? '<span class="tag">Scheduled</span>' : c.status === 'active' ? '<span class="tag ok">Live</span>' : c.status === 'paused' ? '<span class="tag warn">Paused</span>' : c.status === 'out' ? '<span class="tag warn">Out of credits</span>' : c.status === 'done' ? '<span class="tag">Ended</span>' : '<span class="tag">' + esc(c.status) + '</span>';
+19 -1
View File
@@ -116,5 +116,23 @@ window.CR = (function () {
});
}
async function requireSession(onReady) { const m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); await loginAd(); onReady(r); }); }
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow };
// tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first
function sparkline(series) {
const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return '';
const W = 74, H = 26, max = Math.max(...s), min = Math.min(...s);
const pts = s.map((v, i) => [(i / (s.length - 1)) * W, H - 2 - ((v - min) / ((max - min) || 1)) * (H - 4)]);
const line = pts.map(p => p[0].toFixed(1) + ',' + p[1].toFixed(1)).join(' ');
return '<svg class="sparkline" viewBox="0 0 74 26" aria-hidden="true"><polygon class="fill" points="0,26 ' + line + ' 74,26"/><polyline points="' + line + '"/></svg>';
}
function delta(now, before, label) {
now = Number(now) || 0; before = Number(before) || 0; if (!before && !now) return null;
if (!before) return { text: 'new' + (label ? ' ' + label : ''), cls: 'flat' };
const pct = Math.round((now - before) / before * 100);
return { text: (pct > 0 ? '+' : '') + pct + '%' + (label ? ' ' + label : ''), cls: pct > 0 ? '' : pct < 0 ? 'down' : 'flat' };
}
function tile(o) {
return '<div class="tile' + (o.hi ? ' hi' : '') + '"><span class="k">' + esc(o.k) + '</span><div class="row"><span class="v">' + o.v + (o.unit ? '<small>' + esc(o.unit) + '</small>' : '') + '</span>' + sparkline(o.series) + '</div>'
+ (o.delta ? '<span class="delta' + (o.delta.cls ? ' ' + o.delta.cls : '') + '">' + esc(o.delta.text) + '</span>' : '') + (o.note ? '<span class="muted mono" style="font-size:11px">' + esc(o.note) + '</span>' : '') + '</div>';
}
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta };
})();
+2 -1
View File
@@ -86,6 +86,7 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
.tile .k{display:flex;align-items:center;gap:8px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}
.tile .k::before{content:"";width:6px;height:6px;border-radius:1px;background:var(--accent);flex:none}
.tile .v{font-family:var(--display);font-weight:700;font-size:30px;line-height:1.05;letter-spacing:.02em;font-variant-numeric:tabular-nums;color:var(--ink)}
.tile .row{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;min-width:0}
.tile .v small{font-family:var(--mono);font-size:12px;font-weight:500;color:var(--muted);margin-left:4px;letter-spacing:0}
.tile.hi{background:linear-gradient(180deg,#FFFFFF,#EEF4FE)} .tile.hi::before,.tile.hi::after{border-color:var(--sig)} .tile.hi .k::before{background:var(--sig)} .tile.hi .v{color:var(--accent-hi)}
.tile .delta{justify-self:start;font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:.04em;color:var(--ok);background:var(--ok-soft);border-radius:4px;padding:2px 6px;margin-top:2px}
@@ -137,7 +138,7 @@ label.lbl{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.
/* tiny charts: gradient bars, glow on the peak */
.bars{display:grid;gap:3px;align-items:end;height:120px;border-bottom:1px solid var(--line-strong);background:repeating-linear-gradient(180deg,transparent 0 29px,rgba(31,111,235,.08) 29px 30px)}
.bars i{display:block;background:linear-gradient(180deg,var(--accent),var(--accent-hi));min-height:1px;border-radius:2px 2px 0 0}
.bars i{display:block;width:100%;max-width:56px;justify-self:center;background:linear-gradient(180deg,var(--accent),var(--accent-hi));min-height:1px;border-radius:2px 2px 0 0}
.bars i.dim{background:linear-gradient(180deg,var(--accent-dim),#A9CBFA)}
.bars i.hi{background:linear-gradient(180deg,#FF8A48,var(--sig));box-shadow:0 -4px 12px -4px rgba(255,106,26,.6)}
.axis{display:flex;justify-content:space-between;font-family:var(--mono);font-size:10px;color:var(--muted)}
+16 -3
View File
@@ -37,8 +37,7 @@
const h = health(r); $('dLive').innerHTML = '<span class="' + h.cls + '"><span class="dot"></span>' + h.t + '</span>';
$('pauseBtn').textContent = r.paused ? 'Resume' : 'Pause';
$('fallback').value = r.fallback || '';
$('tiles').innerHTML = [['Served, 7 d', fmt(r.hits7 || 0)], ['Unique, all time', fmt(r.uniques || 0)], ['Clicks, all time', fmt(r.hits || 0)], ['Bots dropped', fmt(r.bots || 0)], ['Conversions', fmt(r.conversions || 0)], ['Live destinations', r.destinations.filter(d => d.active).length + ' / ' + r.destinations.length]]
.map(([k, v], i) => '<div class="tile' + (i === 0 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span></div>').join('');
renderTiles(r, STATS[id]);
renderDest(r); renderShare(r);
if (!quiet) window.scrollTo({ top: 0 });
loadStats(r.id);
@@ -69,15 +68,29 @@
$('shareKit').querySelectorAll('[data-cp]').forEach(b => b.addEventListener('click', () => CR.copy($('kit-' + b.dataset.cp).textContent)));
}
const kv = rows => rows && rows.length ? rows.map(x => '<span style="overflow-wrap:anywhere">' + esc(x.k) + '</span><span class="bar"><i style="width:' + Math.round(x.n / (rows[0].n || 1) * 100) + '%"></i></span><span class="r num">' + fmt(x.n) + '</span>').join('') : '<span class="muted">nothing yet</span><span></span><span></span>';
function renderTiles(r, s) {
let series = null, delta = null;
if (s && s.days) { // per-day clicks: last 7 days as the sparkline, delta against the 7 before
const by = {}; s.days.forEach(d => { by[d.day] = d.n; }); const day = i => new Date(Date.now() - i * 86400000).toISOString().slice(0, 10);
series = []; for (let i = 6; i >= 0; i--) series.push(by[day(i)] || 0);
let prior = 0; for (let i = 13; i >= 7; i--) prior += by[day(i)] || 0;
delta = CR.delta(series.reduce((a, b) => a + b, 0), prior, 'vs prior 7 d');
}
$('tiles').innerHTML = [
CR.tile({ k: 'Served, 7 d', v: fmt(r.hits7 || 0), hi: true, series, delta }),
CR.tile({ k: 'Unique, all time', v: fmt(r.uniques || 0) }), CR.tile({ k: 'Clicks, all time', v: fmt(r.hits || 0) }), CR.tile({ k: 'Bots dropped', v: fmt(r.bots || 0) }),
CR.tile({ k: 'Conversions', v: fmt(r.conversions || 0) }), CR.tile({ k: 'Live destinations', v: r.destinations.filter(d => d.active).length + ' / ' + r.destinations.length })].join('');
}
async function loadStats(id) {
let s = STATS[id]; if (!s) { try { s = await CR.get('/api/my/rotations/' + id + '/stats'); } catch (e) { return; } STATS[id] = s; setTimeout(() => { delete STATS[id]; }, 60000); }
if (SEL !== id) return;
{ const r = ROT.find(x => x.id === id); if (r) renderTiles(r, s); }
const hmax = Math.max(1, ...s.hours); $('hourBars').innerHTML = s.hours.map((n, i) => '<i class="' + (n >= hmax * 0.6 ? '' : 'dim') + '" style="height:' + Math.round(n / hmax * 100) + '%" title="' + i + ':00 · ' + n + '"></i>').join('');
$('srcRows').innerHTML = kv(s.source); $('geoRows').innerHTML = kv(s.country); $('subRows').innerHTML = kv(s.subs); $('convRows').innerHTML = kv(s.conversions);
const dev = s.device || []; const dt = dev.reduce((n, x) => n + x.n, 0) || 1; $('devRow').textContent = dev.length ? dev.map(x => x.k + ' ' + Math.round(x.n / dt * 100) + '%').join(' · ') : '';
const days = s.days || []; const dmax = Math.max(1, ...days.map(d => d.n));
$('dayBars').style.gridTemplateColumns = 'repeat(' + Math.max(1, days.length) + ',minmax(0,1fr))';
$('dayBars').innerHTML = days.length ? days.map(d => '<i class="' + (d.n === dmax ? 'hi' : '') + '" style="height:' + Math.round(d.n / dmax * 100) + '%" title="' + d.day + ' · ' + d.n + '"></i>').join('') : '';
$('dayBars').innerHTML = days.length ? days.map(d => '<i class="' + (days.length >= 3 && d.n === dmax ? 'hi' : '') + '" style="height:' + Math.round(d.n / dmax * 100) + '%" title="' + d.day + ' · ' + d.n + '"></i>').join('') : '';
$('dayAxis').innerHTML = days.length ? '<span>' + days[0].day + '</span><span>' + days[days.length - 1].day + '</span>' : '<span class="muted">no clicks recorded yet</span>';
}
// postbacks (account level)
+13 -3
View File
@@ -9,11 +9,21 @@
let s; try { s = await CR.get('/api/my/reports?days=' + RANGE); } catch (e) { CR.sub('could not load'); return; }
const t = s.totals || {};
CR.sub(RANGE + ' days · ' + fmt(s.links || 0) + ' link' + (s.links === 1 ? '' : 's') + ' · Central time days');
$('tiles').innerHTML = [['Served', fmt(t.served), ''], ['Unique', fmt(t.unique), ''], ['Bots dropped', fmt(t.bots), t.served ? Math.round(t.bots / (t.served + t.bots) * 100) + '% of hits' : ''], ['Joins', fmt(t.joins), t.unique ? (t.joins / t.unique * 100).toFixed(1) + '% of unique' : ''], ['Buyers', fmt(t.purchases), t.joins ? Math.round(t.purchases / t.joins * 100) + '% of joins' : ''], ['Partner conversions', fmt(t.external), '']]
.map(([k, v, n], i) => '<div class="tile' + (i === 4 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span>' + (n ? '<span class="muted mono" style="font-size:11px">' + n + '</span>' : '') + '</div>').join('');
// sparklines: one point per Central day in the range (days without hits are zero); delta = second half of the range vs the first
const dl = s.days || []; const byDay = {}; dl.forEach(d => { byDay[d.day] = d; });
const keys = []; for (let i = RANGE - 1; i >= 0; i--) keys.push(new Date(Date.now() - i * 86400000).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }));
const ser = f => keys.map(k => byDay[k] ? f(byDay[k]) : 0); const half = a => { const m = Math.floor(a.length / 2); return [a.slice(0, m).reduce((x, y) => x + y, 0), a.slice(m).reduce((x, y) => x + y, 0)]; };
const su = ser(d => d.u), sb = ser(d => d.b); const [u0, u1] = half(su), [b0, b1] = half(sb);
$('tiles').innerHTML = [
CR.tile({ k: 'Served', v: fmt(t.served) }),
CR.tile({ k: 'Unique', v: fmt(t.unique), series: su, delta: CR.delta(u1, u0, 'vs prior') }),
CR.tile({ k: 'Bots dropped', v: fmt(t.bots), series: sb, delta: CR.delta(b1, b0, 'vs prior'), note: t.served ? Math.round(t.bots / (t.served + t.bots) * 100) + '% of hits' : '' }),
CR.tile({ k: 'Joins', v: fmt(t.joins), note: t.unique ? (t.joins / t.unique * 100).toFixed(1) + '% of unique' : '' }),
CR.tile({ k: 'Buyers', v: fmt(t.purchases), hi: true, note: t.joins ? Math.round(t.purchases / t.joins * 100) + '% of joins' : '' }),
CR.tile({ k: 'Partner conversions', v: fmt(t.external) })].join('');
const days = s.days || []; const dmax = Math.max(1, ...days.map(d => Math.max(d.u, d.b)));
$('dayBars').style.gridTemplateColumns = 'repeat(' + Math.max(1, days.length) + ',minmax(0,1fr))';
$('dayBars').innerHTML = days.map(d => '<i class="' + (d.u === dmax && d.u ? 'hi' : d.u ? '' : 'dim') + '" style="height:' + Math.round(d.u / dmax * 100) + '%" title="' + d.day + ' · ' + d.u + ' unique, ' + d.b + ' bots"></i>').join('');
$('dayBars').innerHTML = days.map(d => '<i class="' + (days.length >= 3 && d.u === dmax && d.u ? 'hi' : d.u ? '' : 'dim') + '" style="height:' + Math.round(d.u / dmax * 100) + '%" title="' + d.day + ' · ' + d.u + ' unique, ' + d.b + ' bots"></i>').join('');
$('dayAxis').innerHTML = days.length ? '<span>' + days[0].day + '</span><span>' + days[Math.floor(days.length / 2)].day + '</span><span>' + days[days.length - 1].day + '</span>' : '<span class="muted">no clicks yet</span>';
$('srcRows').innerHTML = kv(s.source, t.unique); $('geoRows').innerHTML = kv(s.country, t.unique);
const dev = s.device || []; const dt = dev.reduce((n, x) => n + x.n, 0) || 1; $('devRow').textContent = dev.map(x => x.k + ' ' + Math.round(x.n / dt * 100) + '%').join(' · ');
+3 -3
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Links · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.ws{display:grid;grid-template-columns:320px minmax(0,1fr);min-height:calc(100vh - 94px)}
.dbody .tiles{grid-template-columns:repeat(auto-fit,minmax(128px,1fr))}
@@ -111,7 +111,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/links.js?v=20260929c"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/links.js?v=20260929d"></script>
</body>
</html>
+2 -2
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Pages · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.ws{display:grid;grid-template-columns:minmax(0,1fr) 440px;min-height:calc(100vh - 94px)}
.body{padding:16px 24px;display:grid;gap:14px;align-content:start}
@@ -55,7 +55,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/pages-screen.js?v=20260929a"></script>
</body>
</html>
+3 -3
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Reports · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px}
@@ -38,7 +38,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/reports.js?v=20260929b"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/reports.js?v=20260929c"></script>
</body>
</html>
+2 -2
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Team · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px}
@@ -37,7 +37,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/team.js?v=20260929a"></script>
</body>
</html>
+2 -2
View File
@@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<title>Wallet · 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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
@@ -31,7 +31,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/wallet-screen.js?v=20260929a"></script>
</body>
</html>
+2 -2
View File
@@ -6,7 +6,7 @@
<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=20260929c">
<link rel="stylesheet" href="/assets/cr.css?v=20260929d">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
@@ -28,7 +28,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929c"></script>
<script src="/assets/cr-shell.js?v=20260929d"></script>
<script src="/assets/zones-screen.js?v=20260929a"></script>
</body>
</html>