23 lines
670 B
JavaScript
Executable File
23 lines
670 B
JavaScript
Executable File
/* AES-Erweiterung: CSP-konforme Bestaetigungsdialoge fuer Formulare mit
|
|
data-confirm="..." (ersetzt inline onsubmit). Von /static ausgeliefert. */
|
|
(function () {
|
|
"use strict";
|
|
function wire() {
|
|
var forms = document.querySelectorAll("form[data-confirm]");
|
|
for (var i = 0; i < forms.length; i++) {
|
|
(function (f) {
|
|
f.addEventListener("submit", function (e) {
|
|
if (!window.confirm(f.getAttribute("data-confirm"))) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
})(forms[i]);
|
|
}
|
|
}
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", wire);
|
|
} else {
|
|
wire();
|
|
}
|
|
})();
|