From 737ed28e1dc8ed3626ed4a45a6658a45af251852 Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 3 Oct 2026 09:32:29 -0500 Subject: [PATCH] Overview announcement cards: the x hides a card for 24 hours (was until next sign-in, so they stacked up at every login) Co-Authored-By: Claude Opus 5.5 --- public/assets/my.js | 13 +++++++------ public/my.html | 2 +- tools/patch_card_snooze.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 tools/patch_card_snooze.py diff --git a/public/assets/my.js b/public/assets/my.js index 4bfbd28..a3f7f4d 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -1596,16 +1596,17 @@ })); } // The announcement cards at the top of the Overview are repeated on a timer, so a member who has read - // one can put it away: dismissed for the rest of this browser session, back at the next sign-in - // (Marty, 2026-09-22) so a message nobody has acted on is never gone for good. - function cardHidden(key) { try { return sessionStorage.getItem('iap-hide-' + key) === '1'; } catch (e) { return false; } } + // one can put it away: dismissed for 24 hours on this browser (Marty, 2026-10-03; it used to come back + // at every sign-in and the cards stacked up), then it shows again so it is never gone for good. + const CARD_SNOOZE_MS = 24 * 3600 * 1000; + function cardHidden(key) { try { const t = Number(localStorage.getItem('iap-hide-' + key)); return t > 0 && Date.now() - t < CARD_SNOOZE_MS; } catch (e) { return false; } } function cardDismiss(card, key) { if (!card || card.querySelector('.card-x')) return; const x = document.createElement('button'); x.type = 'button'; x.className = 'card-x'; x.innerHTML = '×'; - x.title = 'Hide this until my next sign-in'; - x.setAttribute('aria-label', 'Hide this message until my next sign-in'); - x.addEventListener('click', () => { try { sessionStorage.setItem('iap-hide-' + key, '1'); } catch (e) {} card.hidden = true; }); + x.title = 'Hide this for 24 hours'; + x.setAttribute('aria-label', 'Hide this message for 24 hours'); + x.addEventListener('click', () => { try { localStorage.setItem('iap-hide-' + key, String(Date.now())); } catch (e) {} card.hidden = true; }); (card.querySelector('.card-head') || card).appendChild(x); } // Five Dollar Friday card on the Overview: the live wave on Fridays, the date the rest of the week diff --git a/public/my.html b/public/my.html index 444c3f1..bffc157 100644 --- a/public/my.html +++ b/public/my.html @@ -1129,7 +1129,7 @@ - + diff --git a/tools/patch_card_snooze.py b/tools/patch_card_snooze.py new file mode 100644 index 0000000..f37b34e --- /dev/null +++ b/tools/patch_card_snooze.py @@ -0,0 +1,31 @@ +# Overview announcement cards: the x now hides a card for 24 hours on this browser instead of +# "until my next sign-in" (Marty, 2026-10-03: they stack up and greet him at every login). +ROOT = 'D:/Projects/HighRisk/onchain-ad-membership/site/' +def edit(path, pairs): + b = open(ROOT + path, 'rb').read(); crlf = b.count(b'\r\n') > b.count(b'\n') // 2 + s = b.decode('utf-8').replace('\r\n', '\n') + for a, r in pairs: + if s.count(a) != 1: raise SystemExit('%s anchor %d: %s' % (path, s.count(a), a[:70])) + s = s.replace(a, r) + if crlf: s = s.replace('\n', '\r\n') + open(ROOT + path, 'wb').write(s.encode('utf-8')); print('patched', path) + +edit('public/assets/my.js', [ + (" // The announcement cards at the top of the Overview are repeated on a timer, so a member who has read\n" + " // one can put it away: dismissed for the rest of this browser session, back at the next sign-in\n" + " // (Marty, 2026-09-22) so a message nobody has acted on is never gone for good.\n" + " function cardHidden(key) { try { return sessionStorage.getItem('iap-hide-' + key) === '1'; } catch (e) { return false; } }\n", + " // The announcement cards at the top of the Overview are repeated on a timer, so a member who has read\n" + " // one can put it away: dismissed for 24 hours on this browser (Marty, 2026-10-03; it used to come back\n" + " // at every sign-in and the cards stacked up), then it shows again so it is never gone for good.\n" + " const CARD_SNOOZE_MS = 24 * 3600 * 1000;\n" + " function cardHidden(key) { try { const t = Number(localStorage.getItem('iap-hide-' + key)); return t > 0 && Date.now() - t < CARD_SNOOZE_MS; } catch (e) { return false; } }\n"), + (" x.title = 'Hide this until my next sign-in';\n" + " x.setAttribute('aria-label', 'Hide this message until my next sign-in');\n" + " x.addEventListener('click', () => { try { sessionStorage.setItem('iap-hide-' + key, '1'); } catch (e) {} card.hidden = true; });\n", + " x.title = 'Hide this for 24 hours';\n" + " x.setAttribute('aria-label', 'Hide this message for 24 hours');\n" + " x.addEventListener('click', () => { try { localStorage.setItem('iap-hide-' + key, String(Date.now())); } catch (e) {} card.hidden = true; });\n"), +]) +edit('public/my.html', [('/assets/my.js?v=20261002sdp', '/assets/my.js?v=20261003snz')]) +print('ok')