summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-10-11 08:21:08 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-10-11 08:21:08 +0100
commita93ef46743251516b3ad4075fdd518ed45d0776d (patch)
tree58fdb3f1f6dd4a99c7a15e0803a2042d702b7ee2 /play.js
parent7396312cd495803df67a2e8ca17cf7b01927cfdb (diff)
download1989-dawn-of-freedom-a93ef46743251516b3ad4075fdd518ed45d0776d.tar.gz
Revert to old view
Diffstat (limited to 'play.js')
-rw-r--r--play.js103
1 files changed, 8 insertions, 95 deletions
diff --git a/play.js b/play.js
index 7b18e6e..99dd5f6 100644
--- a/play.js
+++ b/play.js
@@ -162,73 +162,7 @@ const spaceCharacteristicsElement = document.getElementById('space-characteristi
}
}
-// POP UP CARD MENU
-
-var card_action_menu = Array.from(document.getElementById("popup").querySelectorAll("li[data-action]")).map(e => e.dataset.action)
-
-console.log('card_action_menu', card_action_menu)
-
-function show_popup_menu(evt, menu_id, target_id, title) {
- let menu = document.getElementById(menu_id)
- console.log('show_popup_menu called with evt',evt, 'menu_id',menu_id, 'target_id', target_id, 'title', title)
-
- let show = false
- console.log(`menu.querySelectorAll("li")`, menu.querySelectorAll("li"))
- for (let item of menu.querySelectorAll("li")) {
- let action = item.dataset.action
- console.log('item', item, 'action', action)
- if (action) {
- //console.log('in if action')
- if (is_card_action(action, target_id)) {
- console.log('in is_card_action',)
- show = true
- item.classList.add("action")
- item.classList.remove("disabled")
- item.onclick = function () {
- send_action(action, target_id)
- hide_popup_menu()
- evt.stopPropagation()
- }
- } else {
- item.classList.remove("action")
- item.classList.add("disabled")
- item.onclick = null
- }
- }
- }
- if (show) {
- menu.onmouseleave = hide_popup_menu
- menu.style.display = "block"
- if (title) {
- let item = menu.querySelector("li.title")
- if (item) {
- item.onclick = hide_popup_menu
- item.textContent = title
- }
- }
-
- let w = menu.clientWidth
- let h = menu.clientHeight
- let x = Math.max(5, Math.min(evt.clientX - w / 2, window.innerWidth - w - 5))
- let y = Math.max(5, Math.min(evt.clientY - 12, window.innerHeight - h - 40))
- menu.style.left = x + "px"
- menu.style.top = y + "px"
-
- evt.stopPropagation()
- } else {
- menu.style.display = "none"
- }
-}
-
-function hide_popup_menu() {
- document.getElementById("popup").style.display = "none"
- document.getElementById("popup_ceh_check").style.display = "none"
- document.getElementById("popup_opp_event").style.display = "none"
- document.getElementById("popup_tst_7").style.display = "none"
- document.getElementById("popup_tst_8").style.display = "none"
- document.getElementById("popup_tst_7_8").style.display = "none"
-}
function is_card_enabled(card) {
@@ -262,37 +196,16 @@ function on_click_space(evt) {
}
function on_click_card(evt) {
- const card = evt.target.my_card;
- console.log('on_click_card_called with card:', card);
- if (is_action('card', card)) {
- console.log('in action card')
- if (send_action('card', card)) {
- evt.stopPropagation();
- }
- }
- //First check for TST special powers
- else if (is_card_action('card_tst_7', card)) {
- if (is_card_action('card_tst_8', card)) {
- show_popup_menu(evt, "popup_tst_7_8", card, cards[card].name)
- } else {
- show_popup_menu(evt, "popup_tst_7", card, cards[card].name)
+ if (evt.button === 0) {
+ const card = evt.target.my_card;
+ console.log('on_click_card_called with card:', card);
+ if (is_action('card', card)) {
+ console.log('in action card')
+ if (send_action('card', card)) {
+ evt.stopPropagation();
+ }
}
}
- else if (is_card_action('card_tst_8', card)) {
- show_popup_menu(evt, "popup_tst_8", card, cards[card].name)
- }
-
- //Check for Common European Home
- else if (is_card_action('card_ceh', card)) {
- show_popup_menu(evt, "popup_ceh_check", card, cards[card].name)
- } else if (is_card_action('card_opp_event', card)) {
- console.log('in action card_opp_event')
- show_popup_menu(evt, "popup_opp_event", card, cards[card].name)
- }
- else {
- console.log('in action card_my_event')
- show_popup_menu(evt, "popup", card, cards[card].name)
- }
}
function is_action(action) {