diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-03-31 17:26:06 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-03-31 17:26:06 +0200 |
commit | 71e3087f5a8382a38b0780758b4b9b44230e8c98 (patch) | |
tree | 4e34c92c309c0695a44c19ae73165454fb457269 | |
parent | e34da06aa63e72b7afdf225a8bea5a6244017ff8 (diff) | |
download | server-71e3087f5a8382a38b0780758b4b9b44230e8c98.tar.gz |
Add action buttons that take action arguments.
To simplify action buttons like number(x).
-rw-r--r-- | public/common/client.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/public/common/client.js b/public/common/client.js index 452d71a..367cbb0 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -651,6 +651,25 @@ try { /* ACTIONS */ +function action_button_with_argument(verb, noun, label) { + if (params.mode === "replay") + return + let id = verb + "_" + noun + "_button" + let button = document.getElementById(id) + if (!button) { + button = document.createElement("button") + button.id = id + button.textContent = label + button.addEventListener("click", evt => send_action(verb, noun)) + document.getElementById("actions").prepend(button) + } + if (view.actions && view.actions[verb] && view.actions[verb].includes(noun)) { + button.classList.remove("hide") + } else { + button.classList.add("hide") + } +} + function action_button_imp(action, label, callback) { if (params.mode === "replay") return |