Control Room: shared shell with in-shell sign-in, Reports, Team and Wallet screens; postback rails (click ids, macros, lsid attribution, conversions, outbound + inbound postbacks with SSRF guards)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-29 15:52:07 -05:00
parent 688d3c4bb5
commit 8e1ddb892f
12 changed files with 652 additions and 138 deletions
+90
View File
@@ -0,0 +1,90 @@
// LinkSpin Control Room shell (2026-09-29): the frame every workspace screen shares.
// Rail + topbar, session check, in-shell sign-in (email code, same endpoints as the dashboard),
// fetch helper, toast, in-page dialogs (never native prompt/confirm). Pages: put content in
// <div id="page">, then CR.mount({active,title,sub,actions}) and CR.requireSession(cb).
window.CR = (function () {
const $ = id => document.getElementById(id);
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const fmt = n => Number(n || 0).toLocaleString();
const NAV = [
['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"/>'],
['zones', 'Zones', '/zones', '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/>'],
['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"/>'],
['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
const FALLBACK = { pages: '/my#promo', zones: '/my#campaigns', team: '/my#line', wallet: '/my#wallet' };
const BUILT = new Set(['links', 'reports', 'team', 'wallet']);
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); }
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 get(path) { const r = await (await fetch(path, { headers: { Accept: 'application/json' } })).json(); if (r.error) throw new Error(r.error); return r; }
function copy(text) { try { navigator.clipboard.writeText(text).then(() => toast('Copied'), () => toast('Select and copy: ' + text)); } catch (e) { toast('Select and copy: ' + text); } }
function dialog(opts) {
return new Promise(resolve => {
let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); }
host.innerHTML = '';
const back = document.createElement('div'); back.className = 'modal-back';
back.innerHTML = '<div class="modal" role="dialog" aria-modal="true"><h2>' + esc(opts.title) + '</h2>' + (opts.text ? '<div class="ink2">' + esc(opts.text) + '</div>' : '') + (opts.html || '')
+ (opts.fields || []).map(f => '<label class="lbl">' + esc(f.label) + (f.type === 'textarea' ? '<textarea class="field' + (f.mono ? ' mono' : '') + '" id="dlg-' + f.k + '" rows="' + (f.rows || 3) + '" placeholder="' + esc(f.placeholder || '') + '">' + esc(f.value || '') + '</textarea>' : '<input class="field' + (f.mono ? ' mono' : '') + '" id="dlg-' + f.k + '" type="' + (f.type || 'text') + '" value="' + esc(f.value || '') + '" placeholder="' + esc(f.placeholder || '') + '"' + (f.max ? ' maxlength="' + f.max + '"' : '') + '>') + '</label>').join('')
+ '<div class="acts"><button class="btn" type="button" id="dlgNo">' + esc(opts.no || 'Cancel') + '</button><button class="btn pri' + (opts.danger ? ' danger' : '') + '" type="button" id="dlgOk">' + esc(opts.ok || 'OK') + '</button></div></div>';
host.appendChild(back);
const done = v => { host.innerHTML = ''; resolve(v); };
back.querySelector('#dlgNo').addEventListener('click', () => done(null));
back.addEventListener('click', e => { if (e.target === back) done(null); });
back.querySelector('#dlgOk').addEventListener('click', () => { const out = {}; (opts.fields || []).forEach(f => { out[f.k] = back.querySelector('#dlg-' + f.k).value; }); done(opts.fields ? out : true); });
const first = back.querySelector('input,textarea'); if (first) { first.focus(); if (first.select) first.select(); }
back.addEventListener('keydown', e => { if (e.key === 'Enter' && e.target.tagName !== 'TEXTAREA') back.querySelector('#dlgOk').click(); if (e.key === 'Escape') done(null); });
});
}
function mount(o) {
const page = $('page'); if (!page) return;
const app = document.createElement('div'); app.className = 'app';
app.innerHTML = '<nav class="rail" aria-label="LinkSpin"><a class="mark" href="/" aria-label="LinkSpin home" title="LinkSpin"></a>'
+ NAV.map(([k, label, href, svg]) => '<a href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === o.active ? ' class="on" aria-current="page"' : '') + ' title="' + label + '" aria-label="' + label + '"><svg viewBox="0 0 24 24">' + svg + '</svg></a>').join('')
+ '<span class="sp"></span><a href="#" id="crUserBtn" title="Account" aria-label="Account"><svg viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/></svg></a></nav>'
+ '<div class="main"><div class="topbar"><h1>' + esc(o.title || '') + '</h1><span class="muted mono" id="crSub">' + esc(o.sub || '') + '</span><span class="grow"></span><span id="crActions">' + (o.actions || '') + '</span></div><div id="crBody"></div></div>';
page.parentNode.insertBefore(app, page); app.querySelector('#crBody').appendChild(page);
$('crUserBtn').addEventListener('click', async e => { e.preventDefault(); if (!ME || !ME.signedIn) return signInFlow(() => location.reload()); const v = await dialog({ title: ME.username ? '@' + ME.username : (ME.email || 'Account'), text: 'Signed in on LinkSpin. Your classic dashboard is still at /my.', ok: 'Sign out', no: 'Close', danger: true }); if (v) { try { await api('/api/auth/logout'); } catch (er) {} location.reload(); } });
}
const sub = t => { const s = $('crSub'); if (s) s.textContent = t; };
async function me(force) { if (ME && !force) return ME; try { ME = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) { ME = { signedIn: false }; } return ME; }
// sign-in inside the shell: email -> six-digit code, on the same endpoints and guards as the dashboard.
const FTS = Date.now();
async function signInFlow(onReady) {
let host = $('crModalHost'); if (!host) { host = document.createElement('div'); host.id = 'crModalHost'; document.body.appendChild(host); }
host.innerHTML = '<div class="modal-back"><div class="modal" role="dialog" aria-modal="true"><h2>Sign in</h2><div class="ink2">Email first. We send a six-digit code; no password to remember. New here? The same box creates your account.</div>'
+ '<label class="lbl">Email<input class="field" id="siEmail" type="email" autocomplete="email" placeholder="you@example.com"></label>'
+ '<div id="siCodeRow" hidden><label class="lbl">Code from the email<input class="field mono" id="siCode" inputmode="numeric" maxlength="6" placeholder="123456"></label></div>'
+ '<div class="muted" id="siMsg"></div><div class="acts"><a class="btn" href="/my">Classic dashboard</a><button class="btn pri" type="button" id="siGo">Send code</button></div></div></div>';
const email = $('siEmail'), code = $('siCode'), go = $('siGo'), msg = $('siMsg'); let stage = 'email';
email.focus();
const say = (t, bad) => { msg.textContent = t; msg.className = bad ? 'bad' : 'muted'; };
async function step() {
try {
if (stage === 'email') {
const e = email.value.trim(); if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)) return say('That email address does not look right.', true);
go.disabled = true; say('Sending…');
// the sign-up guard refuses a form younger than a few seconds (bot defence); wait it out instead of bouncing the person
const wait = FTS + 4500 - Date.now(); if (wait > 0) await new Promise(r => setTimeout(r, wait));
const r = await api('/api/auth/email/start', { email: e, fts: FTS, hp_field_x9: '', pick: null });
go.disabled = false;
if (r.challenge) { say('One more check is needed for this address. Use the classic dashboard sign-in this once.', true); return; }
$('siCodeRow').hidden = false; code.focus(); stage = 'code'; go.textContent = 'Sign in';
if (r.devCode) code.value = r.devCode;
say(r.sent ? 'Code sent. Check your inbox, and spam the first time.' : 'Code filled in (local dev).');
} else {
go.disabled = true; say('Checking…');
await api('/api/auth/email/verify', { email: email.value.trim(), code: code.value.trim() });
host.innerHTML = ''; ME = null; await me(true); toast('You are in'); onReady && onReady(ME);
}
} catch (e) { go.disabled = false; say(e.message, true); }
}
go.addEventListener('click', 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); }
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow };
})();
+52 -45
View File
@@ -1,68 +1,45 @@
// LinkSpin Links workspace (Control Room, first real screen, 2026-09-29). Talks to the existing rotator API:
// GET /api/my/rotations, POST /api/my/rotations, POST /api/my/rotations/:id, POST .../dest, POST .../dest/:did, GET .../stats
// LinkSpin Links workspace (Control Room). Rotator API + postbacks + share kit. Uses the shared shell (cr-shell.js).
(function () {
const $ = id => document.getElementById(id);
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const fmt = n => Number(n || 0).toLocaleString();
let ROT = [], HOSTS = [], SEL = null, STATS = {}, FILTER = '';
let toastT;
function toast(msg, bad) { const t = $('toast'); t.textContent = msg; t.style.background = bad ? '#FF7A7A' : ''; t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 1800); }
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; }
function copy(text) { try { navigator.clipboard.writeText(text).then(() => toast('Copied'), () => toast('Select and copy: ' + text)); } catch (e) { toast('Select and copy: ' + text); } }
// in-page dialogs (never native prompt/confirm)
function dialog(opts) {
return new Promise(resolve => {
const host = $('modalHost'); host.innerHTML = '';
const back = document.createElement('div'); back.className = 'modal-back';
back.innerHTML = '<div class="modal" role="dialog" aria-modal="true"><h2>' + esc(opts.title) + '</h2>' + (opts.text ? '<div class="ink2">' + esc(opts.text) + '</div>' : '')
+ (opts.fields || []).map(f => '<label class="lbl">' + esc(f.label) + '<input class="field' + (f.mono ? ' mono' : '') + '" id="dlg-' + f.k + '" type="' + (f.type || 'text') + '" value="' + esc(f.value || '') + '" placeholder="' + esc(f.placeholder || '') + '"' + (f.max ? ' maxlength="' + f.max + '"' : '') + '></label>').join('')
+ '<div class="acts"><button class="btn" type="button" id="dlgNo">' + esc(opts.no || 'Cancel') + '</button><button class="btn pri' + (opts.danger ? ' danger' : '') + '" type="button" id="dlgOk">' + esc(opts.ok || 'OK') + '</button></div></div>';
host.appendChild(back);
const done = v => { host.innerHTML = ''; resolve(v); };
back.querySelector('#dlgNo').addEventListener('click', () => done(null));
back.addEventListener('click', e => { if (e.target === back) done(null); });
back.querySelector('#dlgOk').addEventListener('click', () => { const out = {}; (opts.fields || []).forEach(f => { out[f.k] = back.querySelector('#dlg-' + f.k).value; }); done(opts.fields ? out : true); });
const first = back.querySelector('input'); if (first) { first.focus(); first.select(); back.addEventListener('keydown', e => { if (e.key === 'Enter') back.querySelector('#dlgOk').click(); if (e.key === 'Escape') done(null); }); }
});
}
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;
CR.mount({ active: 'links', title: 'Links', sub: 'loading', actions: '<button class="btn pri" id="newBtn" type="button">+ New 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' };
async function load(keep) {
let r; try { r = await (await fetch('/api/my/rotations', { headers: { Accept: 'application/json' } })).json(); } catch (e) { r = { error: 'network' }; }
if (r.error) { $('signin').hidden = false; $('ws').hidden = true; $('tbSub').textContent = 'not signed in'; return; }
let r; try { r = await CR.get('/api/my/rotations'); } catch (e) { CR.sub('could not load'); return; }
ROT = (r.rotations || []).slice().sort((a, b) => clicks7(b) - clicks7(a)); HOSTS = r.hosts || [];
$('signin').hidden = true; $('ws').hidden = false;
const tot7 = ROT.reduce((n, x) => n + clicks7(x), 0);
$('tbSub').textContent = ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days';
CR.sub(ROT.length + ' link' + (ROT.length === 1 ? '' : 's') + ' · ' + fmt(tot7) + ' clicks in 7 days');
renderList();
if (keep && SEL != null) { const s = ROT.find(x => x.id === SEL); if (s) return select(s.id, true); }
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; }
else if (SEL == null) select(ROT[0].id, true);
else select(ROT[0].id, true);
}
function renderList() {
const q = FILTER.trim().toLowerCase();
const rows = ROT.filter(x => !q || x.name.toLowerCase().includes(q) || x.code.includes(q));
$('listCount').textContent = ROT.length + ' link' + (ROT.length === 1 ? '' : 's');
$('items').innerHTML = rows.length ? rows.map(x => { const h = health(x); return '<div class="item' + (x.id === SEL ? ' on' : '') + '" data-id="' + x.id + '" role="button" tabindex="0">'
+ '<div><div class="nm">' + esc(x.name) + (h.cls !== 'ok' ? ' <span class="tag ' + h.cls + '">' + h.t + '</span>' : '') + '</div><div class="cd">' + esc((HOSTS[0] || location.host) + '/r/' + x.code) + '</div></div>'
+ '<div><div class="nm">' + esc(x.name) + (h.cls !== 'ok' ? ' <span class="tag ' + h.cls + '">' + h.t + '</span>' : '') + (x.conversions ? ' <span class="tag ok">' + x.conversions + ' conv</span>' : '') + '</div><div class="cd">' + esc((HOSTS[0] || location.host) + '/r/' + x.code) + '</div></div>'
+ '<div class="rt"><span class="n">' + fmt(clicks7(x)) + '</span><span class="muted" style="font-size:10px">7 d</span></div></div>'; }).join('')
: '<div class="empty"><div class="muted">' + (ROT.length ? 'No link matches that filter.' : 'No links yet.') + '</div></div>';
$('items').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(); } }); });
}
async function select(id, quiet) {
SEL = id; const r = ROT.find(x => x.id === id); if (!r) return;
if (String(location.hash.slice(1)) !== String(id)) history.replaceState(null, '', '#' + id);
$('noSel').hidden = true; $('sel').hidden = false; $('ws').classList.add('focus');
$('items').querySelectorAll('.item').forEach(el => el.classList.toggle('on', Number(el.dataset.id) === id));
$('dName').textContent = r.name; $('dUrl').textContent = linkUrl(r);
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 || '';
const bots = r.bots || 0;
$('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(bots)], ['Live destinations', r.destinations.filter(d => d.active).length + ' / ' + r.destinations.length]]
$('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('');
renderDest(r);
renderDest(r); renderShare(r);
if (!quiet) window.scrollTo({ top: 0 });
loadStats(r.id);
}
@@ -80,19 +57,49 @@
$('destRows').querySelectorAll('[data-t]').forEach(b => b.addEventListener('click', async () => { const d = r.destinations.find(q => q.id === Number(b.dataset.t)); try { await api('/api/my/rotations/' + r.id + '/dest/' + d.id, { active: !d.active }); load(true); } catch (e) { toast(e.message, true); } }));
$('destRows').querySelectorAll('[data-x]').forEach(b => b.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this destination?', text: 'Its click history stays in the stats.', ok: 'Remove', danger: true })) return; try { await api('/api/my/rotations/' + r.id + '/dest/' + b.dataset.x, { remove: true }); toast('Removed'); load(true); } catch (e) { toast(e.message, true); } }));
}
function renderShare(r) {
const url = linkUrl(r);
const kit = [
['Short post', 'One link, every page I promote, in turn. Take a look: ' + url],
['Email or Telegram line', 'Here is the link I use for everything: ' + url + ' (it always sends you to the right page).'],
['Tracker-ready link', url + '?clickid={clickid}&s1={source} (replace the braces with your network\'s macros)'],
['Sub-id split test', url + '?s1=email-A and ' + url + '?s1=email-B (each shows up under Sources)'],
];
$('shareKit').innerHTML = kit.map(([t, body], i) => '<div class="panel" style="padding:10px 12px"><div style="display:flex;justify-content:space-between;align-items:center;gap:8px"><b>' + esc(t) + '</b><button class="btn sm" type="button" data-cp="' + i + '">Copy</button></div><div class="mono muted" style="font-size:12px;overflow-wrap:anywhere;margin-top:6px" id="kit-' + i + '">' + esc(body) + '</div></div>').join('');
$('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>';
async function loadStats(id) {
let s = STATS[id]; if (!s) { try { s = await (await fetch('/api/my/rotations/' + id + '/stats')).json(); } catch (e) { s = null; } if (!s || s.error) return; STATS[id] = s; setTimeout(() => { delete STATS[id]; }, 60000); }
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 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('');
const kv = rows => rows.length ? rows.map(x => '<span>' + 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>';
$('srcRows').innerHTML = kv(s.source); $('geoRows').innerHTML = kv(s.country);
$('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 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>';
}
// actions
// postbacks (account level)
async function loadPb() {
try { PB = await CR.get('/api/my/postbacks'); } catch (e) { return; }
$('pbInUrl').textContent = PB.inboundUrl + '?key=' + PB.key + '&lsid={lsid}&event=sale&value=0.00';
const rows = PB.postbacks || [];
$('pbRows').innerHTML = rows.length ? rows.map(p => '<div class="rw"><div><b>' + esc(p.name) + '</b><br><span class="mono muted" style="font-size:11px">' + p.method + ' · sent ' + fmt(p.sent) + (p.lastAt ? ' · last ' + esc(String(p.lastStatus)) : '') + '</span></div><div class="mono" style="font-size:11px;overflow-wrap:anywhere">' + esc(p.url) + '</div><div>' + p.events.map(e => '<span class="tag dim">' + e + '</span>').join(' ') + '</div><div>' + (p.enabled ? '<span class="tag ok">ON</span>' : '<span class="tag warn">OFF' + (p.fails >= 10 ? ' · failed 10x' : '') + '</span>') + '</div><div style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap"><button class="btn sm" type="button" data-test="' + p.id + '">Test</button><button class="btn sm" type="button" data-tog="' + p.id + '">' + (p.enabled ? 'Off' : 'On') + '</button><button class="btn sm" type="button" data-edit="' + p.id + '">Edit</button><button class="btn sm danger" type="button" data-del="' + p.id + '" aria-label="Remove">&times;</button></div></div>').join('')
: '<div class="rw"><span class="muted">No postbacks yet. Add your tracker\'s postback URL and pick which events fire it.</span></div>';
const log = PB.log || []; $('pbFoot').textContent = log.length ? 'last delivery: ' + new Date(log[0].ts).toLocaleString() + ' · ' + log[0].name + ' · ' + log[0].event + ' · ' + (log[0].ok ? 'ok ' + log[0].status : 'failed ' + (log[0].status || log[0].note)) + ' · ' + log.filter(l => l.ok).length + ' of the last ' + log.length + ' succeeded' : 'no deliveries yet';
$('pbRows').querySelectorAll('[data-test]').forEach(b => b.addEventListener('click', async () => { b.disabled = true; try { const r = await api('/api/my/postbacks/' + b.dataset.test, { test: true }); toast(r.ok ? 'Test delivered, HTTP ' + r.status : 'Test failed: ' + (r.status || r.note), !r.ok); } catch (e) { toast(e.message, true); } b.disabled = false; loadPb(); }));
$('pbRows').querySelectorAll('[data-tog]').forEach(b => b.addEventListener('click', async () => { const p = rows.find(x => x.id === b.dataset.tog); try { await api('/api/my/postbacks/' + p.id, { enabled: !p.enabled }); loadPb(); } catch (e) { toast(e.message, true); } }));
$('pbRows').querySelectorAll('[data-del]').forEach(b => b.addEventListener('click', async () => { if (!await dialog({ title: 'Remove this postback?', ok: 'Remove', danger: true })) return; try { await api('/api/my/postbacks/' + b.dataset.del, { remove: true }); loadPb(); } catch (e) { toast(e.message, true); } }));
$('pbRows').querySelectorAll('[data-edit]').forEach(b => b.addEventListener('click', () => pbForm(rows.find(x => x.id === b.dataset.edit))));
}
async function pbForm(p) {
const ev = (PB && PB.events) || ['join', 'wallet', 'purchase', 'external'];
const v = await dialog({ title: p ? 'Edit postback' : 'New postback', text: 'Your tracker or network gives you a postback URL with macros. Paste it; LinkSpin fills the click id it saw on the link.',
fields: [{ k: 'name', label: 'Name', value: p ? p.name : '', placeholder: 'BeMob', max: 60 }, { k: 'url', label: 'URL template', value: p ? p.url : '', placeholder: 'https://tracker.example/postback?cid={clickid}&payout={payout}&txid={txid}', mono: true, type: 'url' }, { k: 'events', label: 'Events, comma separated: ' + ev.join(', '), value: p ? p.events.join(',') : 'join,purchase' }, { k: 'method', label: 'Method, GET or POST', value: p ? p.method : 'GET', max: 4 }], ok: p ? 'Save' : 'Create' });
if (!v) return;
try { if (p) await api('/api/my/postbacks/' + p.id, v); else await api('/api/my/postbacks', v); toast(p ? 'Saved' : 'Postback added'); loadPb(); } catch (e) { toast(e.message, true); }
}
async function newSpin() {
const v = await dialog({ title: 'New spin', text: 'Name it for you, not for visitors. You add the pages next.', fields: [{ k: 'name', label: 'Name', placeholder: 'IAP main invite', max: 80 }, { k: 'url', label: 'First page to send people to (optional)', placeholder: 'https://', mono: true, type: 'url' }], ok: 'Create' });
if (!v || !v.name.trim()) return;
@@ -100,16 +107,16 @@
}
$('newBtn').addEventListener('click', newSpin); $('newBtn2').addEventListener('click', newSpin);
$('filter').addEventListener('input', e => { FILTER = e.target.value; renderList(); });
$('copyBtn').addEventListener('click', () => { const r = ROT.find(x => x.id === SEL); if (r) copy(linkUrl(r)); });
$('copyBtn').addEventListener('click', () => { const r = ROT.find(x => x.id === SEL); if (r) CR.copy(linkUrl(r)); });
$('backBtn').addEventListener('click', () => { $('ws').classList.remove('focus'); });
$('renameBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const v = await dialog({ title: 'Rename', fields: [{ k: 'name', label: 'Name', value: r.name, max: 80 }], ok: 'Save' }); if (!v || !v.name.trim()) return; try { await api('/api/my/rotations/' + r.id, { name: v.name }); load(true); } catch (e) { toast(e.message, true); } });
$('pauseBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; try { await api('/api/my/rotations/' + r.id, { paused: !r.paused }); toast(r.paused ? 'Live again' : 'Paused: visitors go to the fallback'); load(true); } catch (e) { toast(e.message, true); } });
$('delBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; if (!await dialog({ title: 'Delete ' + r.name + '?', text: 'The short link stops working for everyone who has it. This cannot be undone.', ok: 'Delete', danger: true })) return; try { await api('/api/my/rotations/' + r.id, { remove: true }); SEL = null; toast('Deleted'); load(); } catch (e) { toast(e.message, true); } });
$('delBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; if (!await dialog({ title: 'Delete ' + r.name + '?', text: 'The short link stops working for everyone who has it. This cannot be undone.', ok: 'Delete', danger: true })) return; try { await api('/api/my/rotations/' + r.id, { remove: true }); SEL = null; history.replaceState(null, '', location.pathname); toast('Deleted'); load(); } catch (e) { toast(e.message, true); } });
$('addBtn').addEventListener('click', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; const url = $('addUrl').value.trim(); if (!url) { $('addUrl').focus(); return; } try { await api('/api/my/rotations/' + r.id + '/dest', { url, label: $('addLabel').value, weight: $('addWeight').value }); $('addUrl').value = ''; $('addLabel').value = ''; toast('Destination added'); load(true); } catch (e) { toast(e.message, true); } });
$('addUrl').addEventListener('keydown', e => { if (e.key === 'Enter') $('addBtn').click(); });
$('fallback').addEventListener('change', async () => { const r = ROT.find(x => x.id === SEL); if (!r) return; try { await api('/api/my/rotations/' + r.id, { fallback: $('fallback').value.trim() }); toast('Fallback saved'); load(true); } catch (e) { toast(e.message, true); } });
$('tabs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { $('tabs').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); ['dest', 'hours', 'sources', 'report'].forEach(t => { $('tab-' + t).hidden = t !== b.dataset.tab; }); }));
$('tabs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { $('tabs').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); ['dest', 'hours', 'sources', 'report', 'share'].forEach(t => { $('tab-' + t).hidden = t !== b.dataset.tab; }); }));
$('pbNew').addEventListener('click', () => pbForm(null));
$('backBtn').hidden = !window.matchMedia('(max-width:760px)').matches;
load();
setInterval(() => { if (!document.hidden) load(true); }, 60000);
CR.requireSession(() => { load(); loadPb(); setInterval(() => { if (!document.hidden) load(true); }, 60000); });
})();
+27
View File
@@ -0,0 +1,27 @@
// LinkSpin Reports: one view across every link the member owns (rotator.summary via /api/my/reports).
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
let RANGE = 30;
CR.mount({ active: 'reports', title: 'Reports', sub: 'loading', actions: '<div class="range" id="range"><button type="button" data-d="7">7d</button><button type="button" data-d="30" class="on">30d</button><button type="button" data-d="90">90d</button></div>' });
$('range').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { RANGE = Number(b.dataset.d); $('range').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); load(); }));
const kv = (rows, total) => rows && rows.length ? rows.map(x => '<span>' + 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) + (total ? ' <span class="muted">' + Math.round(x.n / total * 100) + '%</span>' : '') + '</span>').join('') : '<span class="muted">nothing yet</span><span></span><span></span>';
async function load() {
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('');
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 style="height:' + Math.round(d.u / dmax * 100) + '%;background:' + (d.u ? 'var(--accent)' : 'var(--line)') + '" 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(' · ');
$('topRows').innerHTML = (s.top || []).length ? s.top.map(x => '<div class="rw"><a href="/links#' + x.id + '" style="text-decoration:none;color:var(--ink)"><b>' + esc(x.name) + '</b><br><span class="mono muted" style="font-size:11px">' + esc(x.code) + '</span></a><span class="r num">' + fmt(x.unique) + '</span><span class="r num">' + fmt(x.hits) + '</span><span class="r num">' + fmt(x.conv) + '</span></div>').join('') : '<div class="rw"><span class="muted">No links yet.</span></div>';
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 UTC · ' + n + '"></i>').join('');
const best = (s.hours || []).map((n, i) => [n, i]).sort((a, b) => b[0] - a[0]).slice(0, 3).filter(x => x[0]).map(x => x[1] + ':00');
$('hourNote').textContent = best.length ? 'Busiest hours (UTC): ' + best.join(', ') + '. Hour rules per link come next.' : 'No clicks yet.';
$('convRows').innerHTML = kv(s.conversions || [], 0);
}
CR.requireSession(load);
})();
+41
View File
@@ -0,0 +1,41 @@
// LinkSpin Team: the line as a working table (dashboard + line + carry APIs from the engine).
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
let D = null, LINE = null, LEVEL = 1, FILTERS = new Set(), ME = null;
CR.mount({ active: 'team', title: 'Team', sub: 'loading' });
const dayStart = () => { const d = new Date(); d.setHours(0, 0, 0, 0); return d.getTime(); };
const ago = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + ' h ago'; const days = Math.floor(d / 86400e3); return days === 1 ? 'yesterday' : days + ' d ago'; };
const pol = wei => { try { return (Number(BigInt(wei || '0') / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } };
function rows() {
const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); let ms = L ? L.members.slice() : [];
const f = { today: m => (m.lastSeen || 0) >= dayStart(), wallet: m => !!m.wallet, nopay: m => !!m.wallet && !m.activated, nowallet: m => !m.wallet };
for (const k of FILTERS) ms = ms.filter(f[k]);
ms.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0));
return ms;
}
function render() {
const ms = rows(); const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); const total = L ? L.members.length : 0;
$('rows').innerHTML = ms.length ? ms.map(m => { const today = (m.lastSeen || 0) >= dayStart();
return '<div class="rw"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $20+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span></div>'
+ '<span class="mono ' + (today ? 'ok' : (m.lastSeen && Date.now() - m.lastSeen > 3 * 86400e3 ? 'warn' : '')) + '" style="font-size:12px">' + (today ? 'today' : ago(m.lastSeen)) + '</span>'
+ '<span class="mono" style="font-size:11px">' + (m.activated ? '<span class="ok">payouts on</span>' : m.wallet ? '<span class="warn">wallet, payouts off</span>' : '<span class="muted">no wallet</span>') + '</span>'
+ '<span class="r num">' + (m.earnedWei && m.earnedWei !== '0' ? '+' + pol(m.earnedWei) + ' POL' : '<span class="muted">0</span>') + '</span>'
+ '<span class="muted" style="font-size:12px">' + (m.sponsor ? 'via ' + esc(m.sponsor) : (m.email ? esc(m.email) : '')) + '</span></div>'; }).join('')
: '<div class="rw"><span class="muted">' + (total ? 'Nobody matches those filters.' : 'Nobody on this level yet. Share your link, or put it in a spin.') + '</span></div>';
$('foot').textContent = 'level ' + LEVEL + ' · ' + ms.length + (ms.length !== total ? ' of ' + total : '') + ' · surf earnings and full activity are in the classic dashboard for now';
}
async function load() {
try { [D, LINE, ME] = await Promise.all([CR.get('/api/my/dashboard'), CR.get('/api/my/line'), CR.me()]); } catch (e) { CR.sub('could not load'); return; }
const counts = (LINE.counts || []); const refs = D.referrals || [];
CR.sub((counts[0] || 0) + ' direct' + (counts[0] === 1 ? '' : 's') + ' · ' + ((counts[1] || 0) + (counts[2] || 0)) + ' deeper');
$('tiles').innerHTML = [['Directs', fmt(counts[0] || 0), refs.filter(r => r.activated).length + ' with payouts on'], ['Levels 2 and 3', fmt((counts[1] || 0) + (counts[2] || 0)), (counts[1] || 0) + ' · ' + (counts[2] || 0)], ['Qualifying buyers', fmt(D.buyerCount || 0), (D.buyerCount || 0) >= 5 ? 'level 3 open' : (D.buyerCount || 0) >= 2 ? 'level 2 open' : 'level 2 at 2 buyers'], ['Paid by the line', pol(D.earnedWei || '0') + ' POL', (D.earnCount || 0) + ' payouts']]
.map(([k, v, n], i) => '<div class="tile' + (i === 3 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span><span class="muted mono" style="font-size:11px">' + n + '</span></div>').join('');
const inv = 'https://' + location.host + '/join/' + (ME.username || ME.refCode || ME.memberId || ''); $('invite').textContent = inv; $('copyInvite').onclick = () => CR.copy(inv);
$('sponsor').innerHTML = ME.sponsorName ? '<b>' + esc(ME.sponsorName) + '</b>' + (ME.sponsorId ? ' <span class="mono muted">#' + ME.sponsorId + '</span>' : '') + '<div class="muted">Carried over from the network where you first joined. Nothing to set up, nothing anyone can change.</div>' : (ME.sponsorId ? '<b>member #' + ME.sponsorId + '</b>' : '<span class="muted">Not set. Your first purchase locks a sponsor.</span>');
try { const c = await CR.get('/api/my/carry'); const cl = (c.claims || []).filter(x => x.sponsor === (ME.email || '').toLowerCase()); if (cl.length) { $('claimPanel').hidden = false; $('claims').innerHTML = cl.length + ' of your people can use every tool now; their first purchase waits up to ' + (c.claimDays || 3) + ' days for you to link a wallet and switch on payouts, then walks up your line.'; } } catch (e) {}
render();
}
document.querySelectorAll('.lvl [data-l]').forEach(b => b.addEventListener('click', () => { LEVEL = Number(b.dataset.l); document.querySelectorAll('.lvl [data-l]').forEach(x => x.classList.toggle('on', x === b)); render(); }));
$('chips').querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (FILTERS.has(k)) FILTERS.delete(k); else FILTERS.add(k); b.classList.toggle('on', FILTERS.has(k)); render(); }));
CR.requireSession(load);
})();
+25
View File
@@ -0,0 +1,25 @@
// LinkSpin Wallet: paid-to-this-wallet, credits, positions, payout history (engine APIs). Connect/buy stay on /my#wallet for now.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt;
CR.mount({ active: 'wallet', title: 'Wallet', sub: 'loading' });
const pol = wei => { try { return (Number(BigInt(wei || '0') / 10000000000000000n) / 100).toFixed(2); } catch (e) { return '0.00'; } };
async function load() {
let D, ME, POS = [], E = null;
try { [D, ME] = await Promise.all([CR.get('/api/my/dashboard'), CR.me()]); } catch (e) { CR.sub('could not load'); return; }
try { POS = await CR.get('/api/my/positions'); } catch (e) {}
try { E = await CR.get('/api/my/activity'); } catch (e) {}
const addr = ME.address || ''; const on = !!ME.memberId;
CR.sub(addr ? addr.slice(0, 6) + '…' + addr.slice(-4) + (on ? ' · payouts on' : ' · payouts off') : 'no wallet linked');
$('tiles').innerHTML = [['Paid to this wallet', pol(D.earnedWei || '0') + ' POL', (D.earnCount || 0) + ' transactions'], ['Credits', fmt((D.credits || 0) + (D.earnedCredits || 0)), fmt(D.credits || 0) + ' purchased · ' + fmt(D.earnedCredits || 0) + ' earned'], ['In campaigns', fmt(D.inCampaigns || 0), 'reserved by live campaigns'], ['Qualifying buyers', fmt(D.buyerCount || 0), (D.buyerCount || 0) >= 5 ? 'level 3 open' : (D.buyerCount || 0) >= 2 ? 'level 2 open' : 'level 2 at 2 buyers']]
.map(([k, v, n], i) => '<div class="tile' + (i === 0 ? ' hi' : '') + '"><span class="k">' + k + '</span><span class="v">' + v + '</span><span class="muted mono" style="font-size:11px">' + n + '</span></div>').join('');
$('walletBox').innerHTML = addr ? '<div class="code" style="display:block">' + esc(addr) + '</div><div style="margin-top:8px">' + (on ? '<span class="ok"><span class="dot"></span>PAYOUTS ON · member #' + ME.memberId + '</span>' : '<span class="warn"><span class="dot"></span>WALLET LINKED · PAYOUTS OFF</span><div class="muted" style="margin-top:4px">Switch payouts on so the people you bring pay you from their first purchase.</div>') + '</div>' : '<span class="warn">No wallet linked yet.</span><div class="muted" style="margin-top:4px">Link one to be paid. Your email account keeps working either way.</div>';
const pays = E && Array.isArray(E.earnings) ? E.earnings : [];
$('payRows').innerHTML = pays.length ? pays.slice(0, 25).map(x => '<div class="rw"><span class="mono muted" style="font-size:12px">' + new Date((x.ts || 0) * (x.ts > 1e12 ? 1 : 1000)).toLocaleString() + '</span><span><b>' + esc(x.buyerName || x.fromName || (x.buyerId ? 'member #' + x.buyerId : x.type === 'AwardPaid' ? 'award' : 'member')) + '</b></span><span class="mono">' + (x.tier ? 'L' + x.tier + ' · ' + (x.tier === 1 ? '50%' : x.tier === 2 ? '20%' : '10%') : (x.type === 'AwardPaid' ? 'award' : '')) + '</span><span class="mono">' + (x.priceCents ? '$' + (x.priceCents / 100) : '') + '</span><span class="r num ok">+' + pol(x.amountWei || '0') + ' POL</span>' + (x.tx ? '<a class="mono" style="font-size:11px" href="/tx/' + esc(x.tx) + '" target="_blank" rel="noopener">' + esc(String(x.tx).slice(0, 10)) + '…</a>' : '<span></span>') + '</div>').join('')
: '<div class="rw"><span class="muted">No payouts yet. They appear here the moment someone in your line buys.</span></div>';
$('payFoot').textContent = 'every line is a Polygon transaction · nothing is held by the site';
const rows = Array.isArray(POS) ? POS : (POS && (POS.positions || POS.list)) || [];
$('posRows').innerHTML = rows.length ? rows.map(p => '<div class="rw"><span><b>' + (p.main ? 'Main position' : 'Position') + '</b> <span class="mono muted">' + (p.memberId ? '#' + p.memberId : 'not on chain yet') + '</span><br><span class="mono muted" style="font-size:11px">' + esc(String(p.address || '').slice(0, 10)) + '…</span></span><span class="num">' + fmt(p.avail || 0) + '</span><span>' + (p.memberId ? '<span class="tag ok">ACTIVE</span>' : '<span class="tag dim">PENDING</span>') + '</span></div>').join('')
: '<div class="rw"><span class="muted">' + (addr ? 'Main wallet only.' : 'No positions yet.') + '</span></div>';
}
CR.requireSession(load);
})();
+69 -82
View File
@@ -6,9 +6,9 @@
<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=20260929a">
<link rel="stylesheet" href="/assets/cr.css?v=20260929b">
<style>
.ws{display:grid;grid-template-columns:320px minmax(0,1fr);flex:1;min-height:0}
.ws{display:grid;grid-template-columns:320px minmax(0,1fr);min-height:calc(100vh - 53px)}
.list{border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0}
.list .hd{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line)}
.list .hd h2{font-family:var(--display);font-size:20px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;margin:0}
@@ -27,103 +27,90 @@
.empty{padding:40px 24px;color:var(--muted);text-align:center;display:grid;gap:10px;justify-items:center}
.two{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:16px}
.kv{display:grid;grid-template-columns:minmax(0,1fr) 60px 60px;gap:8px;font-size:12px;align-items:center}
@media (max-width:900px){.two{grid-template-columns:1fr}.dest .hd{display:none}.dest .rw{grid-template-columns:1fr 1fr}}
.pb .hd,.pb .rw{grid-template-columns:minmax(0,1.2fr) minmax(0,2fr) 120px 90px 110px}
@media (max-width:900px){.two{grid-template-columns:1fr}.dest .hd{display:none}.dest .rw{grid-template-columns:1fr 1fr}.pb .hd{display:none}.pb .rw{grid-template-columns:1fr}}
@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}}
</style>
</head>
<body>
<div class="app">
<nav class="rail" aria-label="LinkSpin">
<div class="mark" aria-hidden="true"></div>
<a href="/links" class="on" title="Links" aria-label="Links"><svg viewBox="0 0 24 24"><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"/></svg></a>
<a href="/my#promo" title="Pages" aria-label="Pages"><svg viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="2"/><path d="M8 9h8M8 13h6"/></svg></a>
<a href="/my#campaigns" title="Zones" aria-label="Zones"><svg viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/></svg></a>
<a href="/my#earnings" title="Reports" aria-label="Reports"><svg viewBox="0 0 24 24"><path d="M4 19V9M10 19V5M16 19v-8M22 19H2"/></svg></a>
<a href="/my#line" title="Team" aria-label="Team"><svg viewBox="0 0 24 24"><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"/></svg></a>
<a href="/my#wallet" title="Wallet" aria-label="Wallet"><svg viewBox="0 0 24 24"><rect x="3" y="6" width="18" height="12" rx="2"/><path d="M16 12h3"/></svg></a>
<span class="sp"></span>
</nav>
<div class="main">
<div class="topbar">
<h1>Links</h1>
<span class="muted mono" id="tbSub">loading</span>
<span class="grow"></span>
<button class="btn pri" id="newBtn" type="button">+ New spin</button>
<div id="page">
<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>
<div class="flt"><input class="field" id="filter" type="search" placeholder="Filter links" aria-label="Filter links"></div>
<div class="items" id="items"></div>
</div>
<div id="signin" class="empty" hidden>
<div class="h-disp" style="font-size:18px">Sign in to see your links</div>
<div class="muted">Your links, destinations and numbers live on your account.</div>
<a class="btn pri" href="/my?next=/links">Sign in</a>
</div>
<div class="ws" id="ws" hidden>
<div class="list">
<div class="hd"><h2 id="listCount">Links</h2><span class="muted mono" id="listSort">by clicks, 7 days</span></div>
<div class="flt"><input class="field" id="filter" type="search" placeholder="Filter links" aria-label="Filter links"></div>
<div class="items" id="items"></div>
</div>
<div class="detail" id="detail">
<div class="empty" id="noSel"><div class="h-disp" style="font-size:18px">Pick a link</div><div class="muted">Or make your first one. Paste the pages you promote, get one short link that spins them.</div><button class="btn pri" type="button" id="newBtn2">+ New spin</button></div>
<div id="sel" hidden>
<div class="dhead">
<button class="btn sm" type="button" id="backBtn" hidden>&larr; Links</button>
<h2 id="dName">Link</h2>
<span class="code" id="dUrl"></span>
<button class="btn sm" type="button" id="copyBtn">Copy</button>
<span class="mono" id="dLive"></span>
<span class="grow"></span>
<button class="btn sm" type="button" id="renameBtn">Rename</button>
<button class="btn sm" type="button" id="pauseBtn">Pause</button>
<button class="btn sm danger" type="button" id="delBtn">Delete</button>
<div class="detail" id="detail">
<div class="empty" id="noSel"><div class="h-disp" style="font-size:18px">Pick a link</div><div class="muted">Or make your first one. Paste the pages you promote, get one short link that spins them.</div><button class="btn pri" type="button" id="newBtn2">+ New spin</button></div>
<div id="sel" hidden>
<div class="dhead">
<button class="btn sm" type="button" id="backBtn" hidden>&larr; Links</button>
<h2 id="dName">Link</h2>
<span class="code" id="dUrl"></span>
<button class="btn sm" type="button" id="copyBtn">Copy</button>
<span class="mono" id="dLive"></span>
<span class="grow"></span>
<button class="btn sm" type="button" id="renameBtn">Rename</button>
<button class="btn sm" type="button" id="pauseBtn">Pause</button>
<button class="btn sm danger" type="button" id="delBtn">Delete</button>
</div>
<div class="dbody">
<div class="tiles" id="tiles"></div>
<div class="tabs" id="tabs">
<button type="button" class="on" data-tab="dest">Destinations</button>
<button type="button" data-tab="hours">Hours</button>
<button type="button" data-tab="sources">Sources</button>
<button type="button" data-tab="report">Report</button>
<button type="button" data-tab="share">Share kit</button>
</div>
<div class="dbody">
<div class="tiles" id="tiles"></div>
<div class="tabs" id="tabs">
<button type="button" class="on" data-tab="dest">Destinations</button>
<button type="button" data-tab="hours">Hours</button>
<button type="button" data-tab="sources">Sources</button>
<button type="button" data-tab="report">Report</button>
<div id="tab-dest">
<div class="tbl dest">
<div class="hd"><span>Destination</span><span>Weight</span><span class="r">Clicks</span><span class="r">Unique</span><span>Status</span><span></span></div>
<div id="destRows"></div>
<div class="ft" id="destFoot"></div>
</div>
<div id="tab-dest">
<div class="tbl dest">
<div class="hd"><span>Destination</span><span>Weight</span><span class="r">Clicks</span><span class="r">Unique</span><span>Status</span><span></span></div>
<div id="destRows"></div>
<div class="ft" id="destFoot"></div>
</div>
<div class="panel" style="margin-top:12px">
<h2>Add a destination</h2>
<div style="display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) 90px auto;gap:8px;align-items:end" id="addRow">
<label class="lbl">Page you are sending people to<input class="field mono" id="addUrl" type="url" placeholder="https://"></label>
<label class="lbl">Label<input class="field" id="addLabel" type="text" placeholder="Join page, instant hook" maxlength="60"></label>
<label class="lbl">Weight<input class="field mono" id="addWeight" type="number" min="1" max="100" value="10"></label>
<button class="btn pri" type="button" id="addBtn">Add</button>
</div>
<label class="lbl">Fallback, used when every destination is paused or the link is paused<input class="field mono" id="fallback" type="url" placeholder="https://"></label>
<div class="panel" style="margin-top:12px">
<h2>Add a destination</h2>
<div style="display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) 90px auto;gap:8px;align-items:end" id="addRow">
<label class="lbl">Page you are sending people to<input class="field mono" id="addUrl" type="url" placeholder="https://"></label>
<label class="lbl">Label<input class="field" id="addLabel" type="text" placeholder="Join page, instant hook" maxlength="60"></label>
<label class="lbl">Weight<input class="field mono" id="addWeight" type="number" min="1" max="100" value="10"></label>
<button class="btn pri" type="button" id="addBtn">Add</button>
</div>
<div class="muted">Macros in a destination are filled per visitor: <span class="mono">{clickid} {subid} {s1}…{s5} {source} {country} {device} {lsid}</span>. Example: <span class="mono">https://tracker.example/?cid={clickid}&amp;src={source}</span></div>
<label class="lbl">Fallback, used when every destination is paused or the link is paused<input class="field mono" id="fallback" type="url" placeholder="https://"></label>
</div>
<div id="tab-hours" hidden>
<div class="panel"><h2>Clicks by hour, UTC, all time</h2><div class="bars" id="hourBars" style="grid-template-columns:repeat(24,minmax(0,1fr))"></div><div class="axis"><span>00</span><span>06</span><span>12</span><span>18</span><span>23</span></div><div class="muted">Hour rules (open a destination only at set hours) come in the next pass; this is where they will live.</div></div>
</div>
<div id="tab-sources" hidden>
<div class="two">
<div class="panel"><h2>Sources</h2><div id="srcRows" class="kv"></div></div>
<div class="panel"><h2>Countries · devices</h2><div id="geoRows" class="kv"></div><div id="devRow" class="muted"></div></div>
</div>
</div>
<div id="tab-report" hidden>
<div class="panel"><h2>Clicks by day, last 30</h2><div class="bars" id="dayBars"></div><div class="axis" id="dayAxis"></div></div>
</div>
<div id="tab-hours" hidden>
<div class="panel"><h2>Clicks by hour, UTC, all time</h2><div class="bars" id="hourBars" style="grid-template-columns:repeat(24,minmax(0,1fr))"></div><div class="axis"><span>00</span><span>06</span><span>12</span><span>18</span><span>23</span></div><div class="muted">Hour rules (open a destination only at set hours) come in the next pass; this is where they will live.</div></div>
</div>
<div id="tab-sources" hidden>
<div class="two">
<div class="panel"><h2>Sources</h2><div id="srcRows" class="kv"></div><h2 style="margin-top:8px">Click ids and sub ids seen</h2><div id="subRows" class="kv"></div></div>
<div class="panel"><h2>Countries · devices</h2><div id="geoRows" class="kv"></div><div id="devRow" class="muted"></div><h2 style="margin-top:8px">Conversions</h2><div id="convRows" class="kv"></div></div>
</div>
</div>
<div id="tab-report" hidden>
<div class="panel"><h2>Clicks by day, last 30</h2><div class="bars" id="dayBars"></div><div class="axis" id="dayAxis"></div></div>
</div>
<div id="tab-share" hidden>
<div class="panel"><h2>Share kit</h2><div class="muted">Ready to paste. The link is yours; every click is counted and spun.</div><div id="shareKit" style="display:grid;gap:10px"></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>
<div class="tbl pb"><div class="hd"><span>Name</span><span>URL template</span><span>Events</span><span>Status</span><span></span></div><div id="pbRows"></div><div class="ft" id="pbFoot"></div></div>
<div class="muted">Macros: <span class="mono">{clickid} {subid} {s1}…{s5} {source} {event} {payout} {currency} {txid} {lsid} {code}</span>. Inbound: partners can report a conversion to <span class="code" id="pbInUrl"></span> with your partner key.</div>
</div>
</div>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<div id="modalHost"></div>
<script src="/assets/links.js?v=20260929a"></script>
<script src="/assets/cr-shell.js?v=20260929a"></script>
<script src="/assets/links.js?v=20260929b"></script>
</body>
</html>
+44
View File
@@ -0,0 +1,44 @@
<!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>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=20260929b">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.kv{display:grid;grid-template-columns:minmax(0,1fr) 60px 70px;gap:8px;font-size:12px;align-items:center}
.range{display:flex;border:1px solid var(--line-strong);border-radius:var(--r);overflow:hidden} .range button{background:transparent;border:0;color:var(--muted);font-family:var(--mono);font-size:12px;padding:5px 10px;cursor:pointer} .range button.on{background:var(--accent);color:var(--accent-ink)}
.top .hd,.top .rw{grid-template-columns:minmax(0,1fr) 80px 80px 80px}
@media (max-width:900px){.two,.grid2{grid-template-columns:1fr}.body{padding:12px 16px}}
</style>
</head>
<body>
<div id="page">
<div class="body">
<div class="tiles" id="tiles"></div>
<div class="two">
<div class="panel">
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px"><h2>Unique visitors by day</h2><div style="display:flex;gap:14px;font-size:11px;color:var(--ink-2)"><span><span style="display:inline-block;width:10px;height:10px;background:var(--accent);vertical-align:middle;margin-right:5px"></span>unique</span><span><span style="display:inline-block;width:10px;height:10px;background:var(--line);vertical-align:middle;margin-right:5px"></span>bots</span></div></div>
<div class="bars" id="dayBars" style="height:190px"></div><div class="axis" id="dayAxis"></div>
<div class="grid2" style="margin-top:6px">
<div><div class="sec" style="margin-bottom:6px">By source</div><div class="kv" id="srcRows"></div></div>
<div><div class="sec" style="margin-bottom:6px">By country · device</div><div class="kv" id="geoRows"></div><div class="muted" id="devRow" style="margin-top:6px"></div></div>
</div>
</div>
<div style="display:grid;gap:16px;align-content:start">
<div class="panel"><h2>Top links</h2><div class="tbl top"><div class="hd"><span>Link</span><span class="r">Unique</span><span class="r">Clicks</span><span class="r">Conv.</span></div><div id="topRows"></div></div></div>
<div class="panel"><h2>Your best hours</h2><div class="bars" id="hourBars" style="grid-template-columns:repeat(24,minmax(0,1fr));height:80px"></div><div class="axis"><span>00</span><span>06</span><span>12</span><span>18</span><span>23</span></div><div class="muted" id="hourNote"></div></div>
<div class="panel"><h2>Conversions</h2><div class="kv" id="convRows"></div><div class="muted">Joins, wallets and purchases matched to a click on one of your links, plus anything a partner reported by postback.</div></div>
</div>
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929a"></script>
<script src="/assets/reports.js?v=20260929a"></script>
</body>
</html>
+44
View File
@@ -0,0 +1,44 @@
<!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>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=20260929b">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px}
.line .hd,.line .rw{grid-template-columns:minmax(0,2fr) 110px 130px 110px 110px}
.lvl{display:flex;gap:4px;padding:10px 16px;border-bottom:1px solid var(--line);align-items:center;flex-wrap:wrap}
.lvl button{background:transparent;border:1px solid transparent;border-radius:var(--r);color:var(--muted);font-family:var(--display);font-size:14px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:4px 10px;cursor:pointer}
.lvl button.on{background:var(--bg);border-color:var(--accent);color:var(--accent-hi)}
.chips{display:flex;gap:6px;flex-wrap:wrap} .chip{font-size:11px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:2px 9px;cursor:pointer;background:transparent} .chip.on{border-color:var(--accent);color:var(--ink);background:rgba(59,157,255,.1)}
@media (max-width:900px){.two{grid-template-columns:1fr}.line .hd{display:none}.line .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="two">
<div class="tbl line">
<div class="lvl"><button type="button" class="on" data-l="1">Directs</button><button type="button" data-l="2">Level 2</button><button type="button" data-l="3">Level 3</button><span class="grow"></span><span class="chips" id="chips"><button class="chip" type="button" data-f="today">Active today</button><button class="chip" type="button" data-f="wallet">Wallet linked</button><button class="chip" type="button" data-f="nopay">Wallet, payouts off</button><button class="chip" type="button" data-f="nowallet">No wallet</button></span></div>
<div class="hd"><span>Member</span><span>Last seen</span><span>Wallet</span><span class="r">Paid you</span><span>Came from</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>Your invite link</h2><span class="code" id="invite"></span><div style="display:flex;gap:8px"><button class="btn sm" type="button" id="copyInvite">Copy</button><a class="btn sm" href="/links">Put it in a spin</a></div><div class="muted">Everyone who joins through it becomes part of your line. Payouts lock to you once your payouts are on.</div></div>
<div class="panel"><h2>Your sponsor</h2><div id="sponsor" class="ink2">loading</div></div>
<div class="panel" id="claimPanel" hidden><h2 class="warn">Waiting on a wallet</h2><div id="claims" class="ink2"></div></div>
<div class="panel"><h2>Message your line</h2><div class="muted">One broadcast a day, on-site and email.</div><a class="btn sm" href="/my#line" style="justify-self:start">Write one in the classic dashboard</a></div>
</div>
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929a"></script>
<script src="/assets/team.js?v=20260929a"></script>
</body>
</html>
+37
View File
@@ -0,0 +1,37 @@
<!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>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=20260929b">
<style>
.body{padding:16px 24px;display:grid;gap:16px}
.two{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:16px}
.pay .hd,.pay .rw{grid-template-columns:110px minmax(0,1.4fr) 70px 110px 110px 120px}
.pos .rw{grid-template-columns:minmax(0,1fr) 120px 100px}
@media (max-width:900px){.two{grid-template-columns:1fr}.pay .hd{display:none}.pay .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="two">
<div style="display:grid;gap:16px;align-content:start">
<div class="tbl pay"><div class="hd"><span>When</span><span>From</span><span>Level</span><span>Package</span><span class="r">You got</span><span>Transaction</span></div><div id="payRows"></div><div class="ft" id="payFoot"></div></div>
<div class="tbl pos"><div class="hd" style="grid-template-columns:minmax(0,1fr) 120px 100px"><span>Position</span><span>Credits</span><span>Status</span></div><div id="posRows"></div><div class="ft">linked positions share this account's credits; levels pay on the main position</div></div>
</div>
<div style="display:grid;gap:16px;align-content:start">
<div class="panel"><h2>This wallet</h2><div id="walletBox" class="ink2">loading</div><div style="display:flex;gap:8px;flex-wrap:wrap"><a class="btn sm" href="/my#wallet">Connect, switch on payouts, buy</a></div><div class="muted">Connecting a wallet and buying a package use the wallet screen in the classic dashboard until the on-chain flow moves into this shell.</div></div>
<div class="panel"><h2>How you get paid</h2><div class="ink2">Every package splits in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. Nothing is held by the site, ever. Your sponsor is paid the moment your purchase settles.</div></div>
</div>
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20260929a"></script>
<script src="/assets/wallet-screen.js?v=20260929a"></script>
</body>
</html>