Compare commits
No commits in common. "42244fe14aea2a3e56d76fe54aaf929c089eff2d" and "38b6dccd4ae3af23cbff30608ee2490ef868ee97" have entirely different histories.
42244fe14a
...
38b6dccd4a
@ -89,7 +89,6 @@ class TopbarComponent {
|
|||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let resetTimer = null;
|
let resetTimer = null;
|
||||||
let currentToast = null; // single rolling toast — updated in place
|
|
||||||
|
|
||||||
document.addEventListener('click', (e) => {
|
document.addEventListener('click', (e) => {
|
||||||
const logo = e.target.closest('.libreportal-logo');
|
const logo = e.target.closest('.libreportal-logo');
|
||||||
@ -97,10 +96,7 @@ class TopbarComponent {
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (resetTimer) clearTimeout(resetTimer);
|
if (resetTimer) clearTimeout(resetTimer);
|
||||||
resetTimer = setTimeout(() => {
|
resetTimer = setTimeout(() => { count = 0; }, RESET_AFTER_MS);
|
||||||
count = 0;
|
|
||||||
currentToast = null; // next sequence starts a fresh toast
|
|
||||||
}, RESET_AFTER_MS);
|
|
||||||
|
|
||||||
const remaining = TARGET_CLICKS - count;
|
const remaining = TARGET_CLICKS - count;
|
||||||
const devOn = (window.systemConfigs?.CFG_DEV_MODE === 'true');
|
const devOn = (window.systemConfigs?.CFG_DEV_MODE === 'true');
|
||||||
@ -108,22 +104,10 @@ class TopbarComponent {
|
|||||||
const noun = devOn ? 'developer mode' : 'a developer';
|
const noun = devOn ? 'developer mode' : 'a developer';
|
||||||
|
|
||||||
if (remaining > 0 && count >= TOAST_FROM) {
|
if (remaining > 0 && count >= TOAST_FROM) {
|
||||||
const msg = `You are ${remaining} click${remaining === 1 ? '' : 's'} away from ${verb} ${noun}.`;
|
this._devToast(`You are ${remaining} click${remaining === 1 ? '' : 's'} away from ${verb} ${noun}.`, 'info');
|
||||||
// If the rolling toast is still in the DOM, mutate its message
|
|
||||||
// text in place instead of stacking another notification. When
|
|
||||||
// it's been auto-removed (10s lifetime) we open a fresh one.
|
|
||||||
const msgEl = currentToast && currentToast.parentElement
|
|
||||||
? currentToast.querySelector('.notification-message')
|
|
||||||
: null;
|
|
||||||
if (msgEl) {
|
|
||||||
msgEl.innerHTML = msg;
|
|
||||||
} else {
|
|
||||||
currentToast = this._devToast(msg, 'info');
|
|
||||||
}
|
|
||||||
} else if (remaining === 0) {
|
} else if (remaining === 0) {
|
||||||
count = 0;
|
count = 0;
|
||||||
clearTimeout(resetTimer);
|
clearTimeout(resetTimer);
|
||||||
currentToast = null;
|
|
||||||
this._setDevMode(!devOn);
|
this._setDevMode(!devOn);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -176,18 +160,15 @@ class TopbarComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toast helper — uses the project's notification system if loaded, else
|
// Toast helper — uses the project's notification system if loaded, else
|
||||||
// a quiet console echo so dev-mode UX never blocks page render. Returns
|
// a quiet console echo so dev-mode UX never blocks page render.
|
||||||
// the notification DOM element when the real system is available, so
|
|
||||||
// callers (the easter-egg countdown) can mutate the message in place
|
|
||||||
// instead of stacking new toasts on each click.
|
|
||||||
_devToast(message, kind = 'info') {
|
_devToast(message, kind = 'info') {
|
||||||
if (window.notificationSystem?.show) {
|
if (window.notificationSystem?.show) {
|
||||||
return window.notificationSystem.show(message, kind);
|
window.notificationSystem.show(message, kind);
|
||||||
} else if (typeof window.showNotification === 'function') {
|
} else if (typeof window.showNotification === 'function') {
|
||||||
return window.showNotification(message, kind);
|
window.showNotification(message, kind);
|
||||||
}
|
} else {
|
||||||
console.log(`[dev-mode] ${message}`);
|
console.log(`[dev-mode] ${message}`);
|
||||||
return null;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flip CFG_DEV_MODE via the standard config-update task (same path the
|
// Flip CFG_DEV_MODE via the standard config-update task (same path the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user