32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
// ── Error modal ───────────────────────────────────────────────────────────────
|
|
//
|
|
// A simple overlay modal that displays -ACK! with a custom message.
|
|
// Depends on: dom.js ($)
|
|
//
|
|
|
|
/**
|
|
* Shows the error modal with the given message.
|
|
* The overlay is absolutely positioned and blocks all interaction until dismissed.
|
|
* @param {string} msg - message to display inside the error box
|
|
*/
|
|
function showError(msg) {
|
|
const el = $("#error-overlay");
|
|
el.querySelector(".error-msg").textContent = msg;
|
|
el.classList.add("active");
|
|
}
|
|
|
|
/**
|
|
* Hides the error modal. Triggered by clicking the × button,
|
|
* the overlay backdrop, or called programmatically.
|
|
* @param {MouseEvent} [ev] - event to check target matching
|
|
*/
|
|
function closeError(ev) {
|
|
if (
|
|
!ev ||
|
|
ev.target === ev.currentTarget ||
|
|
ev.target.classList.contains("error-close")
|
|
) {
|
|
$("#error-overlay").classList.remove("active");
|
|
}
|
|
}
|