diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-10-04 12:32:21 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 12:42:59 +0100 |
commit | aeed1073cf5ecf19dc064b6d6169b20b3c292d62 (patch) | |
tree | 9601720049c0ce5426c25f657dc4db1cba72d550 | |
parent | cfdba0c522f460df3d97580ec2900fef80af9f77 (diff) | |
download | 300-earth-and-water-aeed1073cf5ecf19dc064b6d6169b20b3c292d62.tar.gz |
300: Add tooltips to card numbers in game log.
-rw-r--r-- | play.html | 6 | ||||
-rw-r--r-- | rules.js | 2 | ||||
-rw-r--r-- | ui.js | 19 |
3 files changed, 26 insertions, 1 deletions
@@ -77,6 +77,12 @@ border-radius: 10px; } +.log span.tip { + cursor: help; + text-decoration: underline; + color: blue; +} + #tooltip.card { position: fixed; z-index: 200; @@ -2167,7 +2167,7 @@ function can_play_ostracism() { function play_ostracism() { let card = draw_card(game.greek.hand); game.discard.push(card); - log("Card " + card + " is discarded."); + log("Persia discards Greek card " + card + "."); end_persian_operation(); } @@ -59,12 +59,31 @@ let ui = { selected_fleets: null, }; +create_log_entry = function (text) { + let p = document.createElement("div"); + text = text.replace(/&/g, "&"); + text = text.replace(/</g, "<"); + text = text.replace(/>/g, ">"); + text = text.replace(/card (\d+)/g, + '<span class="tip" onmouseenter="on_focus_card_tip($1)" onmouseleave="on_blur_card_tip()">card $1</span>'); + p.innerHTML = text; + return p; +} + function remove_from_array(array, item) { let i = array.indexOf(item); if (i >= 0) array.splice(i, 1); } +function on_focus_card_tip(card_number) { + document.getElementById("tooltip").className = "card show card_" + card_number; +} + +function on_blur_card_tip() { + document.getElementById("tooltip").classList = "card"; +} + function on_focus_discard(evt) { if (game.discard) document.getElementById("tooltip").className = "card show card_" + game.discard; |