From 71e3087f5a8382a38b0780758b4b9b44230e8c98 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 31 Mar 2024 17:26:06 +0200 Subject: Add action buttons that take action arguments. To simplify action buttons like number(x). --- public/common/client.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'public') 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 -- cgit v1.2.3