-
🌐 async-utils.jsWeb, 3.69 kB⬇
-
🌐 auth-storage.jsWeb, 735 B⬇
-
🌐 chat-helpers.jsWeb, 8.85 kB⬇
-
🌐 chat-renderer.jsWeb, 70.00 kB⬇
-
🌐 code-overlay.jsWeb, 21.77 kB⬇
-
🌐 confirm-dialog.jsWeb, 3.17 kB⬇
-
🌐 conversation-format-utils.jsWeb, 21.51 kB⬇
-
🌐 diagram-overlay.jsWeb, 7.93 kB⬇
-
🌐 dialog.jsWeb, 2.50 kB⬇
-
🌐 dom-utils.jsWeb, 8.33 kB⬇
-
🌐 drag-reorder.jsWeb, 4.82 kB⬇
-
🌐 elements.jsWeb, 11.06 kB⬇
-
🌐 export-utils.jsWeb, 1.53 kB⬇
-
🌐 format-utils.jsWeb, 29.60 kB⬇
-
🌐 history-navigation.jsWeb, 1.95 kB⬇
-
🌐 hljs-yaml.jsWeb, 5.07 kB⬇
-
🌐 inline-format.jsWeb, 7.35 kB⬇
-
🌐 instant-answer.jsWeb, 19.82 kB⬇
-
🌐 interactive-tools.jsWeb, 38.77 kB⬇
-
🌐 mermaid-fixes.jsWeb, 4.60 kB⬇
-
🌐 mermaid-render.jsWeb, 5.10 kB⬇
-
🌐 mermaid.jsWeb, 195 B⬇
-
🌐 migrations.jsWeb, 12.11 kB⬇
-
🌐 multi-choice-dialog.jsWeb, 1.33 kB⬇
-
🌐 notification-stack.jsWeb, 2.50 kB⬇
-
🌐 options-manager.jsWeb, 45.56 kB⬇
-
🌐 overlay-utils.jsWeb, 4.14 kB⬇
-
🌐 pdf-export.jsWeb, 23.59 kB⬇
-
🌐 pinch-zoom.jsWeb, 3.21 kB⬇
-
🌐 plugin-dialog.jsWeb, 2.17 kB⬇
-
🌐 read-aloud.jsWeb, 33.84 kB⬇
-
🌐 response-pipeline.jsWeb, 55.19 kB⬇
-
🌐 scratchpad-editor.jsWeb, 8.64 kB⬇
-
🌐 scratchpad-export.jsWeb, 3.56 kB⬇
-
🌐 scrollbars.jsWeb, 3.12 kB⬇
-
🌐 selection-manager.jsWeb, 3.76 kB⬇
-
🌐 settings-utils.jsWeb, 31.08 kB⬇
-
🌐 share.jsWeb, 10.75 kB⬇
-
🌐 side-drawer.jsWeb, 9.37 kB⬇
-
🌐 speech-text.jsWeb, 6.60 kB⬇
-
🌐 swipe-navigation.jsWeb, 6.16 kB⬇
-
🌐 table-overlay.jsWeb, 8.10 kB⬇
-
🌐 theme-utils.jsWeb, 8.34 kB⬇
-
🌐 thinking-panel-base.jsWeb, 14.88 kB⬇
-
🌐 ui-sets.jsWeb, 1.00 kB⬇
-
🌐 version-overlay.jsWeb, 4.63 kB⬇
/**
* Minimal notification stack anchored to the bottom center of the screen, above
* the footer. Each notification shows for 1.5 seconds and is then removed.
* Items are tracked in a Map so multiple notifications stack up and clear
* independently; the footer bell is visible while at least one is displayed.
*/
const DISPLAY_MS = 1500;
const FADE_MS = 200;
/** @type {Map<string, {el: HTMLElement, timer: number}>} */
const items = new Map();
let nextId = 1;
/**
* Shows a notification in the stack; it is removed automatically after 1.5 seconds.
* @param {string} text - Notification text.
*/
export function showNotification(text) {
const container = ensureContainer();
const bell = ensureBell();
const id = `notification-${nextId++}`;
const el = document.createElement('div');
el.className = 'div-notification-item';
el.textContent = text;
container.appendChild(el);
const timer = window.setTimeout(() => removeNotification(id), DISPLAY_MS);
items.set(id, { el: el, timer: timer });
bell.hidden = false;
}
/**
* Removes one notification and updates the footer bell.
* @param {string} id - Notification id.
*/
function removeNotification(id) {
const item = items.get(id);
if (!item) {
return;
}
window.clearTimeout(item.timer);
items.delete(id);
const bell = ensureBell();
bell.hidden = items.size === 0;
item.el.classList.add('is-fading-out');
window.setTimeout(() => item.el.remove(), FADE_MS);
}
/**
* Returns the notification stack container, creating it on first use and
* re-anchoring it above the footer.
* @returns {HTMLElement} The stack container.
*/
function ensureContainer() {
let container = document.getElementById('id-notification-stack');
if (!container) {
container = document.createElement('div');
container.id = 'id-notification-stack';
container.className = 'div-notification-stack';
document.body.appendChild(container);
}
const footer = document.querySelector('.div-structure-footer');
container.style.bottom = footer ? (footer.offsetHeight + 12) + 'px' : '2em';
return container;
}
/**
* Returns the footer bell element, creating it if the footer lacks one.
* @returns {HTMLElement} The bell element.
*/
function ensureBell() {
let bell = document.getElementById('id-span-footer-bell');
if (!bell) {
bell = document.createElement('span');
bell.id = 'id-span-footer-bell';
bell.className = 'span-footer-bell as-icon';
bell.textContent = '🔔';
bell.hidden = true;
document.querySelector('.div-structure-footer .is-center')?.appendChild(bell);
}
return bell;
}
notification-stack.js
×
Type: Web, text/plain
2.50 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File
Type: Web, text/plain
2.50 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File