From c364b1273b880d71f7c975bde74aff34a078c241 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Thu, 6 Jan 2022 11:19:52 -0500 Subject: feat(grfn/bbbg): Add delete event button Change-Id: I763e7a6b367ea5b474ab3aa13c7ff21e99db34af Reviewed-on: https://cl.tvl.fyi/c/depot/+/5023 Reviewed-by: grfn Autosubmit: grfn Tested-by: BuildkiteCI --- users/grfn/bbbg/resources/public/main.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'users/grfn/bbbg/resources/public/main.js') diff --git a/users/grfn/bbbg/resources/public/main.js b/users/grfn/bbbg/resources/public/main.js index 2308ca595724..87c0b64d0a37 100644 --- a/users/grfn/bbbg/resources/public/main.js +++ b/users/grfn/bbbg/resources/public/main.js @@ -58,10 +58,16 @@ window.onload = () => { } document.querySelectorAll("form").forEach((form) => { - form.onsubmit = (e) => { + form.addEventListener("submit", (e) => { if (e.target.attributes.disabled) { e.preventDefault(); } - }; + + const confirmMessage = e.target.dataset.confirm; + if (confirmMessage != null && !confirm(confirmMessage)) { + e.stopImmediatePropagation(); + e.preventDefault(); + } + }); }); }; -- cgit 1.4.1