Login ads: flat 30-day slot, same as InstantAdPay
- Engine (JSON + MySQL twin): login ads are a slot buy (loginSlotCredits 1000,
loginSlotDays 30, loginSlotsMax 3, dwell 10 s). createCampaign pins the budget
to the slot price, sets the 30-day expiry and charges it once, purchased credits
only (credited purchased grade first, the rest burns on-chain; viewing credits
never pay). countLoginSlots counts live member slots (house never counts); a 4th
is refused while 3 are live. Sign-in pick prefers member slots over the house.
The per-day charge loop only runs for legacy login ads with no expiry.
- Day keys on Central time (ctDay / dayKeyNow / today) instead of UTC toISOString,
incl. login lastShownDay, the daily sweep, claim streak and sign-in bonus.
- Beyond IAP: resuming a paused slot obeys the same cap, top-up is refused on a
slot, the audit's days-charged check skips slots, JSON grantWelcome keeps the
purchased grade.
- Ads screen: slot wording, loginSlots { max, used, free } from the API, chip and
cost line show open slots, Launch disabled with an explanation when full; no Top
up on slots; classic dashboard, earning page, admin rate labels and chatbot
(canned answer + FACTS, KNOWLEDGE_DATE 2026-10-18) updated. Cache tags bumped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -792,7 +792,10 @@
|
||||
bannerBatch: ['Banner: views per batch', 'impressions counted before a banner campaign is charged'],
|
||||
bannerCreditsPerBatch: ['Banner: credits per batch', 'charged to the advertiser per batch'],
|
||||
textBatch: ['Text ad: views per batch', ''], textCreditsPerBatch: ['Text ad: credits per batch', ''],
|
||||
loginCreditsPerDay: ['Login ad: credits per day', 'flat daily charge while active'],
|
||||
loginSlotCredits: ['Login ad: slot price (credits)', 'one flat buy, purchased credits only, unlimited sign-in impressions'],
|
||||
loginSlotDays: ['Login ad: slot length (days)', 'the slot ends and frees its place after this many days'],
|
||||
loginSlotsMax: ['Login ad: member slots at once', 'a new slot is refused while this many are live; house ads do not count'],
|
||||
loginCreditsPerDay: ['Login ad: legacy credits per day', 'only for old login ads with no end date (none since slots)'],
|
||||
loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'],
|
||||
burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'],
|
||||
welcomeCredits: ['Welcome credits', 'granted after the welcome tour'],
|
||||
|
||||
@@ -7,8 +7,13 @@
|
||||
const NOTE = {
|
||||
banner: 'Runs in the ad viewer, in every member zone on outside sites, and on the partner network. Views are timed on the server. Spends purchased or earned credits.',
|
||||
text: 'A headline and one line. Runs in the ad viewer and on the partner network. Spends purchased or earned credits.',
|
||||
login: 'Your page, full screen, to every member right after they sign in. One sponsor a day, purchased credits only. No creative needed: the page is the ad.'
|
||||
login: 'Your page, full screen, to every member right after they sign in. A slot is 1,000 purchased credits for 30 days of unlimited sign-in impressions, paid once and never charged per day. 3 slots at a time, first come first served. No creative needed: the page is the ad.'
|
||||
};
|
||||
// login slots (same rule as InstantAdPay): one flat price, a fixed run, a cap on member slots live at once
|
||||
const slotInfo = () => { const r = (D && D.rates) || {}; const ls = (D && D.loginSlots) || {}; const max = ls.max || r.loginSlotsMax || 3;
|
||||
return { credits: ls.credits || r.loginSlotCredits || 1000, days: ls.days || r.loginSlotDays || 30, max, used: ls.used || 0, free: ls.free != null ? ls.free : max }; };
|
||||
const loginNote = () => { const L = slotInfo();
|
||||
return 'Your page, full screen, to every member right after they sign in. A slot is ' + fmt(L.credits) + ' purchased credits for ' + L.days + ' days of unlimited sign-in impressions, paid once and never charged per day. ' + L.max + ' slots at a time, first come first served. No creative needed: the page is the ad.'; };
|
||||
const host = u => { try { return new URL(u).hostname.replace(/^www\./, ''); } catch (e) { return u; } };
|
||||
async function load() {
|
||||
try { [D, EARN] = await Promise.all([CR.get('/api/my/campaigns'), CR.get('/api/my/earn')]); } catch (e) { CR.sub('could not load'); return; }
|
||||
@@ -24,18 +29,19 @@
|
||||
CR.tile({ k: 'Views delivered', v: fmt(views), series: week ? hours : null, note: week ? fmt(week) + ' in 7 days, by hour' : '' }),
|
||||
CR.tile({ k: 'Today\'s viewing', v: EARN.views + ' / ' + EARN.target, note: EARN.streakDay > 1 ? 'streak day ' + EARN.streakDay : '' })].join('');
|
||||
const r = D.rates || {};
|
||||
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views, ' + r.loginCreditsPerDay + ' per day for the login spot. Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
|
||||
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views, ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day login slot (' + slotInfo().free + ' of ' + slotInfo().max + ' open). Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
|
||||
const st = c => c.scheduled ? '<span class="tag">Scheduled</span>' : c.status === 'active' ? '<span class="tag ok">Live</span>' : c.status === 'paused' ? '<span class="tag warn">Paused</span>' : c.status === 'out' ? '<span class="tag warn">Out of credits</span>' : c.status === 'done' ? '<span class="tag">Ended</span>' : '<span class="tag">' + esc(c.status) + '</span>';
|
||||
const cr = c => c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page</span>';
|
||||
const cr = c => c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page' + (c.type === 'login' && c.expires ? '<br><span style="font-size:12px">' + (c.expires > Date.now() ? 'slot ends ' : 'ended ') + new Date(c.expires).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) + '</span>' : '') + '</span>';
|
||||
$('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw"><div><b>' + esc(c.name) + '</b> <span class="tag t">' + esc(c.type) + '</span>' + (c.audience ? ' <span class="tag plain" title="audience">' + esc((((D && D.audiences) || []).find(a => a.id === c.audience) || {}).name || 'audience') + (c.audienceMode === 'exclude' ? ' · excluded' : '') + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + '</span><div class="bar"><i style="width:' + Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network</span>' : '') + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">'
|
||||
+ (c.status === 'active' ? '<button class="btn sm" type="button" data-pause="' + c.id + '">Pause</button>' : c.status === 'paused' ? '<button class="btn sm" type="button" data-resume="' + c.id + '">Resume</button>' : '')
|
||||
+ (['active', 'paused', 'out'].includes(c.status) ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '') + '</span></div>').join('')
|
||||
: '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or the login spot.</span></div>';
|
||||
+ (['active', 'paused', 'out'].includes(c.status) && c.type !== 'login' ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '') + '</span></div>').join('')
|
||||
: '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or a login-ad slot.</span></div>';
|
||||
if (D.gauntletPending) $('earnNote').insertAdjacentHTML('afterend', '<div class="muted" style="margin-top:8px">Your welcome credits unlock after the short welcome tour on <a href="/tools">the classic dashboard</a>.</div>');
|
||||
$('foot').textContent = 'views = timed views in the ad viewer plus member zones; network = the partner ad network · a paused ad keeps its credits · unspent credits return when an ad ends';
|
||||
$('rows').querySelectorAll('[data-pause]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.pause + '/pause')));
|
||||
$('rows').querySelectorAll('[data-resume]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.resume + '/resume')));
|
||||
$('rows').querySelectorAll('[data-top]').forEach(b => b.addEventListener('click', async () => { const v = await dialog({ title: 'Top up #' + b.dataset.top, text: 'Add credits to this ad. You have ' + fmt(D.availableCredits) + ' available.', fields: [{ k: 'credits', label: 'Credits to add', value: '25', mono: true }], ok: 'Add' }); if (!v) return; try { await api('/api/my/campaigns/' + b.dataset.top + '/topup', { credits: Number(v.credits) }); toast('Topped up.'); load(); } catch (e) { toast(e.message, true); } }));
|
||||
slotChip(); if (!$('composer').hidden) setType(TYPE);
|
||||
earnPaint();
|
||||
}
|
||||
async function act(path) { try { await api(path, {}); load(); } catch (e) { toast(e.message, true); } }
|
||||
@@ -66,11 +72,18 @@
|
||||
window.addEventListener('storage', e => { if (e.key === 'iap-view-done') earnRefresh(); });
|
||||
$('earnClaim').addEventListener('click', async () => { try { const r = await api('/api/my/claim', {}); toast('+' + r.credited + ' credits' + (r.streakDay > 1 ? ', streak day ' + r.streakDay : '') + '. Spend them on an ad.'); load(); } catch (e) { toast(e.message, true); } });
|
||||
// -- composer
|
||||
function setType(t) { TYPE = t; document.querySelectorAll('#typeChips .chip').forEach(c => c.classList.toggle('on', c.dataset.t === t)); $('typeNote').textContent = NOTE[t]; $('bannerFields').hidden = t !== 'banner'; $('textFields').hidden = t !== 'text'; $('fCap').parentElement.hidden = t === 'login'; cost(); preview(); }
|
||||
function setType(t) { TYPE = t; document.querySelectorAll('#typeChips .chip').forEach(c => c.classList.toggle('on', c.dataset.t === t)); $('typeNote').textContent = t === 'login' ? loginNote() : NOTE[t]; $('bannerFields').hidden = t !== 'banner'; $('textFields').hidden = t !== 'text'; $('fCap').parentElement.hidden = t === 'login';
|
||||
const L = slotInfo(), full = t === 'login' && !L.free; const fb = $('fBudget');
|
||||
if (t === 'login') { fb.dataset.keep = fb.dataset.keep || fb.value; fb.value = L.credits; fb.readOnly = true; } else { if (fb.readOnly && fb.dataset.keep) fb.value = fb.dataset.keep; delete fb.dataset.keep; fb.readOnly = false; }
|
||||
$('fGo').disabled = full; $('fGo').title = full ? 'All login-ad slots are taken right now' : '';
|
||||
cost(); preview(); }
|
||||
function slotChip() { const ch = document.querySelector('#typeChips .chip[data-t="login"]'); if (!ch || !D) return; const L = slotInfo(); ch.textContent = 'Login ad' + (L.free ? ' (' + L.free + ' of ' + L.max + ' open)' : ' (full)'); }
|
||||
function cost() { const b = Math.floor(Number($('fBudget').value) || 0); const r = D ? D.rates : {}; let s = '';
|
||||
if (TYPE === 'banner') s = 'about ' + fmt(Math.floor(b / (r.bannerCreditsPerBatch || 2) * (r.bannerBatch || 10))) + ' timed views';
|
||||
else if (TYPE === 'text') s = 'about ' + fmt(Math.floor(b / (r.textCreditsPerBatch || 1) * (r.textBatch || 10))) + ' timed views';
|
||||
else s = 'about ' + Math.floor(b / (r.loginCreditsPerDay || 100)) + ' day' + (Math.floor(b / (r.loginCreditsPerDay || 100)) === 1 ? '' : 's') + ' as the login sponsor (' + (r.loginCreditsPerDay || 100) + ' per day)';
|
||||
else { const L = slotInfo(); $('fCost').innerHTML = L.free
|
||||
? '<b>' + fmt(L.credits) + '</b> purchased credits for <b>' + L.days + '</b> days of unlimited sign-in impressions · <b>' + L.free + '</b> of ' + L.max + ' slots open'
|
||||
: 'All <b>' + L.max + '</b> login-ad slots are taken right now. A place opens when a running slot ends its ' + L.days + ' days; check back in a few days.'; return; }
|
||||
$('fCost').innerHTML = b >= 10 ? s.replace(/(about )([\d,]+)/, '$1<b>$2</b>') : 'minimum <b>10</b> credits'; }
|
||||
function preview() { const p = $('prev'); if (TYPE === 'banner' && IMG) { const sz = ($('fSize').value || '728x90').split('x'); p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><img src="' + esc(IMG) + '" alt="" style="max-width:100%;width:' + sz[0] + 'px;height:auto;border:1px solid var(--chrome-line);background:var(--inset)">'; }
|
||||
else if (TYPE === 'text') p.innerHTML = '<div class="muted" style="margin-bottom:6px">Preview</div><div class="panel" style="max-width:420px"><b>' + esc($('fTitle').value || 'Your headline') + '</b><br><span class="ink2">' + esc($('fBody').value || 'One line under it.') + '</span><br><span class="mono muted" style="font-size:11px">' + esc(host($('fTarget').value || 'yoursite.com')) + '</span></div>';
|
||||
@@ -95,7 +108,7 @@
|
||||
if (TYPE === 'banner') { body.size = $('fSize').value; body.imageUrl = $('fImage').value.trim(); }
|
||||
if (TYPE === 'text') { body.title = $('fTitle').value; body.body = $('fBody').value; }
|
||||
$('fGo').disabled = true;
|
||||
try { await api('/api/my/campaigns', body); toast('Launched. It is live in rotation now.'); $('composer').hidden = true; $('fName').value = ''; load(); } catch (e) { toast(e.message, true); } finally { $('fGo').disabled = false; }
|
||||
try { await api('/api/my/campaigns', body); toast(TYPE === 'login' ? 'Launched. Your login-ad slot runs for ' + slotInfo().days + ' days.' : 'Launched. It is live in rotation now.'); $('composer').hidden = true; $('fName').value = ''; load(); } catch (e) { toast(e.message, true); } finally { $('fGo').disabled = TYPE === 'login' && !slotInfo().free; }
|
||||
});
|
||||
CR.requireSession(load);
|
||||
})();
|
||||
|
||||
+10
-6
@@ -785,7 +785,7 @@
|
||||
try {
|
||||
const r = await (await fetch('/api/my/campaigns')).json();
|
||||
if (r.error) return;
|
||||
lastRates = r.rates;
|
||||
lastRates = r.rates; lastSlots = r.loginSlots || null;
|
||||
if ($('cGeoHint') && r.tiers) $('cGeoHint').textContent = 'All three ticked = everyone. Tier 1: ' + r.tiers.t1.join(', ') + '. Tier 2: ' + r.tiers.t2.join(', ') + '. Tier 3: every other country. Geo applies to delivery on this site; a narrowed banner or text ad is kept off the worldwide partner network. ' + (r.geoReady ? '' : 'Country data is still loading, so narrowed campaigns pause until it is ready. ') + 'IP geolocation by DB-IP.';
|
||||
// populate the banner-size dropdown once (ids map to NAS width/height)
|
||||
if (r.bannerSizes && $('cSize') && !$('cSize').options.length)
|
||||
@@ -799,14 +799,14 @@
|
||||
if ($('spendNote')) $('spendNote').textContent = r.inCampaigns
|
||||
? 'Not counting ' + r.inCampaigns.toLocaleString() + ' credits already set aside for your live campaigns. That budget spends down inside each campaign below. This number only moves when you start, top up or pause a campaign.'
|
||||
: 'This is what is not committed to a campaign. When you start one, its budget moves out of here and spends down inside the campaign.';
|
||||
$('spendRates').innerHTML = [['Banner', r.rates.bannerCreditsPerBatch + ' cr / ' + r.rates.bannerBatch + ' views'], ['Text', r.rates.textCreditsPerBatch + ' cr / ' + r.rates.textBatch + ' views'], ['Login', r.rates.loginCreditsPerDay + ' cr / day'], ['Solo', r.rates.soloCostPerRecipient + ' cr / delivery'], ['Featured', (r.rates.featuredPerDay || 40) + ' cr / day'], ['Visit', (r.rates.visitCostPerVisit || 3) + ' cr / visit']].map(x => '<span><b>' + x[0] + '</b> ' + x[1] + '</span>').join('');
|
||||
$('spendRates').innerHTML = [['Banner', r.rates.bannerCreditsPerBatch + ' cr / ' + r.rates.bannerBatch + ' views'], ['Text', r.rates.textCreditsPerBatch + ' cr / ' + r.rates.textBatch + ' views'], ['Login', (r.rates.loginSlotCredits || 1000).toLocaleString() + ' cr / ' + (r.rates.loginSlotDays || 30) + '-day slot'], ['Solo', r.rates.soloCostPerRecipient + ' cr / delivery'], ['Featured', (r.rates.featuredPerDay || 40) + ' cr / day'], ['Visit', (r.rates.visitCostPerVisit || 3) + ' cr / visit']].map(x => '<span><b>' + x[0] + '</b> ' + x[1] + '</span>').join('');
|
||||
}
|
||||
$('rateLine').textContent = 'Available to spend: ' + r.availableCredits.toLocaleString()
|
||||
+ (r.earnedCredits ? ' (' + r.purchasedCredits.toLocaleString() + ' purchased + ' + r.earnedCredits + ' earned)' : '')
|
||||
+ (r.inCampaigns ? ' · ' + r.inCampaigns.toLocaleString() + ' set aside in live campaigns' : '')
|
||||
+ ' credits · rates: banner ' + r.rates.bannerCreditsPerBatch + 'cr/' + r.rates.bannerBatch
|
||||
+ ' views, text ' + r.rates.textCreditsPerBatch + 'cr/' + r.rates.textBatch
|
||||
+ ' views, login ' + r.rates.loginCreditsPerDay + 'cr/day, solo '
|
||||
+ ' views, login ' + (r.rates.loginSlotCredits || 1000) + 'cr per ' + (r.rates.loginSlotDays || 30) + '-day slot, solo '
|
||||
+ (r.rates.soloCostPerRecipient || 5) + 'cr/delivery';
|
||||
const el = $('campList');
|
||||
el.innerHTML = '';
|
||||
@@ -841,7 +841,7 @@
|
||||
}));
|
||||
} catch (e) {}
|
||||
}
|
||||
let lastRates = null;
|
||||
let lastRates = null, lastSlots = null;
|
||||
function soloHint() {
|
||||
if (!lastRates || $('cType').value !== 'solo') return;
|
||||
const cost = lastRates.soloCostPerRecipient || 5;
|
||||
@@ -895,12 +895,15 @@
|
||||
});
|
||||
const WHERE = { banner: 'Runs in the ad viewer, on the home page, the live ledger, every Overview, the sidebar tile, and out in the Network Ad Space rotation across the wider network.',
|
||||
text: 'Runs in the ad viewer, the live ledger text slot, and out in the Network Ad Space rotation.',
|
||||
login: 'Full screen for every member who signs in, ten seconds, once a day per member. Opens in a fresh tab, so any working page qualifies. Login ads spend purchased credits only.',
|
||||
login: 'Full screen for every member who signs in, ten seconds, once a day per member. Opens in a fresh tab, so any working page qualifies. A slot is 1,000 purchased credits for 30 days of unlimited sign-in impressions, never charged per day. 3 slots at a time, first come first served. Login ads spend purchased credits only.',
|
||||
solo: 'Delivered into member inboxes under Earn credits. Each read is timed and rewarded, so it gets opened.',
|
||||
video: 'Plays in Watch videos and the Shorts feed under Earn credits. You pay only for completed watches.',
|
||||
featured: 'Your headline and link in the Featured strip on every member Overview for the days you book.',
|
||||
visits: 'A distinct member opens your site in a new tab, stays eight seconds and passes a check. Nobody counts twice.' };
|
||||
const whereHint = () => { const el = $('cWhere'); if (el) el.textContent = WHERE[$('cType').value] || ''; };
|
||||
const whereHint = () => { const el = $('cWhere'); if (!el) return; const t = $('cType').value; let s = WHERE[t] || '';
|
||||
if (t === 'login' && lastRates) s = s.replace('1,000', (lastRates.loginSlotCredits || 1000).toLocaleString()).replace('30 days', (lastRates.loginSlotDays || 30) + ' days').replace('3 slots', (lastRates.loginSlotsMax || 3) + ' slots');
|
||||
if (t === 'login' && lastSlots) s += lastSlots.free ? ' ' + lastSlots.free + ' of ' + lastSlots.max + ' slots open right now.' : ' All ' + lastSlots.max + ' slots are taken right now; a place opens when a running slot ends its ' + lastSlots.days + ' days.';
|
||||
el.textContent = s; };
|
||||
whereHint();
|
||||
// runs on every type change AND once at load, so the default type (banner) shows its size + image rows immediately
|
||||
function applyType() { // hoisted: loadCampaigns may run before this line is reached
|
||||
@@ -924,6 +927,7 @@
|
||||
// solo ads have a real floor (5cr x 10 deliveries): default to 50 so 10 isn't rejected
|
||||
if (t === 'solo' && (!$('cBudget').value || Number($('cBudget').value) < 50)) $('cBudget').value = (lastRates && lastRates.soloCostPerRecipient ? lastRates.soloCostPerRecipient : 5) * 10;
|
||||
if (t === 'visits') visitHint();
|
||||
if (t === 'login') $('cBudget').value = (lastRates && lastRates.loginSlotCredits) || 1000; // a slot is one flat price
|
||||
$('cTitle').placeholder = t === 'solo' ? 'Subject line (max 80)' : 'Headline (max 60)';
|
||||
soloHint();
|
||||
if (t === 'video') videoHint();
|
||||
|
||||
Reference in New Issue
Block a user