Spooky Doors launch pack (IAP side): door packs + Golden Doors, Promo tools card, season from Oct 4

- Visit packs get a placement: 'all' (as before), 'doors' (Behind Spooky Doors, doorPackCost 4/door) or
  'golden' (Golden Spooky Door, goldenDoorCost 6/door). campaigns.placement column (alterSafe) + JSON store.
- Doors serve golden packs first, then door packs, then the existing chain; each pack at most once per
  player per Central day. Door-only packs never reach the Earn tab, refuels or the PassiveDrip listing
  until rates.sdSeasonEnd ('2026-11-01'); from then on they behave as 'all'.
- Door payloads: credits = per-door price actually charged (3/4/6); Golden Doors add golden: true and
  bonus: goldenBonusCandy (2) to /api/door/open, done, callback and receipt. Gold variant of /door.
- Campaign list: Spooky Doors / Golden Door chip, doors opened + unique players, Buy more doors at the
  door price. Composer: placement choice with live cost. Admin rates labels + house pack placement.
- Promo tools: Spooky Doors card (spookydoors.com/r/<username>, copy, share image, two posts) on the same
  season window as the Games card (seasonState helper).
- Season start moved up to 2026-10-04 (Games card + promo card + chatbot).
- qa/door.mjs covers all of the above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-02 15:55:19 -05:00
parent 9809953ae0
commit a5a991d024
13 changed files with 228 additions and 41 deletions
+35 -14
View File
@@ -1023,11 +1023,13 @@
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>'
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c) + '</td>'
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c)
+ (c.type === 'visits' && (c.placement === 'golden' || c.placement === 'doors') ? ' <span class="badge' + (c.placement === 'golden' ? ' amber' : '') + '" title="' + (c.doorOnly ? 'runs only in Spooky Doors until the season ends, then any doors left run as normal visits' : 'the Spooky Doors season is over, so any doors left run as normal visits') + '">' + (c.placement === 'golden' ? 'Golden Door' : 'Spooky Doors') + '</span>' : '') + '</td>'
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
+ '<td class="num" data-l="Network views">' + (['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>'
+ '<td class="num" data-l="Clicks">' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '<div class="muted small clk-src" title="where the clicks happened">' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => '<span>' + esc(k) + ' ' + v + '</span>').join('') + (c.impsNas ? ' · network: see Network views' : '') + '</div>' : '') + '</td>'
+ (c.type === 'visits' ? '<td class="num" data-l="Spent"><span class="muted small" title="visit packs are paid in full when created; nothing more is charged as visits arrive">paid up front</span></td><td class="num" data-l="Delivered"><b>' + c.imps.toLocaleString() + '</b> of ' + Number(c.body || 0).toLocaleString() + ' visits</td>'
+ (c.type === 'visits' ? '<td class="num" data-l="Spent"><span class="muted small" title="visit packs are paid in full when created; nothing more is charged as visits arrive">paid up front</span></td><td class="num" data-l="Delivered"><b>' + c.imps.toLocaleString() + '</b> of ' + Number(c.body || 0).toLocaleString() + (c.placement === 'golden' || c.placement === 'doors' ? ' doors' : ' visits')
+ (((r.doorStats && r.doorStats[c.id]) || c.placement === 'golden' || c.placement === 'doors') ? (ds => '<div class="muted small" title="Spooky Doors: every door opened on this pack, and how many different players opened one">\u{1F383} ' + ds.doors.toLocaleString() + ' door' + (ds.doors === 1 ? '' : 's') + ' opened \u00b7 ' + ds.players.toLocaleString() + ' player' + (ds.players === 1 ? '' : 's') + '</div>')((r.doorStats && r.doorStats[c.id]) || { doors: 0, players: 0 }) : '') + '</td>'
: c.type === 'featured' ? '<td class="num" data-l="Spent"><span class="muted small" title="featured runs are paid in full when booked (' + (r.rates.featuredPerDay || 40) + ' credits a day); nothing more is charged while the run is live">paid up front</span></td><td class="num" data-l="Run">' + featRun(c) + '</td>'
: '<td class="num" data-l="Spent">' + c.spent + '</td><td class="num" data-l="Budget">' + c.budget + '</td>')
+ '<td data-l="Status">' + (c.status === 'out' ? (c.type === 'visits' ? '<span class="badge">pack delivered</span>' : '<span class="badge amber">budget spent</span>') : c.status === 'done' ? '<span class="muted">' + (c.type === 'featured' ? 'run ended' : 'ended') + '</span>' : c.scheduled ? '<span class="badge">scheduled</span>' : c.status) + '</td>'
@@ -1035,7 +1037,7 @@
: c.status === 'paused' ? '<button class="btn small sec" data-camp="' + c.id + '" data-act="resume">Resume</button>' : '')
+ (['paused', 'out', 'done'].includes(c.status) ? ' <button class="btn small quiet" data-arch="' + c.id + '" data-archname="' + esc(c.name || ('#' + c.id)) + '" data-archleft="' + Math.max(0, (c.budget || 0) - (c.spent || 0)) + '" title="move it out of this list, keep its numbers">Archive</button>' : '')
+ (c.type === 'featured' ? ' <button class="btn small sec" data-extend="' + c.id + '" title="book more days at the daily rate">Extend run</button>'
: c.type === 'visits' ? ' <button class="btn small sec" data-morevisits="' + c.id + '">Buy more visits</button>'
: c.type === 'visits' ? ' <button class="btn small sec" data-morevisits="' + c.id + '" data-vper="' + placeCost(c.doorOnly ? c.placement : 'all', r.rates) + '" data-vdoor="' + (c.doorOnly ? (c.placement === 'golden' ? 'golden' : 'doors') : '') + '">' + (c.doorOnly ? 'Buy more doors' : 'Buy more visits') + '</button>'
: ' <button class="btn small sec" data-topup="' + c.id + '">Buy more views</button>')
+ '</td></tr>').join('') + '</tbody></table>';
el.appendChild(tbl);
@@ -1055,11 +1057,12 @@
} catch (e) { IAP.status(e.message, 'bad'); }
}));
el.querySelectorAll('button[data-morevisits]').forEach(b => b.addEventListener('click', async () => {
const per = (r.rates && r.rates.visitCostPerVisit) || 3;
const n = await IAP.ask({ title: 'Buy more visits', text: 'How many more verified visits? ' + per + ' credits each, charged now like the original pack.', type: 'number', placeholder: 'e.g. 50', ok: 'Buy visits' });
const per = Number(b.dataset.vper) || (r.rates && r.rates.visitCostPerVisit) || 3; const door = b.dataset.vdoor; // door packs top up at their door price
const what = door === 'golden' ? 'Golden Doors' : door ? 'doors' : 'visits';
const n = await IAP.ask({ title: 'Buy more ' + what, text: door ? 'How many more ' + what + '? ' + per + ' credits each, charged now like the original pack.' : 'How many more verified visits? ' + per + ' credits each, charged now like the original pack.', type: 'number', placeholder: 'e.g. 50', ok: 'Buy ' + what });
if (!n) return;
try { const x = await api('/api/my/campaigns/' + b.dataset.morevisits + '/topup', { credits: Math.floor(Number(n)) * per });
IAP.status('Added ' + x.visits + ' visits (' + x.added + ' credits)' + (x.reactivated ? '. The pack is open again.' : '.'), 'ok');
IAP.status('Added ' + x.visits + ' ' + what + ' (' + x.added + ' credits)' + (x.reactivated ? '. The pack is open again.' : '.'), 'ok');
await loadCampaigns(); loadDashboard();
} catch (e) { IAP.status(e.message, 'bad'); }
}));
@@ -1213,15 +1216,31 @@
+ ' for ' + (dys * lastRates.featuredPerDay) + ' credits. Max ' + (s ? s.slotsPerDay : 10) + ' links share any day.';
}
document.addEventListener('change', e => { if (e.target && e.target.id === 'cFeatDays') featHint(); });
// where a visits pack runs (Spooky Doors, 2026-10-02): everywhere, behind the doors, or a Golden Door, each with its own price
// function declarations (hoisted): loadCampaigns can run before this point is reached
function visitPlace() { const x = document.querySelector('input[name="cVisitPlace"]:checked'); return x ? x.value : 'all'; }
function placeCost(pl, rr) { rr = rr || lastRates || {}; return pl === 'golden' ? (rr.goldenDoorCost || 6) : pl === 'doors' ? (rr.doorPackCost || 4) : (rr.visitCostPerVisit || 3); }
function sdSeasonOpen(rr) { return new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) < String((rr && rr.sdSeasonEnd) || '2026-11-01'); }
function sdLastDay(rr) { const t = new Date(String((rr && rr.sdSeasonEnd) || '2026-11-01') + 'T12:00:00Z'); t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); }
function visitHint() {
if (!lastRates) return;
const open = sdSeasonOpen(lastRates);
document.querySelectorAll('#cVisitPlaceRow .sd-place').forEach(el => { el.hidden = !open; });
if (!open && visitPlace() !== 'all') { const a = document.querySelector('input[name="cVisitPlace"][value="all"]'); if (a) a.checked = true; }
document.querySelectorAll('[data-vpcost]').forEach(el => { const p = el.dataset.vpcost; el.textContent = '(' + placeCost(p) + ' credits a ' + (p === 'all' ? 'visit' : 'door') + ')'; });
const pl = visitPlace(), per = placeCost(pl), min = lastRates.visitMinPack || 20;
const n = Number($('cVisitCount').value) || 0;
const cost = n * (lastRates.visitCostPerVisit || 3);
$('cVisitHint').textContent = (lastRates.visitCostPerVisit || 3) + ' credits per verified visit'
+ (n >= (lastRates.visitMinPack || 20) ? ' — ' + n + ' visits = ' + cost + ' credits' : ' (min ' + (lastRates.visitMinPack || 20) + ')')
+ '. Each is a unique member, dwell + human-check verified.';
const unit = pl === 'golden' ? 'Golden Door' : pl === 'doors' ? 'door' : 'verified visit';
$('cVisitCount').placeholder = pl === 'all' ? 'How many verified visits?' : pl === 'golden' ? 'How many Golden Doors?' : 'How many doors?';
$('cVisitHint').textContent = per + ' credits per ' + unit
+ (n >= min ? ': ' + n + ' = ' + (n * per).toLocaleString() + ' credits, paid up front' : ' (min ' + min + ')')
+ (pl === 'all' ? '. Each is a unique member, dwell + human-check verified.'
: '. Each door is a dwell + human-check verified visit by a Spooky Doors player, at most once a day per player'
+ (pl === 'golden' ? '; Golden Doors open before every other door and give the player bonus candy' : '; door packs open before ordinary visits')
+ '. They run only in Spooky Doors until the season ends on ' + sdLastDay(lastRates) + ', then any doors left run as normal visits.');
}
$('cVisitCount').addEventListener('input', visitHint);
document.querySelectorAll('input[name="cVisitPlace"]').forEach(x => x.addEventListener('change', visitHint));
// video composer: tier dropdown + upload + price hint
function videoHint() {
if (!lastRates || !lastRates.videoTiers) return;
@@ -1272,13 +1291,13 @@
videoUrl: $('cVideoUrl').value, watchSecs: Number($('cWatchSecs').value),
videoW: cVidDims ? cVidDims.w : null, videoH: cVidDims ? cVidDims.h : null,
days: Number($('cFeatDays').value), startDay: featStartDay,
count: Number($('cVisitCount').value),
count: Number($('cVisitCount').value), placement: t === 'visits' ? visitPlace() : undefined,
dailyCap: ($('cDailyCap') && (t === 'banner' || t === 'text')) ? Number($('cDailyCap').value) || 0 : 0,
geo: [...document.querySelectorAll('.geoTier:checked')].map(x => x.value).join(','),
startsAt: ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value).getTime() : 0,
endsAt: ($('cEndAt') && $('cEndAt').value && !isFeat) ? new Date($('cEndAt').value).getTime() : 0,
ctaLabel: isVideo ? $('cVideoCta').value : $('cCtaLabel').value,
budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : t === 'visits' ? (Number($('cVisitCount').value) * (lastRates.visitCostPerVisit || 3)) : Number($('cBudget').value) });
budget: isFeat ? (Number($('cFeatDays').value) * (lastRates.featuredPerDay || 40)) : t === 'visits' ? (Number($('cVisitCount').value) * placeCost(visitPlace())) : Number($('cBudget').value) });
const schedStart = ($('cStartAt') && $('cStartAt').value && !isFeat) ? new Date($('cStartAt').value) : null;
IAP.status(schedStart && schedStart.getTime() > Date.now() ? 'Campaign saved. It starts serving ' + schedStart.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' }) + '.' : 'Campaign is live. It starts serving right away.', 'ok');
// clear EVERY field so no target/creative carries into the next campaign
@@ -1286,6 +1305,7 @@
'cVideoUrl', 'cVideoTitle', 'cVideoCta', 'cVisitTitle', 'cVisitCount', 'cFeatTitle', 'cDailyCap', 'cStartAt', 'cEndAt']
.forEach(id => { if ($(id)) $(id).value = ''; });
document.querySelectorAll('.geoTier').forEach(x => { x.checked = true; });
{ const a = document.querySelector('input[name="cVisitPlace"][value="all"]'); if (a) a.checked = true; if (t === 'visits') visitHint(); }
$('cSoloEd').innerHTML = ''; if ($('cSoloRaw')) $('cSoloRaw').value = '';
$('cVideoInfo').textContent = ''; $('cVideoPrev').hidden = true; $('cVideoPrev').innerHTML = '';
if ($('edMediaInfo')) $('edMediaInfo').textContent = '';
@@ -2128,9 +2148,10 @@
if ($('tkGo')) { $('tkGo').addEventListener('click', tkGenerate); $('tkAgain').addEventListener('click', tkGenerate); $('tkCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('tkText').value); IAP.status('Copied.', 'ok'); } catch (e) { $('tkText').select(); } }); $('tkSendBc').addEventListener('click', tkSendBroadcast); }
// promo tools: pill menu switches between posts / swipes / banners / wall / videos
function setPromoSub(name) {
const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'polhunter'];
const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'polhunter', 'spookydoors'];
if (name === 'toolkit') loadToolkit();
if (!ids.includes(name)) name = 'posts';
const pill = document.querySelector('.promo-pills [data-promo="' + name + '"]');
if (!ids.includes(name) || !pill || pill.hidden) name = 'posts';
ids.forEach(id => { const el = $('promo-' + id); if (el) el.hidden = id !== name; });
document.querySelectorAll('.promo-pills [data-promo]').forEach(b => {
b.classList.toggle('on', b.dataset.promo === name);