summaryrefslogtreecommitdiff
path: root/html/dialog.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/dialog.js')
-rw-r--r--html/dialog.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/html/dialog.js b/html/dialog.js
index c4bba5d..a2406e8 100644
--- a/html/dialog.js
+++ b/html/dialog.js
@@ -129,3 +129,13 @@ const ask = (ctx, ...msg) => show_dialog(ctx, "ask_buts", msg);
const loader = (ctx, ...msg) => show_dialog(ctx, null, msg);
#EXPORT loader
+
+/*
+ * Wrapper around target.addEventListener() that makes the requested callback
+ * only execute if dialog is not shown.
+ */
+function onevent(ctx, target, event, cb)
+{
+ target.addEventListener(event, e => !ctx.shown && cb(e));
+}
+#EXPORT onevent