diff --git a/chatbot.js b/chatbot.js index 9d7bd1f..d01206e 100644 --- a/chatbot.js +++ b/chatbot.js @@ -25,7 +25,7 @@ let DATA_DIR = null; let chain = null; const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro'; const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b'; -const KNOWLEDGE_DATE = '2026-11-01'; // the day the CANNED answers and FACTS below were last checked against the site +const KNOWLEDGE_DATE = '2026-11-04'; // the day the CANNED answers and FACTS below were last checked against the site function init(opts) { if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } @@ -60,7 +60,7 @@ const CANNED = [ a: 'Open Ads in your Control Room (' + SITE_URL + '/ads) and press Edit on the ad. You can change where the click goes, the banner image (upload a new one or paste a link), the headline and line of a text ad, and the ad name. A login ad shows your page itself, so its link is the whole ad. The first edit of every ad is free, your one correction; each edit after that costs a small credit fee (100 credits at the moment, shown before you save), taken from earned credits first. The type, size, budget, countries, schedule and audience stay as they are; for those, start a new ad. A new link is checked the same way as a new ad, so it has to load and, for banner and text ads, allow framing.' }, { id: 'login-ads', title: 'Login ad slots', q: ['How do login ads work?', 'How do I book a login ad?'], tags: ['login ad', 'slot', 'purchased credits'], re: /(log ?-?in|sign ?-?in) (ad|ads|spot|sponsor|slot|slots)|(ad|sponsor) (on|at) (the )?(log ?-?in|sign ?-?in)/i, - a: 'A login ad is a slot: 1,000 purchased credits buys 30 days of your page, full screen, to every member right after they sign in, with unlimited sign-in impressions and nothing charged per day. At most 6 member slots run at once because they share the same sign-ins. When all 6 are taken you can reserve the next one from the same place: you pay the 1,000 purchased credits now to get your place in line, first paid first served, and your 30 days start the moment a slot frees up (we tell you on the site and by email). The Ads screen shows your place and an estimated start date, which is only an estimate. While you wait you can edit the ad for free, and if you cancel before it starts you get the full 1,000 credits back. A paused slot can only resume when nobody is waiting, because a freed slot goes to the line first. Login ads spend purchased credits only, so earned credits go to banner and text ads instead. Buy or reserve one from Ads, New ad, Login ad.' }, + a: 'A login ad is a slot: 1,000 purchased credits buys 30 days of your page, full screen, to every member right after they sign in, with unlimited sign-in impressions and nothing charged per day. At most 6 member slots run at once because they share the same sign-ins. When all 6 are taken you can reserve the next one from the same place: you pay the 1,000 purchased credits now to get your place in line, first paid first served, and your 30 days start the moment a slot frees up (we tell you on the site and by email). The Ads screen shows your place and an estimated start date, which is only an estimate. While you wait you can edit the ad for free, and if you cancel before it starts you get the full 1,000 credits back. A paused slot can only resume when nobody is waiting, because a freed slot goes to the line first. Login ads spend purchased credits only, so earned credits go to banner and text ads instead. Buy or reserve one from Ads, New ad, Login ad. The slot is paid from ONE of your positions, so one position needs the full 1,000 purchased credits free on its own; credits split across two positions do not add up for a login slot (the Ads screen shows what each position has free).' }, { id: 'vs-iap', title: 'LinkSpin and InstantAdPay: the difference', q: ['What is the difference between LinkSpin and InstantAdPay?', 'Is this the same as InstantAdPay?', 'Why another site?'], tags: ['instantadpay', 'iap', 'sister site', 'network'], re: /(instant ?ad ?pay|[^a-z]iap[^a-z]|differen|same as|another (site|program|property)|why (two|another)|sister (site|property)|which (one|site) (should|do))/i, a: 'InstantAdPay is the ad marketplace: you buy ad packages there, earn credits by viewing ads, and get paid when your line buys. LinkSpin is the tool side of the same network: a link rotator, a page builder and ad zones for your own sites, free with an email address. Its packages buy ad delivery across the LinkSpin viewer, every member zone and the partner network, and they pay your sponsor line the same way, inside the purchase transaction. Same people above and below you, same wallet, and your InstantAdPay username and profile carry over when you sign in with the same email.' }, diff --git a/public/ads.html b/public/ads.html index 033ccec..7732515 100644 --- a/public/ads.html +++ b/public/ads.html @@ -76,7 +76,7 @@ - + diff --git a/public/assets/ads-screen.js b/public/assets/ads-screen.js index 801a702..b8f5dac 100644 --- a/public/assets/ads-screen.js +++ b/public/assets/ads-screen.js @@ -133,13 +133,21 @@ 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 = false; $('fGo').textContent = full ? 'Reserve the next slot' : 'Launch'; $('fGo').title = full ? 'All login-ad slots are taken: pay now for a place in line' : ''; cost(); preview(); } + // a login slot is paid from ONE position (2026-11-04): say what each position has free and stop the buy up front when none covers it + const loginShort = () => { const F = D && D.loginFunds; return !!(F && F.best < slotInfo().credits); }; + function fundsLine() { const F = D && D.loginFunds; if (!F) return ''; const L = slotInfo(); + const per = (F.per || []).length > 1 ? ' (' + F.per.map(x => '#' + x.memberId + ': ' + fmt(x.avail)).join(', ') + ')' : ''; + return 'Paid from one position. ' + + (loginShort() ? 'None of yours has ' + fmt(L.credits) + ' purchased credits free on its own' + per + '. Buy a package on one position to bring it to ' + fmt(L.credits) + ', then come back.' + : 'Your best-funded position has ' + fmt(F.best) + ' purchased credits free' + per + '.') + ''; } + function fundsGate() { if (TYPE !== 'login') return; const b = $('fGo'); b.disabled = loginShort(); if (loginShort()) b.title = 'No single position has ' + fmt(slotInfo().credits) + ' purchased credits free'; } 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, reserve the next)'); } 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 { const L = slotInfo(); $('fCost').innerHTML = L.free + else { const L = slotInfo(); $('fCost').innerHTML = (L.free ? '' + fmt(L.credits) + ' purchased credits for ' + L.days + ' days of unlimited sign-in impressions ยท ' + L.free + ' of ' + L.max + ' slots open' - : 'All ' + L.max + ' login-ad slots are taken' + (L.queued ? ', ' + L.queued + ' paid reservation' + (L.queued === 1 ? '' : 's') + ' in line' : '') + '. Reserve the next one: ' + fmt(L.credits) + ' purchased credits now and you would be #' + nextPlace().place + ' in line. ' + esc(estText(nextPlace().estStartCt)) + ' Cancel before it starts for a full refund.'; return; } + : 'All ' + L.max + ' login-ad slots are taken' + (L.queued ? ', ' + L.queued + ' paid reservation' + (L.queued === 1 ? '' : 's') + ' in line' : '') + '. Reserve the next one: ' + fmt(L.credits) + ' purchased credits now and you would be #' + nextPlace().place + ' in line. ' + esc(estText(nextPlace().estStartCt)) + ' Cancel before it starts for a full refund.') + fundsLine(); fundsGate(); return; } $('fCost').innerHTML = b >= 10 ? s.replace(/(about )([\d,]+)/, '$1$2') : 'minimum 10 credits'; } function preview() { const p = $('prev'); if (TYPE === 'banner' && IMG) { const sz = ($('fSize').value || '728x90').split('x'); p.innerHTML = '
Preview
'; } else if (TYPE === 'text') p.innerHTML = '
Preview
' + esc($('fTitle').value || 'Your headline') + '
' + esc($('fBody').value || 'One line under it.') + '
' + esc(host($('fTarget').value || 'yoursite.com')) + '
'; @@ -172,7 +180,10 @@ $('fGo').disabled = true; try { const r = await api('/api/my/campaigns', body); const c = r.campaign || {}; toast(c.status === 'queued' ? 'Reserved and paid. You are #' + (c.place || '?') + ' in line. We let you know when it starts.' : 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 = false; } + $('composer').hidden = true; $('fName').value = ''; load(); } catch (e) { + // a login-ad failure stays on screen until read (the 2-second toast was missed, 2026-11-03) + if (TYPE === 'login') await dialog({ title: body.reserve ? 'Your reservation did not go through' : 'Your login ad did not launch', text: e.message, ok: 'OK', no: 'Close' }); else toast(e.message, true); + } finally { $('fGo').disabled = false; fundsGate(); } }); CR.requireSession(load); })(); diff --git a/server.js b/server.js index 2907ab2..db01c05 100644 --- a/server.js +++ b/server.js @@ -3743,6 +3743,10 @@ const server = http.createServer(async (req, res) => { out.loginSlots = await ads.loginSlots(); // { max, used, queued, free, credits, days }: the Ads screen shows how many are open out.loginQueue = await ads.myLoginQueue(s.email); // my paid reservations: place in line + estimated start (Central) out.loginNext = await ads.loginNext(); // the place and estimated start a new reservation would get + // a login slot is paid from ONE position (Michael Camire 2026-11-03: 1,000 credits split 618 + 382 failed with a toast he never saw): + // the screen shows each position's free purchased credits and stops the buy before it is tried + try { const pool = await ads.balances((await myMemberIds(s)).ids, s.email); + out.loginFunds = { best: (pool.best.avail || 0) + (pool.credited || 0), credited: pool.credited || 0, per: pool.per.map(x => ({ memberId: x.memberId, avail: x.avail })) }; } catch (e) { out.loginFunds = null; } out.creditLog = await ads.creditLog(s.email, 20); // credit activity (login slots, reservations, refunds) out.editFee = editFee(); // credits per edit after each campaign's free one (the editor says which this is) out.clickSources = await coach.clickSources(out.campaigns.map(c => c.id)); @@ -3775,8 +3779,10 @@ const server = http.createServer(async (req, res) => { const fundId = pool.best.memberId || memberId; const earnedNow = String(b.type) !== 'login' ? pool.earned : 0; const budget = Math.floor(Number(b.budget) || 0); + if (String(b.type) === 'login' && pool.per.length > 1 && budget > pool.best.avail + pool.credited && budget <= pool.total) + return json(res, 400, { error: 'Nothing was charged. A login-ad slot costs ' + budget.toLocaleString('en-US') + ' purchased credits and is paid from ONE position. Your credits are spread across ' + pool.per.length + ' positions (' + pool.per.map(x => '#' + x.memberId + ': ' + x.avail.toLocaleString('en-US')).join(', ') + ' free), so none of them holds ' + budget.toLocaleString('en-US') + ' on its own. Buy a package on one position to bring it to ' + budget.toLocaleString('en-US') + ', or let a running campaign on it finish, then try again.', loginFunds: true }); if (pool.per.length > 1 && budget > pool.best.avail + pool.credited + earnedNow && budget <= pool.total + earnedNow) - return json(res, 400, { error: 'Your credits are spread across ' + pool.per.length + ' positions and one campaign spends from one of them. The largest single position holds ' + pool.best.avail + ' credits: set the budget to that or less, or run two campaigns.' }); + return json(res, 400, { error:'Your credits are spread across ' + pool.per.length + ' positions and one campaign spends from one of them. The largest single position holds ' + pool.best.avail + ' credits: set the budget to that or less, or run two campaigns.' }); const r = await ads.createCampaign(s.email, fundId, b, ids); return json(res, r.error ? 400 : 200, r); }