summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-10-01 13:57:42 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:42:59 +0100
commitd590e5f2e5107084f35aefdf40b383aa564d3d62 (patch)
tree5d57a8438ccc5646db9bb12502fa0e675f840133 /ui.js
parentf3fe9aa59d42b6ce991d2918a226917349f10986 (diff)
download300-earth-and-water-d590e5f2e5107084f35aefdf40b383aa564d3d62.tar.gz
300: Always show undo button.
Help muscle memory by always showing the undo button in the same place.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/ui.js b/ui.js
index 5c95765..d37adf6 100644
--- a/ui.js
+++ b/ui.js
@@ -267,6 +267,26 @@ function show_marker(id, class_name, show = 1, enabled = 0) {
elt.className = class_name;
}
+function show_undo_button(sel, action, use_label = false) {
+ let button = document.querySelector(sel);
+ if (game.actions) {
+ button.classList.remove("hide");
+ if (game.actions && action in game.actions) {
+ if (game.actions[action]) {
+ if (use_label)
+ button.textContent = game.actions[action];
+ button.disabled = false;
+ } else {
+ button.disabled = true;
+ }
+ } else {
+ button.disabled = true;
+ }
+ } else {
+ button.classList.add("hide");
+ }
+}
+
function on_update() {
document.getElementById("greek_info").textContent = greek_info();
document.getElementById("persian_info").textContent = persian_info();
@@ -285,7 +305,7 @@ function on_update() {
show_action_button("#button_draw", "draw");
show_action_button("#button_next", "next");
show_action_button("#button_pass", "pass");
- show_action_button("#button_undo", "undo");
+ show_undo_button("#button_undo", "undo");
if (game.actions && game.actions.destroy)
document.getElementById("bridge").className = "show destroy";