Files
linkspin/public/links.html
T
martbost 97b206f3b5 Dayparting + automatic destination health checks for the rotator
Hours: rotation.hours / destination.hours = null (always on) or 7 strings of 24 chars '1'/'0' (index 0 = Sunday); rotation.tz = IANA zone name or 'visitor' (country -> representative zone, Central when unknown). Outside the link's hours visitors go to the fallback (hit.oh = 1 so stats show it); a destination outside its own hours is skipped by the pick. Presets always/business/evenings/weekends, server-side validation of grid and zone (Intl), "my best hours" = top quarter of weekday-hour cells by uniques over 30 days, unlocks at 200 clicks.

Health (health.js): every 30 min each active destination and the fallback is fetched (10 s timeout, 5 redirects, HEAD then GET, 4 at a time) and classed ok / slow / dead / parked, with frameBlocked noted. Three failing checks in a row pause the destination (never the last live one of a rotation without a fallback); paused ones are re-checked every 6 h and come back after two clean passes only when LinkSpin paused them. Owner gets one on-site inbox notice per pause. POST /api/my/rotations/:id/health = Check now, once a minute.

Links screen: Hours chip + inline 7x24 editor (tap, drag to paint, presets, zone picker, plain-English summary, heat tint), per-destination clock button and chip, health dot + line per row, Check now button, auto-paused note.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 11:21:23 -05:00

142 lines
12 KiB
HTML

<!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>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=20261008a">
<style>
.ws{display:grid;grid-template-columns:320px minmax(0,1fr);min-height:calc(100vh - 94px)}
.dbody .tiles{grid-template-columns:repeat(auto-fit,minmax(128px,1fr))}
.list{border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;background:rgba(255,255,255,.55)}
.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}
.list .flt{padding:8px 16px;border-bottom:1px solid var(--line)}
.list .items{overflow:auto}
.item{display:grid;grid-template-columns:minmax(0,1fr) 64px;gap:8px;padding:11px 16px;border-bottom:1px solid var(--line);border-left:3px solid transparent;cursor:pointer}
.item:hover{background:rgba(31,111,235,.05)} .item.on{background:var(--panel);border-left-color:var(--sig)}
.item .nm{font-weight:700;display:flex;gap:8px;align-items:center;flex-wrap:wrap} .item .cd{font-family:var(--mono);font-size:11px;color:var(--muted)}
.item .rt{display:grid;justify-items:end;gap:3px} .item .rt .n{font-family:var(--mono)}
.detail{display:flex;flex-direction:column;min-width:0}
.dhead{display:flex;align-items:center;gap:14px;padding:12px 24px;border-bottom:1px solid var(--line);background:var(--panel);flex-wrap:wrap}
.dhead h2{font-family:var(--display);font-size:24px;font-weight:700;letter-spacing:.02em;margin:0}
.dbody{padding:16px 24px;display:grid;gap:14px}
.dest .hd,.dest .rw{grid-template-columns:minmax(0,2fr) 150px 80px 80px 110px 130px}
.dest .rw.edit{grid-template-columns:1fr;background:var(--panel-2)}
.dest .dl{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.hdot{display:inline-block;width:9px;height:9px;border-radius:50%;background:var(--line-strong);flex:none;vertical-align:middle}
.hdot.ok{background:var(--ok);box-shadow:0 0 0 2px rgba(14,138,92,.2)} .hdot.warn{background:#D98B0C;box-shadow:0 0 0 2px rgba(217,139,12,.2)} .hdot.bad{background:var(--bad);box-shadow:0 0 0 2px rgba(185,28,28,.2)}
.hchip{display:inline-flex;align-items:center;gap:5px;font-family:var(--mono);font-size:10px;font-weight:700;color:var(--ink-2);border:1px solid var(--line-strong);border-radius:999px;padding:2px 8px;white-space:nowrap;background:#fff;cursor:pointer;letter-spacing:.02em}
.hchip.set{color:var(--sig-2);border-color:rgba(255,106,26,.5);background:var(--sig-soft)}
.he{display:grid;gap:10px}
.he-presets{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.he-tz{display:flex;gap:8px;align-items:center;flex-wrap:wrap} .he-tz select{width:auto;min-width:180px} .he-tz input{width:200px}
.he-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;padding-bottom:6px}
.he-grid{display:grid;grid-template-columns:36px repeat(24,22px);gap:2px;touch-action:pan-x;user-select:none;-webkit-user-select:none;width:max-content}
.he-grid .hl{font-family:var(--mono);font-size:9px;font-weight:700;color:var(--muted);text-align:center;align-self:end;line-height:1}
.he-grid .dlb{font-family:var(--mono);font-size:11px;font-weight:700;color:var(--ink-2);align-self:center;cursor:pointer}
.he-grid .c{width:22px;height:22px;border-radius:3px;background:var(--panel-2);border:1px solid var(--line);cursor:pointer;box-sizing:border-box}
.he-grid .c.heat{background:rgba(31,111,235,var(--heat))}
.he-grid .c.on{background:var(--sig);border-color:var(--sig-2)}
.he-sum{font-weight:700} .he-sum small{font-weight:500;color:var(--muted)}
.he .acts{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.note{border:1px solid rgba(194,65,12,.4);background:var(--warn-soft);color:var(--warn);border-radius:8px;padding:8px 12px;font-size:12px}
.wrow{display:flex;align-items:center;gap:8px} .wrow input{width:56px}
.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}
.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 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 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>
<button class="hchip" type="button" id="hoursChip" title="Hours this link is on">Always on</button>
<span class="grow"></span>
<button class="btn sm" type="button" id="checkBtn" title="Check every destination right now">Check now</button>
<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 id="tab-dest">
<div class="note" id="autoNote" hidden style="margin-bottom:10px"></div>
<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>
<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, the link is paused, or the link is outside its hours<input class="field mono" id="fallback" type="url" placeholder="https://"></label>
<div class="muted mono" id="fallbackHealth" style="font-size:11px"></div>
</div>
</div>
<div id="tab-hours" hidden>
<div class="panel"><h2>Hours this link is on</h2><div class="muted">Outside these hours visitors go to the fallback. Each destination can have its own hours too (the clock button on its row). Tap a cell to flip it, drag to paint, or start from a preset.</div><div id="rotHours"></div></div>
<div class="panel" style="margin-top:12px"><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" id="offNote"></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>
<script src="/assets/cr-shell.js?v=20261008c"></script>
<script src="/assets/links.js?v=20261010a"></script>
</body>
</html>