/* /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 { '&': '&', '<': '<', '>': '>', '"': '"' }[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 = 'ComingNetwork Weekend: Black Friday to Cyber Monday. The deals open here on Thanksgiving.'; daysEl.innerHTML = ''; return; } if (t >= s && t < e) { var d = v.today || {}; stateEl.className = 'nw-state live'; stateEl.innerHTML = 'Live nowIt is ' + esc((d.name || 'Network Weekend').replace(/^Network Weekend /, '')) + '. +' + esc(d.pct) + '% bonus ad credits on any ' + usd(d.minUsd) + '+ InstantAdPay pack until midnight Central.' + (d.stats ? '' + Number(d.stats.packs || 0).toLocaleString('en-US') + ' pack' + (d.stats.packs === 1 ? '' : 's') + ' so far today' : ''); } 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 = 'TonightNetwork Weekend starts at midnight Central, in ' + h + 'h ' + m + 'm.Join now so your account is ready.'; } else { stateEl.className = 'nw-state'; stateEl.innerHTML = 'EndedNetwork Weekend is over. Thank you for building with us. Five Dollar Friday is back every Friday.'; } daysEl.innerHTML = (v.days || []).map(function (x) { return '
' + esc(label(x.day)) + '

+' + esc(x.pct) + '% on ' + usd(x.minUsd) + '+

' + esc(x.name) + ': bonus ad credits on any InstantAdPay pack of ' + usd(x.minUsd) + ' or more, midnight to midnight Central.

'; }).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 = '

Network Weekend has ended.

'; 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 '

' + esc(d.name) + '

' + esc(text) + '

' + (d.note ? '

' + esc(d.note) + '

' : '') + (d.url ? '' + (/instantadpay\.com\/weekend/.test(d.url) ? 'Buy on InstantAdPay' : 'Open ' + esc(d.name)) + '' : '') + '
'; }).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); })();