Files
martbost 218bb10145 Network Weekend 2026, built dormant (Marty 2026-11-17): Black Friday to Cyber Monday, midnight to midnight Central
- promodays.js: reusable date-to-percent bonus map (setting promoDays, kill switch promoDaysOn), once per tx via marks (MySQL):
  Fri 11-27 +40% $5+, Sat/Sun +20% $5+, Mon 11-30 +30% $20+. A mapped Friday is paid by friday.js at max(fridayBonusPct, day pct),
  one bonus per tx, Game Pass Friday perk intact; Five Dollar Friday +20% resumes 12-04 with no hand edits.
- friday.js: Thanksgiving Thursday 18:00 CT notice + email carry the Black Friday copy (one message); Black Friday kickoff and
  wrap-up copy; /api/friday reports the day's real pct and name; IAP_TEST_NOW test clock (ignored in production).
- Weekend Starter Bundle ($20+ in the window: LinkSpin code WEEKEND500 on a purchase notice) and Builder Bundle ($100+: notice +
  GET /api/network/weekend-builders for DownlineHydra, X-Weekend-Key = env WEEKEND_BUNDLE_KEY, constant-time compare).
- promos.js: promo_codes.starts (dormant-until gate) for code NETWORKWEEKEND.
- gamepass.js: tier passes paid by a package Fri 11-27 00:00 CT to Fri 12-04 00:00 CT get Explorer/Champion +15 days, Legend +60.
- /weekend deals page (assets/weekend.js), Home strip + Overview card (assets/weekend-card.js), network ribbon (netdeals.js +
  assets/netweekend.js via common.js and netline.js), chatbot fact + answer date-gated.
- Share hosts: /weekend, /friday and other page names are pages, not usernames (email links use instantadpay.link: instantadpay.com
  is still on the Spamhaus DBL, checked 11-17).
- welcome.js says the day's real pct; common.js/netline.js/welcome.js ?v=20261117nw.
- Tests: qa/promodays.test.cjs (12) + qa/weekend.e2e.mjs (18) at test clocks; bash qa/run.sh weekend; member walk clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 07:59:55 -06:00

54 lines
4.9 KiB
JavaScript

/* /weekend, the Network Weekend deals page (Marty 2026-11-17). External file on purpose: the site's CSP blocks inline scripts.
Data: /api/promodays (InstantAdPay's own days, promodays.js) and /api/network-deals (every site's deal, from the hub).
Switches by the page's own clock at the exact Central midnights; before Thanksgiving Thursday both feeds are empty, so the page
says only that the weekend is coming. Test clock: window.__NW_NOW (ms). */
(function () {
var now = function () { return typeof window.__NW_NOW === 'number' ? window.__NW_NOW : Date.now(); };
var ctDay = function (ms) { return new Date(ms - 6 * 3600 * 1000).toISOString().slice(0, 10); };
var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); };
var usd = function (n) { return '$' + (Number(n) % 1 ? Number(n).toFixed(2) : Number(n)); };
var label = function (k) { var p = k.split('-').map(Number); return new Date(Date.UTC(p[0], p[1] - 1, p[2], 12)).toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'UTC' }); };
var stateEl = document.getElementById('nwState'), daysEl = document.getElementById('nwDays'), dealsEl = document.getElementById('nwDeals');
if (!stateEl) return;
// carry ?ref= onto the join button (the page is a member promo tool, like /friday)
try { var ref = new URLSearchParams(location.search).get('ref'); if (ref && /^[A-Za-z0-9_.-]{1,40}$/.test(ref)) document.getElementById('nwJoin').href = '/join?v=weekend&ref=' + encodeURIComponent(ref); } catch (e) {}
function renderIap(v) {
var t = now(), s = Date.parse(v.startsAt), e = Date.parse(v.endsAt), today = ctDay(t);
if (!v.on || !v.published) {
stateEl.className = 'nw-state'; stateEl.innerHTML = '<span class="nw-tag">Coming</span><span><b>Network Weekend: Black Friday to Cyber Monday.</b> The deals open here on Thanksgiving.</span>';
daysEl.innerHTML = ''; return;
}
if (t >= s && t < e) {
var d = v.today || {};
stateEl.className = 'nw-state live';
stateEl.innerHTML = '<span class="nw-tag">Live now</span><span><b>It is ' + esc((d.name || 'Network Weekend').replace(/^Network Weekend /, '')) + '.</b> +' + esc(d.pct) + '% bonus ad credits on any ' + usd(d.minUsd) + '+ InstantAdPay pack until midnight Central.</span>'
+ (d.stats ? '<span><b>' + Number(d.stats.packs || 0).toLocaleString('en-US') + '</b> pack' + (d.stats.packs === 1 ? '' : 's') + ' so far today</span>' : '');
} else if (t < s) {
var left = s - t, h = Math.floor(left / 3600000), m = Math.floor((left % 3600000) / 60000);
stateEl.className = 'nw-state'; stateEl.innerHTML = '<span class="nw-tag">Tonight</span><span><b>Network Weekend starts at midnight Central</b>, in ' + h + 'h ' + m + 'm.</span><span>Join now so your account is ready.</span>';
} else {
stateEl.className = 'nw-state'; stateEl.innerHTML = '<span class="nw-tag">Ended</span><span><b>Network Weekend is over.</b> Thank you for building with us. Five Dollar Friday is back every Friday.</span>';
}
daysEl.innerHTML = (v.days || []).map(function (x) {
return '<div class="nw-day' + (x.day === today && t >= s && t < e ? ' today' : '') + '"><div class="n">' + esc(label(x.day)) + '</div><h3>+' + esc(x.pct) + '% on ' + usd(x.minUsd) + '+</h3><p>' + esc(x.name) + ': bonus ad credits on any InstantAdPay pack of ' + usd(x.minUsd) + ' or more, midnight to midnight Central.</p></div>';
}).join('');
}
function renderDeals(b) {
var t = now(), today = ctDay(t);
var ev = ((b && b.events) || []).filter(function (e) { return t >= Date.parse(e.startsAt) - 86400000 && t < Date.parse(e.endsAt); })[0];
if (!ev) { if (!((b && b.events) || []).length) return; dealsEl.innerHTML = '<p class="muted">Network Weekend has ended.</p>'; return; }
var deals = (ev.deals || []).filter(function (d) { return t < Date.parse(d.endsAt || ev.endsAt); });
dealsEl.innerHTML = deals.map(function (d) {
var text = (d.byDay && d.byDay[today]) || d.text;
return '<div class="nw-deal"><h3>' + esc(d.name) + '</h3><p>' + esc(text) + '</p>' + (d.note ? '<p class="note">' + esc(d.note) + '</p>' : '')
+ (d.url ? '<a class="go" href="' + esc(d.url) + '"' + (/instantadpay\.com/.test(d.url) ? '' : ' target="_blank" rel="noopener"') + '>' + (/instantadpay\.com\/weekend/.test(d.url) ? 'Buy on InstantAdPay' : 'Open ' + esc(d.name)) + '</a>' : '') + '</div>';
}).join('');
dealsEl.querySelectorAll('a.go').forEach(function (a) { if (/instantadpay\.com\/weekend/.test(a.href)) a.href = '/my#buy'; });
}
function load() {
fetch('/api/promodays').then(function (r) { return r.ok ? r.json() : null; }).then(function (v) { if (v) renderIap(v); }).catch(function () {});
fetch('/api/network-deals').then(function (r) { return r.ok ? r.json() : null; }).then(renderDeals).catch(function () {});
}
load(); setInterval(load, 60000);
})();