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 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-03 09:32:29 -05:00
parent 8f61d11d43
commit 737ed28e1d
3 changed files with 39 additions and 7 deletions
+7 -6
View File
@@ -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 = '&times;';
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
+1 -1
View File
@@ -1129,7 +1129,7 @@
<script src="/assets/common.js?v=20260929b"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261002ref"></script>
<script src="/assets/my.js?v=20261002sdp"></script>
<script src="/assets/my.js?v=20261003snz"></script>
<script src="/assets/chat.js?v=20260907l"></script>
</body>
</html>
+31
View File
@@ -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')