From 5613d10224f44eebf154fe6481859c6bf978516f Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 17 Nov 2026 07:22:52 -0600 Subject: [PATCH] Network Weekend (Marty 2026-11-17): ribbon, WEEKEND500 start gate, date-gated chatbot fact - netdeals.js + /api/network-deals (hub /v1/network-deals) and /assets/netweekend.js loaded from common.js and netline.js: the ribbon shows only Fri 11-27 00:00 CT to Tue 12-01 00:00 CT by the page's own clock (common/netline ?v=20261117nw) - promos: optional starts (MySQL promo_codes.starts) so a code can be created dormant and open by itself; setClock for tests - weekendfact.js: chatbot FACTS for the event (live deal lines from the hub) Fri to Mon, the WEEKEND500 line to Tue 12-08 00:00 CT - qa/networkweekend.test.cjs: 8 pass (test clocks only) Co-Authored-By: Claude Opus 5.5 --- blog.js | 2 +- chatbot.js | 5 ++- db.js | 1 + leaderboard.js | 2 +- netdeals.js | 54 ++++++++++++++++++++++++++ promos.js | 17 ++++++--- public/admin.html | 2 +- public/assets/common.js | 3 ++ public/assets/netline.js | 3 ++ public/assets/netweekend.js | 67 +++++++++++++++++++++++++++++++++ public/contract.html | 2 +- public/conversion-tracking.html | 2 +- public/credits.html | 2 +- public/disclaimer.html | 2 +- public/earning.html | 4 +- public/index.html | 2 +- public/join.html | 4 +- public/launch.html | 2 +- public/ledger.html | 4 +- public/my.html | 2 +- public/partners.html | 4 +- public/plays.html | 2 +- public/privacy.html | 2 +- public/publishers.html | 2 +- public/refuel.html | 2 +- public/support.html | 4 +- public/terms.html | 2 +- public/tx.html | 2 +- public/wall.html | 2 +- public/wallets.html | 2 +- qa/networkweekend.test.cjs | 65 ++++++++++++++++++++++++++++++++ releases.js | 2 +- server.js | 4 +- weekendfact.js | 26 +++++++++++++ 34 files changed, 265 insertions(+), 38 deletions(-) create mode 100644 netdeals.js create mode 100644 public/assets/netweekend.js create mode 100644 qa/networkweekend.test.cjs create mode 100644 weekendfact.js diff --git a/blog.js b/blog.js index 4b59d20..f6cec72 100644 --- a/blog.js +++ b/blog.js @@ -110,7 +110,7 @@ function head(o) { + '
'; } function tail() { - return '
'; + return ''; } const authorBox = () => '
LinkSpin
' + AUTHOR + 'Founder of LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.
'; const cardHtml = p => '' + (p.cover ? '' : '') + '

' + esc(p.title) + '

' + esc(p.excerpt) + '

' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '

'; diff --git a/chatbot.js b/chatbot.js index 4c553ee..f6ced89 100644 --- a/chatbot.js +++ b/chatbot.js @@ -210,6 +210,7 @@ const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refue // launch day 2026-11-15 Central: before it the pre-launch fact, from it the launched fact (date-driven since 2026-11-02) const ctToday = () => new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); function launchFact() { return ctToday() < '2026-11-15' ? '- PRE-LAUNCH (since 2026-10-17): LinkSpin is open to everyone for pre-launch testing until the official launch on November 15, 2026. Everything is live and working (links, sources, zones, ads, credits, payouts), but features and screens may change while it is tested. A notice at the top of every member screen says so. If someone got a reminder email about a member they have not contacted, they can ignore it: nothing changed in their line.' : '- LAUNCHED 2026-11-15: LinkSpin is fully open. The pre-launch period (Oct 17 to Nov 14) is over; everything that was live stays live, and the pre-launch notice is gone.'; } +const { weekendFact } = require('./weekendfact'); // Network Weekend 2026, date-gated (Marty 2026-11-17) function systemPrompt(kbBlock) { return `You are the assistant on LinkSpin (${SITE_URL}), a link rotator, page builder and advertising network for marketers, a Crypto Team Build Network property. @@ -231,7 +232,7 @@ ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS - WHO INVITED YOU (2026-11-07, Marty approved): a member with no sponsor and no member number sees a Who invited you? box at the top of their Control Room screens. They type a username, confirm in an in-page box, and that member becomes their sponsor (it follows to InstantAdPay, lifts the hold, and the sponsor gets a new-referral email and notice); with a wallet already linked the site switches their payouts on under that sponsor right away. Refused: themselves, a username that does not exist, someone in their own line, a member who cannot take new members, a member with no payouts on and nobody above them on the contract, and anyone who already has a sponsor or a member number. Nobody invited me hides the box (a small link under More brings it back while they are in the tank) and changes nothing else. It never blocks the site. It is not an adoption: no 7-day window and it does not count toward the two. - SIGN-UP GRACE (2026-11-07): for 24 hours from sign-up nobody can adopt a member by hand. The 24-hour auto-assign is unchanged and runs from the wallet link, so a member who links a wallet in their first hour is matched about 24 hours after linking, with at most a short hand-adoption window first. Members back in the tank later have no grace. - HOLDING TANK ACTIVATION HOLD (2026-10-27): a member with no sponsor is first matched to their network sponsor (the same email or wallet with a sponsor on InstantAdPay). Nobody known: the free Switch on payouts waits for an adopter and the Credits screen says "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left; they show at the top of every holding tank with a green Ready to activate badge and the hours left, and the shared payments topic on Telegram is told. Nobody adopts in 24 hours: the site assigns them to the next eligible adopter in rotation (own $25+ package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within 7 days; least recently auto-assigned first), and the pickup is posted marked (auto-assigned). The moment they have a sponsor (adopted, assigned or matched), the site switches their payouts on under that sponsor (engine-paid) and sends them the transaction link. A PURCHASE IS NEVER HELD: a tank member can buy at any time; with no sponsor yet that purchase places them under the platform position for good. Someone who arrived through a sponsor link is never held. -${launchFact()} +${launchFact()}${weekendFact()} - SUPPORT (LIVE 2026-10-16): members open Help in the Control Room (${SITE_URL}/help) to send Marty a ticket (pick a category, a subject, the message), see each ticket's status (Open, Waiting on you, Closed), and read and answer his replies; a badge on the Help item shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at ${SITE_URL}/support, gets a private link to follow the ticket without signing in, and can reply there. The chat can also pass a conversation to support ("Send this to support"). Marty answers every ticket himself; there is no support email address, point people to ${SITE_URL}/support instead. Tickets share one desk with the rest of the Crypto Team Build Network. - Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; weekly and monthly prizes are ad credits, never cash). - FOUNDER BADGE (2026-11-05): cosmetic only (no credits, no POL, no perks, never posted to Telegram). Granted automatically from the launch moment (Sun 2026-11-15 6:00 AM Central) to every account whose earliest signed-in visit is before that moment; carried-over accounts that never signed in do not get it. Shown in the member's badge strip, on their wall, on their sponsor's Team list and on the leaderboard. @@ -326,4 +327,4 @@ async function answerRaw(message, historyText) { } } -module.exports = { init, answer, enabled, KNOWLEDGE_DATE, CANNED, seeds, systemPrompt }; +module.exports = { weekendFact, init, answer, enabled, KNOWLEDGE_DATE, CANNED, seeds, systemPrompt }; diff --git a/db.js b/db.js index 5793e0f..a57c80c 100644 --- a/db.js +++ b/db.js @@ -81,6 +81,7 @@ async function bootstrap() { catch (e) { if (!['ER_DUP_FIELDNAME', 'ER_DUP_KEYNAME'].includes(e.code)) throw e; } }; await alterSafe('ALTER TABLE promo_codes ADD COLUMN funder VARCHAR(190) NULL'); // member-funded partner codes (Nexus), 2026-09-14 + await alterSafe('ALTER TABLE promo_codes ADD COLUMN starts BIGINT NOT NULL DEFAULT 0'); // 2026-11-17 Network Weekend: a code can open at a set time (0 = open now) await alterSafe('ALTER TABLE accounts ADD COLUMN username VARCHAR(30) NULL'); await alterSafe('ALTER TABLE accounts ADD UNIQUE KEY uq_username (username)'); await alterSafe('ALTER TABLE accounts ADD COLUMN member_id INT NULL'); diff --git a/leaderboard.js b/leaderboard.js index 43125c5..1778fda 100644 --- a/leaderboard.js +++ b/leaderboard.js @@ -146,7 +146,7 @@ async function renderPage() { const w = winners(); if (w.length) h += '

Past winners

' + w.slice(0, 12).map(x => '
' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + ': ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '
').join(''); h += '

Sales are $ of packages bought by members you directly sponsor. Weekly and monthly prizes are advertising credits or packages, never cash. No income is guaranteed.

'; - h += ''; + h += ''; return h; } function setLaunchPanel(fn) { if (R) R.launchPanel = fn; } diff --git a/netdeals.js b/netdeals.js new file mode 100644 index 0000000..e708583 --- /dev/null +++ b/netdeals.js @@ -0,0 +1,54 @@ +// Network deals for this site's "Network Weekend" ribbon (Marty 2026-11-17). One source: the hub's public GET /v1/network-deals +// (HUB_URL). Cached 2 minutes, refreshed in the background, never waits on a slow hub (2.5 s timeout); hub down = no ribbon. +// The same file lives in every network site. Never RM Circle, never the games (the hub list never names them). +// The page (/assets/netweekend.js) switches the ribbon on and off by its own clock at startsAt / endsAt, so a cached copy never +// shows early or late. setLocal(fn) lets a site rewrite its own deal line from live data (for example a price read from chain), +// so the ribbon never shows a number the contract does not charge: fn(deal) returns the deal, a changed copy, or null to drop it. +const TTL = 2 * 60 * 1000; +let cache = { at: 0, body: { events: [] } }; +let inflight = null; +let local = null; + +const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, ''); +const safeUrl = u => (/^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(u || '')) ? String(u) : ''); +const str = (v, n) => String(v == null ? '' : v).slice(0, n || 300); +function clean(j) { + if (!j || !Array.isArray(j.events)) return null; + return { events: j.events.slice(0, 5).filter(e => e && e.id && !Number.isNaN(Date.parse(e.startsAt)) && !Number.isNaN(Date.parse(e.endsAt))).map(e => ({ + id: str(e.id, 60), name: str(e.name, 60), tagline: str(e.tagline, 160), url: safeUrl(e.url), startsAt: e.startsAt, endsAt: e.endsAt, + days: e.days && typeof e.days === 'object' ? Object.fromEntries(Object.entries(e.days).slice(0, 20).map(([k, v]) => [str(k, 10), str(v, 40)])) : {}, + deals: (Array.isArray(e.deals) ? e.deals : []).slice(0, 40).map(d => { + const x = { site: str(d.site, 30), name: str(d.name, 80), url: safeUrl(d.url), text: str(d.text), endsAt: Number.isNaN(Date.parse(d.endsAt)) ? e.endsAt : d.endsAt }; + if (d.note) x.note = str(d.note, 120); + if (d.byDay && typeof d.byDay === 'object') x.byDay = Object.fromEntries(Object.entries(d.byDay).slice(0, 20).map(([k, v]) => [str(k, 10), str(v)])); + return x; + }) + })) }; +} +function refresh() { + if (inflight || process.env.NETWORK_DEALS_HUB === '0') return inflight; + const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500); + inflight = fetch(hubUrl() + '/v1/network-deals', { signal: ac.signal }) + .then(r => (r.ok ? r.json() : null)) + .then(j => { const b = clean(j); if (b) cache = { at: Date.now(), body: b }; else cache.at = Date.now(); }) + .catch(() => { cache.at = Date.now() - TTL + 30 * 1000; }) // hub down: try again in 30 s, keep the last good copy + .finally(() => { clearTimeout(t); inflight = null; }); + return inflight; +} +function current() { if (Date.now() - cache.at > TTL) refresh(); return cache.body; } +function setLocal(fn) { local = typeof fn === 'function' ? fn : null; } +function withLocal(body, self) { + if (!local) return body; + return { events: body.events.map(e => Object.assign({}, e, { deals: e.deals.map(d => { + if (d.site !== self) return d; + try { const r = local(Object.assign({}, d)); return r === undefined ? d : r; } catch (err) { return d; } + }).filter(Boolean) })) }; +} +// GET /api/network-deals: public, short cache, the same answer on every page. self = this site's network id (NETWORK_SITE_ID). +function handle(req, res, self) { + const me = String(self || process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); + const body = Object.assign({ self: me }, withLocal(current(), me)); + res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=60', 'X-Content-Type-Options': 'nosniff' }); + res.end(JSON.stringify(body)); +} +module.exports = { current, handle, refresh, setLocal, clean, _set: b => { cache = { at: Date.now(), body: clean(b) || { events: [] } }; } }; diff --git a/promos.js b/promos.js index bdea814..36c0218 100644 --- a/promos.js +++ b/promos.js @@ -4,10 +4,14 @@ // the dashboard. One redemption per code per account; every redemption is logged; optional // cap (max uses) and expiry; codes can be switched off. Storage: MySQL promo_codes + // promo_redemptions, or DATA_DIR/promos.json. +// starts (2026-11-17, Network Weekend WEEKEND500): a code can be created dormant and open by itself at an exact time (ms; 0 = open +// now). Before it opens it answers 'not open yet'. Test clock: setClock(fn) in tests only. const fs = require('fs'); const path = require('path'); const db = require('./db'); let DATA_DIR = null; +let clock = () => Date.now(); +function setClock(fn) { clock = typeof fn === 'function' ? fn : () => Date.now(); } const norm = c => String(c || '').trim().toUpperCase().replace(/[^A-Z0-9_-]/g, '').slice(0, 24); const J = { @@ -27,8 +31,8 @@ const D = { async get(code) { const r = await db.q('SELECT * FROM promo_codes WHERE code=?', [code]); return r[0] ? row(r[0]) : null; }, async list() { return (await db.q('SELECT * FROM promo_codes ORDER BY created DESC')).map(row); }, async put(c) { - await db.q('INSERT INTO promo_codes (code,credits,partner,note,max_uses,expires,active,created,funder) VALUES (?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE funder=VALUES(funder), credits=VALUES(credits), partner=VALUES(partner), note=VALUES(note), max_uses=VALUES(max_uses), expires=VALUES(expires), active=VALUES(active)', - [c.code, c.credits, c.partner || null, c.note || null, c.maxUses || 0, c.expires || 0, c.active ? 1 : 0, c.created || Date.now(), c.funder || null]); + await db.q('INSERT INTO promo_codes (code,credits,partner,note,max_uses,expires,active,created,funder,starts) VALUES (?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE funder=VALUES(funder), credits=VALUES(credits), partner=VALUES(partner), note=VALUES(note), max_uses=VALUES(max_uses), expires=VALUES(expires), active=VALUES(active), starts=VALUES(starts)', + [c.code, c.credits, c.partner || null, c.note || null, c.maxUses || 0, c.expires || 0, c.active ? 1 : 0, c.created || Date.now(), c.funder || null, c.starts || 0]); return this.get(c.code); }, async uses(code) { const r = await db.q('SELECT COUNT(*) n FROM promo_redemptions WHERE code=?', [code]); return Number(r[0].n); }, @@ -36,7 +40,7 @@ const D = { async addRedemption(r) { await db.q('INSERT IGNORE INTO promo_redemptions (code,email,credits,via,ts) VALUES (?,?,?,?,?)', [r.code, r.email, r.credits, r.via, r.ts]); }, async redemptions(code, n) { const rows = code ? await db.q('SELECT * FROM promo_redemptions WHERE code=? ORDER BY ts DESC LIMIT ?', [code, Number(n) || 200]) : await db.q('SELECT * FROM promo_redemptions ORDER BY ts DESC LIMIT ?', [Number(n) || 200]); return rows.map(r => ({ code: r.code, email: r.email, credits: Number(r.credits), via: r.via, ts: Number(r.ts) })); } }; -const row = r => ({ code: r.code, funder: r.funder || null, credits: Number(r.credits), partner: r.partner || '', note: r.note || '', maxUses: Number(r.max_uses) || 0, expires: Number(r.expires) || 0, active: !!Number(r.active), created: Number(r.created) }); +const row = r => ({ code: r.code, funder: r.funder || null, credits: Number(r.credits), partner: r.partner || '', note: r.note || '', maxUses: Number(r.max_uses) || 0, expires: Number(r.expires) || 0, starts: Number(r.starts) || 0, active: !!Number(r.active), created: Number(r.created) }); const impl = () => db.enabled() ? D : J; function init(opts) { DATA_DIR = opts.dataDir; if (!db.enabled()) J.load(); } @@ -44,7 +48,7 @@ async function create(c) { const code = norm(c.code); if (!code || code.length < 3) return { error: 'Code must be 3 to 24 letters or numbers.' }; const credits = Math.floor(Number(c.credits)); if (!(credits > 0) || credits > 100000) return { error: 'Credits must be between 1 and 100,000.' }; const cur = await impl().get(code); - const saved = await impl().put({ code, credits, funder: c.funder ? String(c.funder).toLowerCase() : (cur && cur.funder) || null, partner: String(c.partner || '').slice(0, 80), note: String(c.note || '').slice(0, 200), maxUses: Math.max(0, Math.floor(Number(c.maxUses) || 0)), expires: c.expires ? Number(new Date(c.expires)) || 0 : 0, active: c.active !== false && c.active !== 0 && c.active !== '0', created: cur ? cur.created : Date.now() }); + const saved = await impl().put({ code, credits, funder: c.funder ? String(c.funder).toLowerCase() : (cur && cur.funder) || null, partner: String(c.partner || '').slice(0, 80), note: String(c.note || '').slice(0, 200), maxUses: Math.max(0, Math.floor(Number(c.maxUses) || 0)), expires: c.expires ? Number(new Date(c.expires)) || 0 : 0, starts: c.starts !== undefined ? (c.starts ? Number(new Date(c.starts)) || 0 : 0) : (cur && cur.starts) || 0, active: c.active !== false && c.active !== 0 && c.active !== '0', created: cur ? cur.created : Date.now() }); return { ok: true, code: saved }; } async function setActive(code, active) { const c = await impl().get(norm(code)); if (!c) return { error: 'No such code.' }; await impl().put(Object.assign(c, { active: !!active })); return { ok: true }; } @@ -52,7 +56,8 @@ async function setActive(code, active) { const c = await impl().get(norm(code)); async function check(code, email) { const k = norm(code); if (!k) return { error: 'Enter a promo code.' }; const c = await impl().get(k); if (!c || !c.active) return { error: 'That promo code is not valid.' }; - if (c.expires && Date.now() > c.expires) return { error: 'That promo code has expired.' }; + if (c.starts && clock() < c.starts) return { error: 'That promo code is not open yet.' }; + if (c.expires && clock() > c.expires) return { error: 'That promo code has expired.' }; if (email && await impl().redeemed(k, email)) return { error: 'You already used that promo code.' }; if (c.maxUses && (await impl().uses(k)) >= c.maxUses) return { error: 'That promo code has been fully redeemed.' }; return null; @@ -71,4 +76,4 @@ async function adminView() { return { codes, recent: await impl().redemptions(null, 100) }; } async function byFunder(email) { return (await impl().list()).filter(c => c.funder === String(email || '').toLowerCase()); } -module.exports = { init, create, setActive, check, redeem, adminView, norm, byFunder }; +module.exports = { setClock, init, create, setActive, check, redeem, adminView, norm, byFunder }; diff --git a/public/admin.html b/public/admin.html index e9bb921..5c11614 100644 --- a/public/admin.html +++ b/public/admin.html @@ -548,7 +548,7 @@ - + diff --git a/public/assets/common.js b/public/assets/common.js index fac3bd5..1adc8ac 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -313,3 +313,6 @@ window.IAP = (function () { a.href = '/go/iap?to=' + encodeURIComponent(u.pathname + u.search + u.hash); }, true); })(); + +// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub) +(function () { try { if (window.__nwRibbon || document.querySelector('script[src^="/assets/netweekend.js"]')) return; var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117a'; s.defer = true; s.setAttribute('data-site', 'linkspin'); (document.head || document.documentElement).appendChild(s); } catch (e) {} })(); diff --git a/public/assets/netline.js b/public/assets/netline.js index a4aad65..d107641 100644 --- a/public/assets/netline.js +++ b/public/assets/netline.js @@ -36,3 +36,6 @@ } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run(); })(); + +// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub) +(function () { try { if (window.__nwRibbon || document.querySelector('script[src^="/assets/netweekend.js"]')) return; var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117a'; s.defer = true; s.setAttribute('data-site', 'linkspin'); (document.head || document.documentElement).appendChild(s); } catch (e) {} })(); diff --git a/public/assets/netweekend.js b/public/assets/netweekend.js new file mode 100644 index 0000000..7bbb5d3 --- /dev/null +++ b/public/assets/netweekend.js @@ -0,0 +1,67 @@ +// "Network Weekend" ribbon (Marty 2026-11-17): a thin bar at the top of every network site page while a network event is live. +// Data: /api/network-deals (netdeals.js, from the hub). Switches on and off by this page's own clock at the event's exact +// startsAt / endsAt (US Central midnights), so a cached feed never shows it early or late, and it takes itself down at endsAt on +// a page left open. Shows this site's own deal for today (byDay, Central date) and links to the full deals page. +// The same file lives in every network site. Never RM Circle, never the games. No inline styles (CSP): styles go through CSSOM. +// Test clock: window.__NW_NOW (ms) before this script runs; nothing else. +(function () { + if (window.__nwRibbon) return; window.__nwRibbon = 1; + var tag = document.currentScript; + var meAttr = (tag && tag.getAttribute('data-site')) || ''; + function now() { return typeof window.__NW_NOW === 'number' ? window.__NW_NOW : Date.now(); } + // late November is CST (UTC-6) for every date this ribbon covers + function ctDay(ms) { return new Date(ms - 6 * 3600 * 1000).toISOString().slice(0, 10); } + function closedKey(id, day) { return 'nw.closed.' + id + '.' + day; } + function isClosed(id, day) { try { return window.localStorage.getItem(closedKey(id, day)) === '1'; } catch (e) { return false; } } + function setClosed(id, day) { try { window.localStorage.setItem(closedKey(id, day), '1'); } catch (e) {} } + var bar = null; + function remove() { if (bar && bar.parentNode) bar.parentNode.removeChild(bar); bar = null; } + function paint(body) { + var me = meAttr || (body && body.self) || ''; + var t = now(); + var ev = ((body && body.events) || []).filter(function (e) { return t >= Date.parse(e.startsAt) && t < Date.parse(e.endsAt); })[0]; + if (!ev) { remove(); return false; } + var day = ctDay(t); + if (isClosed(ev.id, day)) { remove(); return true; } + var mine = (ev.deals || []).filter(function (d) { return d.site === me && t < Date.parse(d.endsAt || ev.endsAt); })[0]; + var line = mine ? ((mine.byDay && mine.byDay[day]) || mine.text) : ''; + var label = (ev.days && ev.days[day]) || ''; + var onDealsPage = ev.url && (location.origin + location.pathname) === ev.url; + remove(); + bar = document.createElement('div'); + bar.className = 'nw-ribbon'; bar.setAttribute('role', 'region'); bar.setAttribute('aria-label', ev.name); + bar.style.cssText = 'position:relative;z-index:50;display:flex;flex-wrap:wrap;gap:4px 12px;align-items:center;justify-content:center;padding:8px 40px 8px 16px;' + + 'background:#14161b;color:#f4f1e8;font:600 13.5px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;text-align:center;border-bottom:2px solid #f2c94c'; + // built node by node with CSSOM styles: no style attributes, so a strict CSP (style-src 'self') has nothing to block + function el(tagName, css, text) { var n = document.createElement(tagName); if (css) n.style.cssText = css; if (text) n.textContent = text; return n; } + var head = el('span'); head.appendChild(el('b', 'color:#f2c94c', ev.name)); if (label) head.appendChild(document.createTextNode(' · ' + label)); + bar.appendChild(head); + var body2 = el('span', 'font-weight:500', line || ev.tagline); + if (line && mine && mine.note) { body2.appendChild(document.createTextNode(' ')); body2.appendChild(el('span', 'opacity:.75', mine.note)); } + bar.appendChild(body2); + if (ev.url && !onDealsPage) { var a = el('a', 'color:#f2c94c;text-decoration:underline', 'See every deal'); a.href = ev.url; a.target = '_blank'; a.rel = 'noopener'; bar.appendChild(a); } + var x = el('button', 'position:absolute;right:8px;top:50%;transform:translateY(-50%);background:none;border:0;color:#f4f1e8;font-size:18px;line-height:1;cursor:pointer;padding:4px 8px', '×'); + x.type = 'button'; x.setAttribute('aria-label', 'Hide for today'); bar.appendChild(x); + bar.querySelector('button').addEventListener('click', function () { setClosed(ev.id, day); remove(); }); + document.body.insertBefore(bar, document.body.firstChild); + return true; + } + var feed = null, timer = null; + function schedule() { + clearTimeout(timer); if (!feed) return; + // wake at the next switch moment (start, end, a deal ending, the next Central midnight), at least once a minute + var t = now(), next = t + 60 * 1000; + (feed.events || []).forEach(function (e) { + [e.startsAt, e.endsAt].concat((e.deals || []).map(function (d) { return d.endsAt; })).forEach(function (s) { var x = Date.parse(s); if (x > t && x < next) next = x; }); + }); + timer = setTimeout(function () { if (typeof window.__NW_NOW === 'number') window.__NW_NOW += next - t; paint(feed); schedule(); }, Math.max(250, next - t)); + } + function run() { + fetch('/api/network-deals', { credentials: 'omit' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (b) { + if (!b || !Array.isArray(b.events) || !b.events.length) return; + feed = b; paint(b); schedule(); + }).catch(function () {}); + } + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run(); + window.__nwPaint = function (b) { feed = b; return paint(b); }; // tests +})(); diff --git a/public/contract.html b/public/contract.html index edaacf2..c46ae18 100644 --- a/public/contract.html +++ b/public/contract.html @@ -149,6 +149,6 @@ - + diff --git a/public/conversion-tracking.html b/public/conversion-tracking.html index cb9f306..b85ffa2 100644 --- a/public/conversion-tracking.html +++ b/public/conversion-tracking.html @@ -284,6 +284,6 @@ - + diff --git a/public/credits.html b/public/credits.html index 9580e03..1ce5fd4 100644 --- a/public/credits.html +++ b/public/credits.html @@ -81,7 +81,7 @@ - + diff --git a/public/disclaimer.html b/public/disclaimer.html index 5d1be20..04ed359 100644 --- a/public/disclaimer.html +++ b/public/disclaimer.html @@ -47,6 +47,6 @@ a Crypto Team Build Network property - + diff --git a/public/earning.html b/public/earning.html index 84a4093..9cb1a1c 100644 --- a/public/earning.html +++ b/public/earning.html @@ -69,7 +69,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees.
- - + + diff --git a/public/index.html b/public/index.html index 1d8cce0..b744318 100644 --- a/public/index.html +++ b/public/index.html @@ -225,6 +225,6 @@ - + diff --git a/public/join.html b/public/join.html index 6cb2fa6..d5e68ec 100644 --- a/public/join.html +++ b/public/join.html @@ -106,8 +106,8 @@ body.squeeze .card{position:sticky;top:16px} a Crypto Team Build Network property - + - + diff --git a/public/launch.html b/public/launch.html index 3e00ad1..fe1ed7f 100644 --- a/public/launch.html +++ b/public/launch.html @@ -102,7 +102,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees.
- + diff --git a/public/ledger.html b/public/ledger.html index 8d0a9de..9c1f86b 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -65,8 +65,8 @@ a Crypto Team Build Network property - + - + diff --git a/public/my.html b/public/my.html index f5c74bd..ce5a4b4 100644 --- a/public/my.html +++ b/public/my.html @@ -1015,7 +1015,7 @@ - + diff --git a/public/partners.html b/public/partners.html index fcdec61..0e63090 100644 --- a/public/partners.html +++ b/public/partners.html @@ -131,8 +131,8 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.
- + - + diff --git a/public/plays.html b/public/plays.html index 106e978..7f9d820 100644 --- a/public/plays.html +++ b/public/plays.html @@ -193,7 +193,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.
- + diff --git a/public/privacy.html b/public/privacy.html index d5fc478..4b1ed7c 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -56,6 +56,6 @@ a Crypto Team Build Network property - + diff --git a/public/publishers.html b/public/publishers.html index da23230..64c3d82 100644 --- a/public/publishers.html +++ b/public/publishers.html @@ -289,6 +289,6 @@ - + diff --git a/public/refuel.html b/public/refuel.html index ef73140..c4d7181 100644 --- a/public/refuel.html +++ b/public/refuel.html @@ -281,6 +281,6 @@ - + diff --git a/public/support.html b/public/support.html index c8df511..77b4acd 100644 --- a/public/support.html +++ b/public/support.html @@ -67,8 +67,8 @@ a Crypto Team Build Network property - + - + diff --git a/public/terms.html b/public/terms.html index 7affcec..fae3bb0 100644 --- a/public/terms.html +++ b/public/terms.html @@ -62,6 +62,6 @@ a Crypto Team Build Network property - + diff --git a/public/tx.html b/public/tx.html index 19c9850..7d25828 100644 --- a/public/tx.html +++ b/public/tx.html @@ -35,7 +35,7 @@

← Back to the live ledger · Read the contract review

- + diff --git a/public/wall.html b/public/wall.html index 815cd2f..fc98f2c 100644 --- a/public/wall.html +++ b/public/wall.html @@ -49,7 +49,7 @@ - + diff --git a/public/wallets.html b/public/wallets.html index 9e3fbd9..885ad5e 100644 --- a/public/wallets.html +++ b/public/wallets.html @@ -120,7 +120,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.
- + diff --git a/qa/networkweekend.test.cjs b/qa/networkweekend.test.cjs new file mode 100644 index 0000000..d524a9f --- /dev/null +++ b/qa/networkweekend.test.cjs @@ -0,0 +1,65 @@ +// Network Weekend tests (Marty 2026-11-17): WEEKEND500 promo start/end gate, the date-gated chatbot fact, /api/network-deals. +// Throwaway DATA_DIR, JSON promo store, test clocks only (promos.setClock, a fixed `now` for the fact); no MySQL, no real member. +// Run: node qa/networkweekend.test.cjs +'use strict'; +const fs = require('fs'), os = require('os'), path = require('path'), assert = require('assert'); +process.env.DATABASE_URL = ''; process.env.MYSQL_HOST = ''; +const ROOT = path.join(__dirname, '..'); +const promos = require(path.join(ROOT, 'promos.js')); +const { weekendFact } = require(path.join(ROOT, 'weekendfact.js')); +const netdeals = require(path.join(ROOT, 'netdeals.js')); +let pass = 0, fail = 0; +async function test(name, fn) { try { await fn(); pass++; console.log(' ok ' + name); } catch (e) { fail++; console.log(' FAIL ' + name + '\n ' + String(e && e.stack || e).split('\n').slice(0, 4).join('\n ')); } } +const T = iso => Date.parse(iso); +const OPEN = '2026-11-27T00:00:00-06:00', CLOSE = '2026-12-08T00:00:00-06:00'; + +(async () => { + promos.init({ dataDir: fs.mkdtempSync(path.join(os.tmpdir(), 'nwtest-')) }); + await test('WEEKEND500 is created dormant with starts/expires, maxUses 250', async () => { + const r = await promos.create({ code: 'weekend500', credits: 500, maxUses: 250, starts: OPEN, expires: CLOSE, partner: 'Network Weekend', note: 'IAP $20+ pack bundle' }); + assert.ok(r.ok); assert.strictEqual(r.code.starts, T(OPEN)); assert.strictEqual(r.code.expires, T(CLOSE)); assert.strictEqual(r.code.maxUses, 250); assert.strictEqual(r.code.funder, null); + }); + await test('not open one second before Fri 11-27 00:00 CT, open at it', async () => { + promos.setClock(() => T(OPEN) - 1000); + assert.strictEqual((await promos.redeem('WEEKEND500', 'a@x.test', 'dashboard')).error, 'That promo code is not open yet.'); + promos.setClock(() => T(OPEN)); + const g = await promos.redeem('WEEKEND500', 'a@x.test', 'dashboard'); assert.ok(g.ok); assert.strictEqual(g.credits, 500); + }); + await test('one per account', async () => { + promos.setClock(() => T('2026-11-30T23:59:00-06:00')); + assert.strictEqual((await promos.redeem('WEEKEND500', 'a@x.test', 'dashboard')).error, 'You already used that promo code.'); + assert.ok((await promos.redeem('WEEKEND500', 'b@x.test', 'link')).ok); + }); + await test('expired from Tue 12-08 00:00 CT', async () => { + promos.setClock(() => T(CLOSE) - 1); assert.ok((await promos.redeem('WEEKEND500', 'c@x.test', 'dashboard')).ok); + promos.setClock(() => T(CLOSE) + 1); assert.strictEqual((await promos.redeem('WEEKEND500', 'd@x.test', 'dashboard')).error, 'That promo code has expired.'); + }); + await test('re-saving a code without starts keeps its start time; codes without starts open now', async () => { + const r = await promos.create({ code: 'WEEKEND500', credits: 500, maxUses: 250, expires: CLOSE }); assert.strictEqual(r.code.starts, T(OPEN)); + promos.setClock(() => T('2026-11-20T12:00:00-06:00')); + await promos.create({ code: 'PLAINCODE', credits: 10 }); assert.ok((await promos.redeem('PLAINCODE', 'a@x.test', 'dashboard')).ok); + promos.setClock(null); + }); + await test('maxUses caps redemptions', async () => { + promos.setClock(() => T('2026-11-28T12:00:00-06:00')); + await promos.create({ code: 'CAP2', credits: 5, maxUses: 2, starts: OPEN, expires: CLOSE }); + assert.ok((await promos.redeem('CAP2', 'p@x.test')).ok); assert.ok((await promos.redeem('CAP2', 'q@x.test')).ok); + assert.strictEqual((await promos.redeem('CAP2', 'r@x.test')).error, 'That promo code has been fully redeemed.'); + promos.setClock(null); + }); + await test('chatbot fact: absent before Fri 00:00 CT and from Tue 12-08 00:00 CT; deal list only Fri to Mon', async () => { + assert.strictEqual(weekendFact(T(OPEN) - 1), ''); assert.strictEqual(weekendFact(T(CLOSE)), ''); + netdeals._set({ events: [{ id: 'nw', name: 'Network Weekend', startsAt: new Date(T(OPEN)).toISOString(), endsAt: new Date(T('2026-12-01T00:00:00-06:00')).toISOString(), days: {}, + deals: [{ site: 'iap', name: 'InstantAdPay', text: 'x', byDay: { '2026-11-30': 'Cyber Monday: +30% bonus ad credits on any $20+ pack.' }, note: 'Ad credits buy advertising, not income.' }] }] }); + const mon = weekendFact(T('2026-11-30T09:00:00-06:00')); + assert.match(mon, /LIVE NOW/); assert.match(mon, /Cyber Monday: \+30%/); assert.match(mon, /WEEKEND500/); assert.ok(mon.startsWith('\n')); + const tue = weekendFact(T('2026-12-01T00:00:00-06:00')); assert.ok(!/LIVE NOW/.test(tue)); assert.match(tue, /WEEKEND500/); + assert.ok(!/—/.test(mon + tue), 'no em dashes'); assert.ok(!/up to/i.test(mon + tue)); + }); + await test('GET /api/network-deals answers with self and the cached feed', async () => { + let head = null, body = ''; + netdeals.handle({ headers: {} }, { writeHead: (c, h) => { head = [c, h]; }, end: b => { body = b; } }, 'linkspin'); + assert.strictEqual(head[0], 200); const j = JSON.parse(body); assert.strictEqual(j.self, 'linkspin'); assert.strictEqual(j.events.length, 1); + }); + console.log(`\n${pass} passed, ${fail} failed`); process.exit(fail ? 1 : 0); +})(); diff --git a/releases.js b/releases.js index a586da5..0408dab 100644 --- a/releases.js +++ b/releases.js @@ -66,7 +66,7 @@ function renderPage() { h += '

Release notes

'; h += v.notes.length ? v.notes.map(n => '

' + esc(n.title) + n.tags.map(tagChip).join('') + '

' + fmt(n.date) + '

' + bodyHtml(n.body) + '
').join('') : '

No notes yet.

'; h += '

Suggestions and bug reports: the chat bubble on any page, or the LinkSpin Telegram group.

'; - h += ''; + h += ''; return h; } module.exports = { init, notes, roadmap, saveNote, saveRoadmap, remove, publicView, renderPage, bodyHtml, TAGS, STATUSES }; diff --git a/server.js b/server.js index 6503d84..de9820b 100644 --- a/server.js +++ b/server.js @@ -11,6 +11,7 @@ const fs = require('fs'); const path = require('path'); const crypto = require('crypto'); const netsites = require('./netsites'); // footer network list from the hub (2026-11-14 trust pack) +const netdeals = require('./netdeals'); // Network Weekend ribbon feed from the hub (2026-11-17) const sendy = require('./sendy'); const { URL } = require('url'); const chain = require('./chain'); @@ -1681,6 +1682,7 @@ const server = http.createServer(async (req, res) => { // -- public API if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res); + if (p === '/api/network-deals' && req.method === 'GET') return netdeals.handle(req, res, netsites.selfId(req) || 'linkspin'); if (p === '/api/config' && req.method === 'GET') { const c = chain.getConfig(); // public copy of the site settings: never anything that looks like a credential @@ -4589,7 +4591,7 @@ const server = http.createServer(async (req, res) => { + '' + '
' + esc(label) + ' badge for @' + esc(un) + '

@' + esc(un) + ' unlocked ' + label + '

' + esc(sub.charAt(0).toUpperCase() + sub.slice(1)) + '. On LinkSpin every ad package that sells pays the sponsor in the same transaction, straight to their wallet, on-chain.

' + 'Join @' + esc(un) + '\u2019s line free

Advertising with a performance referral program. Not an investment; no income is guaranteed.

' - + ''; + + ''; res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' })); return res.end(html); } diff --git a/weekendfact.js b/weekendfact.js new file mode 100644 index 0000000..d3215b2 --- /dev/null +++ b/weekendfact.js @@ -0,0 +1,26 @@ +// NETWORK WEEKEND chatbot fact (Marty 2026-11-17): date-gated, present only while it applies. +// Fri 11-27 00:00 CT to Tue 12-01 00:00 CT: the event is live; deal lines come from the hub feed (netdeals.js) by the Central day. +// Tue 12-01 00:00 CT to Tue 12-08 00:00 CT: only the WEEKEND500 code fact (Monday buyers get a week to redeem). +// CHATBOT_NOW (ISO) = test clock, tests only. +const NW = { start: Date.parse('2026-11-27T00:00:00-06:00'), end: Date.parse('2026-12-01T00:00:00-06:00'), codeEnd: Date.parse('2026-12-08T00:00:00-06:00') }; +const NL = String.fromCharCode(10); +function nwNow() { const t = Date.parse(process.env.CHATBOT_NOW || ''); return Number.isNaN(t) ? Date.now() : t; } +function lines(now) { + const t = now === undefined ? nwNow() : now; + if (t < NW.start || t >= NW.codeEnd) return []; + const code = '- PROMO CODE WEEKEND500 (Network Weekend 2026): 500 LinkSpin ad credits (earned-grade), one per account, new and existing accounts. It is handed out on the InstantAdPay purchase notice for any InstantAdPay pack of $20 or more bought Fri 11-27 to Mon 11-30 (midnight to midnight Central). Redeem it in the promo code box on the LinkSpin dashboard until Tue 12-08 midnight Central. It is not a referral reward and pays nobody. Ad credits buy advertising, not income.'; + if (t >= NW.end) return [code]; + const out = ['- NETWORK WEEKEND (Black Friday to Cyber Monday 2026, LIVE NOW): Fri 11-27 to Mon 11-30, midnight to midnight Central; every deal ends Tue 12-01 00:00 Central (the InstantAdPay Game Pass bonus days run to Thu 12-03 midnight Central). All deals: https://instantadpay.com/weekend. LinkSpin prices and payouts are unchanged this weekend; the LinkSpin part is the WEEKEND500 code. Never quote earnings or income. Today\'s network deals:']; + try { + const ev = (require('./netdeals').current().events || []).find(e => t >= Date.parse(e.startsAt) && t < Date.parse(e.endsAt)); + if (ev) { + const day = new Date(t - 6 * 3600 * 1000).toISOString().slice(0, 10); + for (const d of ev.deals) if (t < Date.parse(d.endsAt || ev.endsAt)) out.push(' * ' + d.name + ': ' + ((d.byDay && d.byDay[day]) || d.text) + (d.note ? ' ' + d.note : '')); + } + } catch (e) {} + out.push(code); + return out; +} +// '' outside the dates, else a newline then the fact lines (it follows ${launchFact()} on the same template line) +function weekendFact(now) { const l = lines(now); return l.length ? NL + l.join(NL) : ''; } +module.exports = { weekendFact, NW };