25 lines
695 B
JavaScript
25 lines
695 B
JavaScript
/// Tiny DOM helpers shared across modules.
|
|
|
|
export function el(id) {
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
export function escapeHtml(text) {
|
|
if (text === null || text === undefined) return "";
|
|
return String(text)
|
|
.replaceAll("&", "&")
|
|
.replaceAll("<", "<")
|
|
.replaceAll(">", ">");
|
|
}
|
|
|
|
export function setBanner(container, message, level = "info") {
|
|
if (!container) return;
|
|
const existing = container.querySelector(".ops-banner");
|
|
if (existing) existing.remove();
|
|
const div = document.createElement("div");
|
|
div.className = `ops-banner banner-${level}`;
|
|
div.textContent = message;
|
|
container.prepend(div);
|
|
window.setTimeout(() => div.remove(), 4000);
|
|
}
|