diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-15 00:35:49 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-15 00:35:49 +0200 |
commit | aa08a6d083fef631aa58b9c3d50c4c024639b498 (patch) | |
tree | abddc98aa1c8737af9575d5b5f5426590317a89f /play.js | |
parent | 986f697c55c747d9a3e768b0c24e03d12fe935fe (diff) | |
download | washingtons-war-aa08a6d083fef631aa58b9c3d50c4c024639b498.tar.gz |
card tooltips
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -17,13 +17,32 @@ let ui = { cu: [], } +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_last_card() { + if (typeof view.last_card === 'number') { + document.getElementById("tooltip").className = "card show card_" + view.last_card + } +} + +function on_blur_last_card() { + document.getElementById("tooltip").classList = "card" +} + function on_log(text) { let p = document.createElement("div") text = text.replace(/&/g, "&") text = text.replace(/</g, "<") text = text.replace(/>/g, ">") - text = text.replace(/\[(\d+)([^\]]*)\]/, '<span class="card_tip" data-card="$1">$1$2</span>') + text = text.replace(/#(\d+)/g, + '<span class="tip" onmouseenter="on_focus_card_tip($1)" onmouseleave="on_blur_card_tip()">$&</span>') if (text.match(/^\.h1 /)) { p.className = "h1" |