23 lines
848 B
JavaScript
23 lines
848 B
JavaScript
/**
|
||
* app.js – Global Socket.IO connection & UI helpers
|
||
*/
|
||
|
||
document.addEventListener("DOMContentLoaded", function () {
|
||
// ── Bootstrap alert auto-dismiss after 4 s ──────────────────────────────
|
||
document.querySelectorAll(".alert").forEach(function (el) {
|
||
setTimeout(function () {
|
||
const bsAlert = bootstrap.Alert.getOrCreateInstance(el);
|
||
if (bsAlert) bsAlert.close();
|
||
}, 4000);
|
||
});
|
||
|
||
// ── Confirm-before-submit for data-confirm forms ─────────────────────────
|
||
document.querySelectorAll("form[data-confirm]").forEach(function (form) {
|
||
form.addEventListener("submit", function (e) {
|
||
if (!confirm(form.getAttribute("data-confirm"))) {
|
||
e.preventDefault();
|
||
}
|
||
});
|
||
});
|
||
});
|