Ads screen in the Control Room shell: buy banner/text/login ads, delivery across viewer, zones and network, earn viewer; login-ad gate after sign-in; member types limited to the three; welcome credits granted from the shell too
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
|||||||
|
<!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>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=20260929b">
|
||||||
|
<style>
|
||||||
|
.body{padding:16px 24px;display:grid;gap:16px}
|
||||||
|
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
|
||||||
|
.cl .hd,.cl .rw{grid-template-columns:minmax(0,1.4fr) minmax(0,1.4fr) 110px 80px 60px 110px 130px}
|
||||||
|
.cl .rw > *{min-width:0;overflow-wrap:anywhere}
|
||||||
|
.thumb{width:72px;height:36px;object-fit:contain;background:#050912;border:1px solid var(--line);border-radius:4px;display:block}
|
||||||
|
.bar{height:6px;background:var(--line);border-radius:3px;overflow:hidden;margin-top:6px}.bar i{display:block;height:100%;background:var(--accent)}
|
||||||
|
.chips{display:flex;gap:6px;flex-wrap:wrap}.chip{border:1px solid var(--line2);background:transparent;color:var(--ink2);padding:6px 12px;border-radius:999px;font:600 12px Manrope,system-ui;cursor:pointer}.chip.on{border-color:var(--accent);color:var(--accent2);background:rgba(59,157,255,.12)}
|
||||||
|
.lbl{display:grid;gap:4px;font:600 11px Manrope,system-ui;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
|
||||||
|
.field{width:100%;box-sizing:border-box}
|
||||||
|
.prog{height:10px;background:var(--line);border-radius:5px;overflow:hidden}.prog i{display:block;height:100%;background:linear-gradient(90deg,var(--accent),var(--accent2))}
|
||||||
|
#composer[hidden]{display:none}
|
||||||
|
.where{display:grid;gap:8px}.where div{display:flex;gap:10px;align-items:flex-start}.where b{min-width:64px;color:var(--accent2)}
|
||||||
|
@media (max-width:900px){.two{grid-template-columns:1fr}.cl .hd{display:none}.cl .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="panel" id="composer" hidden>
|
||||||
|
<h2 id="cmpTitle">New ad</h2>
|
||||||
|
<div class="chips" id="typeChips"><button class="chip on" type="button" data-t="banner">Banner</button><button class="chip" type="button" data-t="text">Text ad</button><button class="chip" type="button" data-t="login">Login ad</button></div>
|
||||||
|
<div class="muted" id="typeNote"></div>
|
||||||
|
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin-top:12px">
|
||||||
|
<label class="lbl">Name<input class="field" id="fName" maxlength="60" placeholder="Fall promo"></label>
|
||||||
|
<label class="lbl">Budget, credits<input class="field mono" id="fBudget" type="number" min="10" step="1" value="50"></label>
|
||||||
|
<label class="lbl">Daily cap, credits (optional)<input class="field mono" id="fCap" type="number" min="10" step="1" placeholder="none"></label>
|
||||||
|
<label class="lbl">Show to<select class="field" id="fGeo"><option value="">Everyone</option><option value="1">Tier 1 countries</option><option value="1,2">Tier 1 and 2</option></select></label>
|
||||||
|
</div>
|
||||||
|
<div style="display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:12px;margin-top:12px" class="tgt">
|
||||||
|
<label class="lbl">Where the click goes<input class="field mono" id="fTarget" placeholder="https://"></label>
|
||||||
|
<label class="lbl">Or a spin link<select class="field" id="fSpin"><option value="">pick a spin</option></select></label>
|
||||||
|
</div>
|
||||||
|
<div id="bannerFields" style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin-top:12px">
|
||||||
|
<label class="lbl">Size<select class="field" id="fSize"></select></label>
|
||||||
|
<label class="lbl">Image URL<input class="field mono" id="fImage" placeholder="https://"></label>
|
||||||
|
<label class="lbl">Or upload (PNG, JPG, WebP, GIF up to 3 MB)<input class="field" id="fFile" type="file" accept="image/png,image/jpeg,image/webp,image/gif"></label>
|
||||||
|
</div>
|
||||||
|
<div id="textFields" hidden style="display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:12px;margin-top:12px">
|
||||||
|
<label class="lbl">Headline (60)<input class="field" id="fTitle" maxlength="60"></label>
|
||||||
|
<label class="lbl">One line (140)<input class="field" id="fBody" maxlength="140"></label>
|
||||||
|
</div>
|
||||||
|
<div id="prev" style="margin-top:12px"></div>
|
||||||
|
<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:14px;align-items:center"><button class="btn pri" type="button" id="fGo">Launch</button><button class="btn" type="button" id="fCancel">Cancel</button><span class="muted" id="fCost"></span></div>
|
||||||
|
</div>
|
||||||
|
<div class="two">
|
||||||
|
<div class="tbl cl"><div class="hd"><span>Campaign</span><span>Creative</span><span>Budget</span><span class="r">Views</span><span class="r">Clicks</span><span>Status</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"><h2>Earn credits</h2><div class="prog"><i id="earnBar" style="width:0"></i></div><div class="muted" id="earnLine" style="margin-top:8px">loading</div><div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px"><button class="btn pri" type="button" id="earnNext">View an ad</button><button class="btn" type="button" id="earnClaim" hidden>Claim</button></div><div class="muted" id="earnNote" style="margin-top:8px"></div></div>
|
||||||
|
<div class="panel"><h2>Where your ads run</h2><div class="where ink2"><div><b>Banner</b><span>the ad viewer here, every member zone on outside sites, and the partner network</span></div><div><b>Text</b><span>the ad viewer and the partner network</span></div><div><b>Login</b><span>full screen to every member right after they sign in, one sponsor a day</span></div></div><div class="muted" id="rateLine" style="margin-top:10px"></div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
|
<script src="/assets/ads-screen.js?v=20260929a"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
// LinkSpin Ads screen (2026-09-29): buy banner / text / login ads on the engine's campaign API, watch delivery across the
|
||||||
|
// viewer, member zones and the partner network, and earn credits by viewing. Types are limited to the three Marty chose.
|
||||||
|
(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, EARN = null, TYPE = 'banner', SPINS = [], HOSTS = [], IMG = '';
|
||||||
|
CR.mount({ active: 'ads', title: 'Ads', sub: 'loading', actions: '<button class="btn pri" type="button" id="newBtn">+ New ad</button>' });
|
||||||
|
const NOTE = {
|
||||||
|
banner: 'Runs in the ad viewer, in every member zone on outside sites, and on the partner network. Views are timed on the server. Spends purchased or earned credits.',
|
||||||
|
text: 'A headline and one line. Runs in the ad viewer and on the partner network. Spends purchased or earned credits.',
|
||||||
|
login: 'Your page, full screen, to every member right after they sign in. One sponsor a day, purchased credits only. No creative needed: the page is the ad.'
|
||||||
|
};
|
||||||
|
const host = u => { try { return new URL(u).hostname.replace(/^www\./, ''); } catch (e) { return u; } };
|
||||||
|
async function load() {
|
||||||
|
try { [D, EARN] = await Promise.all([CR.get('/api/my/campaigns'), CR.get('/api/my/earn')]); } catch (e) { CR.sub('could not load'); return; }
|
||||||
|
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 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>';
|
||||||
|
const cr = c => c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page</span>';
|
||||||
|
$('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw"><div><b>' + esc(c.name) + '</b> <span class="tag">' + esc(c.type) + '</span><br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + '</span><div class="bar"><i style="width:' + Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network</span>' : '') + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">'
|
||||||
|
+ (c.status === 'active' ? '<button class="btn sm" type="button" data-pause="' + c.id + '">Pause</button>' : c.status === 'paused' ? '<button class="btn sm" type="button" data-resume="' + c.id + '">Resume</button>' : '')
|
||||||
|
+ (['active', 'paused', 'out'].includes(c.status) ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '') + '</span></div>').join('')
|
||||||
|
: '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or the login spot.</span></div>';
|
||||||
|
if (D.gauntletPending) $('earnNote').insertAdjacentHTML('afterend', '<div class="muted" style="margin-top:8px">Your welcome credits unlock after the short welcome tour on <a href="/my">the classic dashboard</a>.</div>');
|
||||||
|
$('foot').textContent = 'views = timed views in the ad viewer plus member zones; network = the partner ad network · a paused ad keeps its credits · unspent credits return when an ad ends';
|
||||||
|
$('rows').querySelectorAll('[data-pause]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.pause + '/pause')));
|
||||||
|
$('rows').querySelectorAll('[data-resume]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.resume + '/resume')));
|
||||||
|
$('rows').querySelectorAll('[data-top]').forEach(b => b.addEventListener('click', async () => { const v = await dialog({ title: 'Top up #' + b.dataset.top, text: 'Add credits to this ad. You have ' + fmt(D.availableCredits) + ' available.', fields: [{ k: 'credits', label: 'Credits to add', value: '25', mono: true }], ok: 'Add' }); if (!v) return; try { await api('/api/my/campaigns/' + b.dataset.top + '/topup', { credits: Number(v.credits) }); toast('Topped up.'); load(); } catch (e) { toast(e.message, true); } }));
|
||||||
|
earnPaint();
|
||||||
|
}
|
||||||
|
async function act(path) { try { await api(path, {}); load(); } catch (e) { toast(e.message, true); } }
|
||||||
|
// -- earn by viewing: the engine's fraud-guarded flow (server-timed dwell + a human check) runs inside /view/<token>
|
||||||
|
function earnPaint() {
|
||||||
|
const s = EARN; if (!s) return;
|
||||||
|
$('earnBar').style.width = Math.min(100, Math.round(100 * s.views / Math.max(1, s.target))) + '%';
|
||||||
|
const done = s.views >= s.target;
|
||||||
|
$('earnLine').textContent = s.claimed ? 'Claimed for today' + (s.streakDay > 1 ? ' (streak day ' + s.streakDay + ')' : '') + '. Tomorrow pays ' + s.nextClaim + '.' : done ? 'Set complete. Claim your ' + s.claimCredits + ' credits.' : s.views + ' of ' + s.target + ' viewed. Then claim ' + s.claimCredits + ' credits' + (s.streakDay > 1 ? ' (streak day ' + s.streakDay + ')' : '') + '.';
|
||||||
|
$('earnClaim').hidden = !(done && !s.claimed); $('earnNext').hidden = done;
|
||||||
|
$('earnNote').textContent = (s.earnedAvailable != null ? s.earnedAvailable : s.earned) + ' earned credits free to spend' + (s.reserved ? ', ' + s.reserved + ' working in live ads' : '') + '. Each view is a full page, timed on the server, with a quick check at the end.';
|
||||||
|
}
|
||||||
|
async function earnRefresh() { try { EARN = await CR.get('/api/my/earn'); earnPaint(); } catch (e) {} }
|
||||||
|
let vt = 0;
|
||||||
|
$('earnNext').addEventListener('click', async () => {
|
||||||
|
const type = ['banner', 'text'][vt++ % 2]; let r = null;
|
||||||
|
try { r = await CR.get('/api/my/earnview?type=' + type); } catch (e) { toast(e.message, true); return; }
|
||||||
|
if (!r || !r.ad || !r.viewUrl) { toast(r && r.status && r.status.views >= r.status.target ? 'Set complete for today.' : 'No member ads are live right now. Views resume the moment a campaign runs.', true); earnRefresh(); return; }
|
||||||
|
openView(r.viewUrl);
|
||||||
|
});
|
||||||
|
function openView(url) {
|
||||||
|
closeView(); const back = document.createElement('div'); back.id = 'adOverlay'; back.style.cssText = 'position:fixed;inset:0;z-index:100000;background:#050912;display:flex;flex-direction:column';
|
||||||
|
const x = document.createElement('button'); x.type = 'button'; x.setAttribute('aria-label', 'Close ad'); x.textContent = '✕'; x.style.cssText = 'position:absolute;top:10px;right:12px;z-index:2;width:40px;height:40px;border-radius:50%;border:1px solid rgba(255,255,255,.25);background:rgba(6,10,16,.85);color:#fff;font-size:20px;font-weight:700;cursor:pointer'; x.addEventListener('click', closeView);
|
||||||
|
const f = document.createElement('iframe'); f.src = url; f.style.cssText = 'flex:1;width:100%;border:0;background:#050912'; back.appendChild(f); back.appendChild(x); document.body.appendChild(back); document.body.style.overflow = 'hidden';
|
||||||
|
}
|
||||||
|
function closeView() { const m = $('adOverlay'); if (m) m.remove(); document.body.style.overflow = ''; earnRefresh(); }
|
||||||
|
window.addEventListener('message', e => { if (e.origin !== location.origin || !e.data) return; if (e.data.t === 'iap-view-close') closeView(); else if (e.data.t === 'iap-view-done') earnRefresh(); });
|
||||||
|
window.addEventListener('storage', e => { if (e.key === 'iap-view-done') earnRefresh(); });
|
||||||
|
$('earnClaim').addEventListener('click', async () => { try { const r = await api('/api/my/claim', {}); toast('+' + r.credited + ' credits' + (r.streakDay > 1 ? ', streak day ' + r.streakDay : '') + '. Spend them on an ad.'); load(); } catch (e) { toast(e.message, true); } });
|
||||||
|
// -- composer
|
||||||
|
function setType(t) { TYPE = t; document.querySelectorAll('#typeChips .chip').forEach(c => c.classList.toggle('on', c.dataset.t === t)); $('typeNote').textContent = NOTE[t]; $('bannerFields').hidden = t !== 'banner'; $('textFields').hidden = t !== 'text'; $('fCap').parentElement.hidden = t === 'login'; cost(); preview(); }
|
||||||
|
function cost() { const b = Math.floor(Number($('fBudget').value) || 0); const r = D ? D.rates : {}; let s = '';
|
||||||
|
if (TYPE === 'banner') s = 'about ' + fmt(Math.floor(b / (r.bannerCreditsPerBatch || 2) * (r.bannerBatch || 10))) + ' timed views';
|
||||||
|
else if (TYPE === 'text') s = 'about ' + fmt(Math.floor(b / (r.textCreditsPerBatch || 1) * (r.textBatch || 10))) + ' timed views';
|
||||||
|
else s = 'about ' + Math.floor(b / (r.loginCreditsPerDay || 100)) + ' day' + (Math.floor(b / (r.loginCreditsPerDay || 100)) === 1 ? '' : 's') + ' as the login sponsor (' + (r.loginCreditsPerDay || 100) + ' per day)';
|
||||||
|
$('fCost').textContent = b >= 10 ? s : 'minimum 10 credits'; }
|
||||||
|
function preview() { const p = $('prev'); if (TYPE === 'banner' && IMG) { const sz = ($('fSize').value || '728x90').split('x'); p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><img src="' + esc(IMG) + '" alt="" style="max-width:100%;width:' + sz[0] + 'px;height:auto;border:1px solid var(--line);background:#050912">'; }
|
||||||
|
else if (TYPE === 'text') p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><div class="panel" style="max-width:420px"><b>' + esc($('fTitle').value || 'Your headline') + '</b><br><span class="ink2">' + esc($('fBody').value || 'One line under it.') + '</span><br><span class="mono muted" style="font-size:11px">' + esc(host($('fTarget').value || 'yoursite.com')) + '</span></div>';
|
||||||
|
else p.innerHTML = ''; }
|
||||||
|
document.querySelectorAll('#typeChips .chip').forEach(c => c.addEventListener('click', () => setType(c.dataset.t)));
|
||||||
|
['fBudget'].forEach(id => $(id).addEventListener('input', cost));
|
||||||
|
['fTitle', 'fBody', 'fTarget', 'fSize'].forEach(id => $(id).addEventListener('input', preview));
|
||||||
|
$('fImage').addEventListener('input', () => { IMG = $('fImage').value.trim(); preview(); });
|
||||||
|
$('fFile').addEventListener('change', async () => { const f = $('fFile').files[0]; if (!f) return; try { const r = await (await fetch('/api/my/upload', { method: 'POST', headers: { 'Content-Type': f.type }, body: f })).json(); if (r.error) throw new Error(r.error); IMG = location.origin + r.url; $('fImage').value = IMG; toast('Uploaded.'); preview(); } catch (e) { toast(e.message, true); } });
|
||||||
|
$('fSpin').addEventListener('change', () => { const code = $('fSpin').value; if (code) { $('fTarget').value = 'https://' + (HOSTS[0] || location.host) + '/r/' + code; preview(); } });
|
||||||
|
$('newBtn').addEventListener('click', async () => {
|
||||||
|
$('composer').hidden = false; $('composer').scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
if (D && D.bannerSizes && !$('fSize').options.length) $('fSize').innerHTML = D.bannerSizes.map(s => '<option value="' + s.id + '">' + esc(s.label) + '</option>').join('');
|
||||||
|
try { const r = await CR.get('/api/my/rotations'); SPINS = r.rotations || []; HOSTS = r.hosts || []; $('fSpin').innerHTML = '<option value="">pick a spin</option>' + SPINS.filter(s => !s.paused).map(s => '<option value="' + esc(s.code) + '">' + esc(s.name) + ' · /r/' + esc(s.code) + '</option>').join(''); } catch (e) {}
|
||||||
|
setType(TYPE);
|
||||||
|
});
|
||||||
|
$('fCancel').addEventListener('click', () => { $('composer').hidden = true; });
|
||||||
|
$('fGo').addEventListener('click', async () => {
|
||||||
|
const body = { type: TYPE, name: $('fName').value, targetUrl: $('fTarget').value.trim(), budget: Number($('fBudget').value), geo: $('fGeo').value };
|
||||||
|
if (TYPE !== 'login' && $('fCap').value) body.dailyCap = Number($('fCap').value);
|
||||||
|
if (TYPE === 'banner') { body.size = $('fSize').value; body.imageUrl = $('fImage').value.trim(); }
|
||||||
|
if (TYPE === 'text') { body.title = $('fTitle').value; body.body = $('fBody').value; }
|
||||||
|
$('fGo').disabled = true;
|
||||||
|
try { await api('/api/my/campaigns', body); toast('Launched. It is live in rotation now.'); $('composer').hidden = true; $('fName').value = ''; load(); } catch (e) { toast(e.message, true); } finally { $('fGo').disabled = false; }
|
||||||
|
});
|
||||||
|
CR.requireSession(load);
|
||||||
|
})();
|
||||||
@@ -10,13 +10,14 @@ window.CR = (function () {
|
|||||||
['links', 'Links', '/links', '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'],
|
['links', 'Links', '/links', '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>'],
|
||||||
['pages', 'Pages', '/pages', '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M8 9h8M8 13h6"/>'],
|
['pages', 'Pages', '/pages', '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M8 9h8M8 13h6"/>'],
|
||||||
['zones', 'Zones', '/zones', '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/>'],
|
['zones', 'Zones', '/zones', '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/>'],
|
||||||
|
['ads', 'Ads', '/ads', '<path d="M3 11l14-5v12L3 13v-2z"/><path d="M17 8a4 4 0 0 1 0 8"/>'],
|
||||||
['reports', 'Reports', '/reports', '<path d="M4 19V9M10 19V5M16 19v-8M22 19H2"/>'],
|
['reports', 'Reports', '/reports', '<path d="M4 19V9M10 19V5M16 19v-8M22 19H2"/>'],
|
||||||
['team', 'Team', '/team', '<circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 19c0-3 3-5 6-5s6 2 6 5M15 15c3 0 6 1.5 6 4"/>'],
|
['team', 'Team', '/team', '<circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 19c0-3 3-5 6-5s6 2 6 5M15 15c3 0 6 1.5 6 4"/>'],
|
||||||
['wallet', 'Wallet', '/wallet', '<rect x="3" y="6" width="18" height="12" rx="2"/><path d="M16 12h3"/>'],
|
['wallet', 'Wallet', '/wallet', '<rect x="3" y="6" width="18" height="12" rx="2"/><path d="M16 12h3"/>'],
|
||||||
];
|
];
|
||||||
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end
|
// 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 FALLBACK = { pages: '/my#promo', zones: '/my#campaigns', team: '/my#line', wallet: '/my#wallet' };
|
||||||
const BUILT = new Set(['links', 'pages', 'zones', 'reports', 'team', 'wallet']);
|
const BUILT = new Set(['links', 'pages', 'zones', 'ads', 'reports', 'team', 'wallet']);
|
||||||
let ME = null, toastT;
|
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); }
|
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; }
|
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; }
|
||||||
@@ -85,6 +86,26 @@ window.CR = (function () {
|
|||||||
go.addEventListener('click', step);
|
go.addEventListener('click', step);
|
||||||
host.querySelector('.modal').addEventListener('keydown', e => { if (e.key === 'Enter') step(); });
|
host.querySelector('.modal').addEventListener('keydown', e => { if (e.key === 'Enter') step(); });
|
||||||
}
|
}
|
||||||
async function requireSession(onReady) { const m = await me(); if (m && m.signedIn) return onReady(m); signInFlow(onReady); }
|
async function loginAd() {
|
||||||
|
let seen = false; try { seen = !!sessionStorage.getItem('ls.la'); } catch (e) {}
|
||||||
|
if (seen) return; try { sessionStorage.setItem('ls.la', '1'); } catch (e) {}
|
||||||
|
let ad = null; try { ad = (await get('/api/ads/slot?type=login')).ad; } catch (e) { return; }
|
||||||
|
if (!ad || !ad.targetUrl) return;
|
||||||
|
await new Promise(done => {
|
||||||
|
const back = document.createElement('div'); back.className = 'modal-back';
|
||||||
|
back.innerHTML = '<div class="modal" style="max-width:520px"><div class="muted" style="font:600 11px Manrope,system-ui;letter-spacing:.08em;text-transform:uppercase">Today\'s login sponsor</div>'
|
||||||
|
+ '<div style="margin:12px 0;text-align:center">' + (ad.imageUrl ? '<img src="' + esc(ad.imageUrl) + '" alt="" style="max-width:100%;height:auto;border:1px solid var(--line)">' : '<div class="panel" style="padding:22px"><b style="font-size:16px">' + esc(ad.title || 'Visit today\'s sponsor') + '</b></div>') + '</div>'
|
||||||
|
+ '<div class="muted" id="laStatus">Open the ad in a new tab. The timer runs here.</div>'
|
||||||
|
+ '<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;align-items:center"><button class="btn pri" type="button" id="laOpen">Open ad</button><span class="mono" id="laTimer" hidden></span><button class="btn" type="button" id="laGo" hidden>Continue</button></div></div>';
|
||||||
|
document.body.appendChild(back);
|
||||||
|
back.querySelector('#laOpen').addEventListener('click', () => {
|
||||||
|
window.open(ad.targetUrl, '_blank'); back.querySelector('#laOpen').disabled = true;
|
||||||
|
let left = ad.dwell || 10; const t = back.querySelector('#laTimer'); t.hidden = false; t.textContent = left + ' s';
|
||||||
|
const iv = setInterval(() => { left -= 1; if (left > 0) { t.textContent = left + ' s'; return; } clearInterval(iv); t.textContent = 'done'; back.querySelector('#laStatus').textContent = 'Thanks for the look.'; back.querySelector('#laGo').hidden = false; }, 1000);
|
||||||
|
});
|
||||||
|
back.querySelector('#laGo').addEventListener('click', () => { back.remove(); done(); });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function requireSession(onReady) { const m = await me(); if (m && m.signedIn) { await loginAd(); return onReady(m); } signInFlow(async r => { await loginAd(); onReady(r); }); }
|
||||||
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow };
|
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow };
|
||||||
})();
|
})();
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/links.js?v=20260929b"></script>
|
<script src="/assets/links.js?v=20260929b"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/pages-screen.js?v=20260929a"></script>
|
<script src="/assets/pages-screen.js?v=20260929a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/reports.js?v=20260929a"></script>
|
<script src="/assets/reports.js?v=20260929a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/team.js?v=20260929a"></script>
|
<script src="/assets/team.js?v=20260929a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/wallet-screen.js?v=20260929a"></script>
|
<script src="/assets/wallet-screen.js?v=20260929a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/cr-shell.js?v=20260929a"></script>
|
<script src="/assets/cr-shell.js?v=20260929b"></script>
|
||||||
<script src="/assets/zones-screen.js?v=20260929a"></script>
|
<script src="/assets/zones-screen.js?v=20260929a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ const carry = require('./carry'); // sponsor carry-over: engine acti
|
|||||||
const rotator = require('./rotator');
|
const rotator = require('./rotator');
|
||||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29)
|
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29)
|
||||||
const pages = require('./pages'); // member pages: bridge / review / squeeze, served at /p/<slug> (2026-09-29)
|
const pages = require('./pages'); // member pages: bridge / review / squeeze, served at /p/<slug> (2026-09-29)
|
||||||
const zones = require('./zones'); // ad zones on members' own sites (2026-09-29) // the rotator: rotations, weighted destinations, /r/<code>
|
const zones = require('./zones'); // ad zones on members' own sites (2026-09-29)
|
||||||
|
const MEMBER_AD_TYPES = ['banner', 'text', 'login']; // the formats LinkSpin members can buy (video, visits, featured, solo stay off) // the rotator: rotations, weighted destinations, /r/<code>
|
||||||
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
||||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||||
@@ -2623,7 +2624,10 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const s = await auth.fromRequest(req);
|
const s = await auth.fromRequest(req);
|
||||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
const memberId = await auth.refreshMemberId(s);
|
const memberId = await auth.refreshMemberId(s);
|
||||||
const out = { campaigns: await ads.listCampaigns(s.email), rates: ads.rates(), bannerSizes: ads.bannerSizes() };
|
// welcome credits used to unlock only through the classic dashboard; the Control Room Ads screen grants them the same way (2026-09-29)
|
||||||
|
let gauntletPending = false;
|
||||||
|
if (!(await ads.welcomeGranted(s.email))) { const tour = (await uplineSlides(s.email)).filter(a => a.lineTargetUrl); if (!tour.length) await ads.grantWelcome(s.email); else gauntletPending = true; }
|
||||||
|
const out = { campaigns: await ads.listCampaigns(s.email), rates: ads.rates(), bannerSizes: ads.bannerSizes(), gauntletPending };
|
||||||
out.clickSources = await coach.clickSources(out.campaigns.map(c => c.id));
|
out.clickSources = await coach.clickSources(out.campaigns.map(c => c.id));
|
||||||
out.hours = await ads.hoursFor(out.campaigns.map(c => c.id)); // on-site views per UTC hour, last 7 days
|
out.hours = await ads.hoursFor(out.campaigns.map(c => c.id)); // on-site views per UTC hour, last 7 days
|
||||||
out.geo = await ads.geoFor(out.campaigns.map(c => c.id)); // on-site serves per viewer country
|
out.geo = await ads.geoFor(out.campaigns.map(c => c.id)); // on-site serves per viewer country
|
||||||
@@ -2644,6 +2648,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
const memberId = await auth.refreshMemberId(s); // 0 is fine: earned credits fund banner/text
|
const memberId = await auth.refreshMemberId(s); // 0 is fine: earned credits fund banner/text
|
||||||
const b = await readBody(req);
|
const b = await readBody(req);
|
||||||
|
if (!MEMBER_AD_TYPES.includes(String(b.type || ''))) return json(res, 400, { error: 'LinkSpin runs banner, text and login ads.' }); // Marty 2026-09-29: the three formats members buy
|
||||||
if (!['login', 'solo', 'video', 'featured'].includes(String(b.type || ''))) { // banner/text surf views frame the target; login/video/solo/featured open in a new tab or play in our own player
|
if (!['login', 'solo', 'video', 'featured'].includes(String(b.type || ''))) { // banner/text surf views frame the target; login/video/solo/featured open in a new tab or play in our own player
|
||||||
const fc = await frameCheck(b.targetUrl);
|
const fc = await frameCheck(b.targetUrl);
|
||||||
if (!fc.ok) return json(res, 400, { error: fc.reason });
|
if (!fc.ok) return json(res, 400, { error: fc.reason });
|
||||||
@@ -2936,6 +2941,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/reports') return sendFile(res, path.join(PUBLIC_DIR, 'reports.html'));
|
if (p === '/reports') return sendFile(res, path.join(PUBLIC_DIR, 'reports.html'));
|
||||||
if (p === '/pages') return sendFile(res, path.join(PUBLIC_DIR, 'pages.html'));
|
if (p === '/pages') return sendFile(res, path.join(PUBLIC_DIR, 'pages.html'));
|
||||||
if (p === '/zones') return sendFile(res, path.join(PUBLIC_DIR, 'zones.html'));
|
if (p === '/zones') return sendFile(res, path.join(PUBLIC_DIR, 'zones.html'));
|
||||||
|
if (p === '/ads') return sendFile(res, path.join(PUBLIC_DIR, 'ads.html'));
|
||||||
if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html'));
|
if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html'));
|
||||||
if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html'));
|
if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html'));
|
||||||
if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html'));
|
if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html'));
|
||||||
|
|||||||
Reference in New Issue
Block a user