summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-04-30 13:37:12 +0200
committerTor Andersson <tor@ccxvii.net>2022-04-30 14:24:48 +0200
commitc9a91eb109d71579b480c18f9637381469067d80 (patch)
treef029ed160798d4cd6e90f6939f4a06be338a5ead /public
parente9ff79d42d2dc55eada4007978250912fd34cbf3 (diff)
downloadserver-c9a91eb109d71579b480c18f9637381469067d80.tar.gz
Add common confirm_action and confirm_action_button functions.
Diffstat (limited to 'public')
-rw-r--r--public/common/play.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/public/common/play.js b/public/common/play.js
index fc71439..a106bcd 100644
--- a/public/common/play.js
+++ b/public/common/play.js
@@ -505,7 +505,7 @@ window.addEventListener("keyup", (evt) => {
/* ACTIONS */
-function action_button(action, label) {
+function action_button_imp(action, label, callback) {
if (params.mode === "replay")
return;
let id = action + "_button";
@@ -514,7 +514,7 @@ function action_button(action, label) {
button = document.createElement("button");
button.id = id;
button.textContent = label;
- button.addEventListener("click", evt => send_action(action));
+ button.addEventListener("click", callback);
document.getElementById("actions").appendChild(button);
}
if (view.actions && action in view.actions) {
@@ -531,6 +531,14 @@ function action_button(action, label) {
}
}
+function action_button(action, label) {
+ action_button_imp(action, label, evt => send_action(action));
+}
+
+function confirm_action_button(action, label, message) {
+ action_button_imp(action, label, evt => confirm_action(message, action));
+}
+
function send_action(verb, noun) {
if (params.mode === "replay")
return;
@@ -552,6 +560,11 @@ function send_action(verb, noun) {
return false;
}
+function confirm_action(message, verb, noun) {
+ if (window.confirm(message))
+ send_action(verb, noun);
+}
+
let replay_query = null;
function send_query(q, param) {