/friday: status script as a file (CSP blocks inline), and the page in the real sitemap

The first deploy shipped the status strip stuck on Checking: the site CSP has no
unsafe-inline, so the inline script never ran. Moved to /assets/friday.js. The
sitemap list lives in blog.js, not the pages list I edited in server.js; /friday
is in it now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-25 06:29:09 -05:00
parent 5b694c8ab4
commit 18aabb3cb2
3 changed files with 39 additions and 37 deletions
+37
View File
@@ -0,0 +1,37 @@
/* /friday status strip (Marty, 2026-09-25). External file on purpose: the site's CSP blocks
inline scripts, which is how the first deploy shipped a strip stuck on "Checking". */
(function () {
var el = document.getElementById('frState');
if (!el) return;
function n(x) { return Number(x || 0).toLocaleString('en-US'); }
// the minute (Central) when the next Friday starts, found by scanning rather than assumed,
// so a daylight-saving change cannot put the countdown an hour out
function startsAt(dayKey) {
var now = Date.now();
for (var m = 0; m < 8 * 1440; m++) {
var t = now + m * 60000;
var d = new Date(t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
if (d === dayKey) return t;
}
return null;
}
function render(f) {
if (!f || !f.on) { el.innerHTML = '<span class="fr-tag">Paused</span><span>Five Dollar Friday is not running right now. Join free and you will hear when it is back.</span>'; return; }
if (f.live) {
var t = f.today || {};
el.className = 'fr-state live';
el.innerHTML = '<span class="fr-tag">Live now</span><span><b>It is Five Dollar Friday.</b> Bonus runs until midnight Central.</span>'
+ '<span><span class="fr-num">' + n(t.packs) + '</span> pack' + (t.packs === 1 ? '' : 's') + ' so far today</span>'
+ '<span><span class="fr-num">' + n(t.bonusCredits) + '</span> bonus credits issued</span>';
return;
}
var at = f.nextFriday ? startsAt(f.nextFriday) : null;
var left = at ? Math.max(0, at - Date.now()) : 0;
var hrs = Math.floor(left / 3600000), mins = Math.floor((left % 3600000) / 60000), days = Math.floor(hrs / 24);
var when = at ? (days >= 1 ? days + ' day' + (days === 1 ? '' : 's') + ' ' + (hrs % 24) + 'h' : hrs + 'h ' + mins + 'm') : '';
el.className = 'fr-state';
el.innerHTML = '<span class="fr-tag">Next</span><span><b>Next Five Dollar Friday: ' + (f.nextLabel || f.nextFriday || 'soon') + '.</b> Starts at midnight Central' + (when ? ', in ' + when : '') + '.</span>'
+ '<span>Join now so your account is ready before it starts.</span>';
}
fetch('/api/friday').then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; }).then(render);
})();
+1 -36
View File
@@ -69,42 +69,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script>
(function () {
var el = document.getElementById('frState');
function n(x) { return Number(x || 0).toLocaleString('en-US'); }
// the minute (Central) when the next Friday starts, found by scanning rather than assumed,
// so daylight-saving changes cannot put the countdown an hour out
function startsAt(dayKey) {
var now = Date.now();
for (var m = 0; m < 8 * 1440; m++) {
var t = now + m * 60000;
var d = new Date(t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
if (d === dayKey) return t;
}
return null;
}
function render(f) {
if (!f || !f.on) { el.innerHTML = '<span class="fr-tag">Paused</span><span>Five Dollar Friday is not running right now. Join free and you will hear when it is back.</span>'; return; }
if (f.live) {
var t = f.today || {};
el.className = 'fr-state live';
el.innerHTML = '<span class="fr-tag">Live now</span><span><b>It is Five Dollar Friday.</b> Bonus runs until midnight Central.</span>'
+ '<span><span class="fr-num">' + n(t.packs) + '</span> pack' + (t.packs === 1 ? '' : 's') + ' so far today</span>'
+ '<span><span class="fr-num">' + n(t.bonusCredits) + '</span> bonus credits issued</span>';
return;
}
var at = f.nextFriday ? startsAt(f.nextFriday) : null;
var left = at ? Math.max(0, at - Date.now()) : 0;
var hrs = Math.floor(left / 3600000), mins = Math.floor((left % 3600000) / 60000), days = Math.floor(hrs / 24);
var when = at ? (days >= 1 ? days + ' day' + (days === 1 ? '' : 's') + ' ' + (hrs % 24) + 'h' : hrs + 'h ' + mins + 'm') : '';
el.className = 'fr-state';
el.innerHTML = '<span class="fr-tag">Next</span><span><b>Next Five Dollar Friday: ' + (f.nextLabel || f.nextFriday || 'soon') + '.</b> Starts at midnight Central' + (when ? ', in ' + when : '') + '.</span>'
+ '<span>Join now so your account is ready before it starts.</span>';
}
fetch('/api/friday').then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; }).then(render);
})();
</script>
<script src="/assets/friday.js?v=20260925a"></script>
<script src="/assets/common.js?v=20260923b"></script>
</body>
</html>