diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-07-22 15:40:10 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-17 13:11:25 +0100 |
commit | b6b5a40502751ecf66bc3ac00890634df0504ecc (patch) | |
tree | 2377a769edb3b5ef34fdd7c400c1b58fce032933 /play.js | |
parent | bacef63f254d26e593bb59dc4799eee495136f06 (diff) | |
download | rommel-in-the-desert-b6b5a40502751ecf66bc3ac00890634df0504ecc.tar.gz |
refuse battle pursuit fire
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 44 |
1 files changed, 35 insertions, 9 deletions
@@ -624,10 +624,23 @@ function on_update() { action_button("undo", "Undo") } +function on_focus_hex_tip(x) { + ui.hexes[x].classList.add("tip") +} + +function on_click_hex_tip(x) { + console.log(ui.hexes[x]) + ui.hexes[x].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" }) +} + +function on_blur_hex_tip(x) { + ui.hexes[x].classList.remove("tip") +} + function sub_hex_name(match, p1, offset, string) { let x = p1 | 0 let n = hex_name[x] - return `<span class="hex" onmouseenter="on_focus_hex_tip(${x})" onmouseleave="on_blur_hex_tip(${x})">${n}</span>` + return `<span class="hex" onmouseenter="on_focus_hex_tip(${x})" onmouseleave="on_blur_hex_tip(${x})" onclick="on_click_hex_tip(${x})">${n}</span>` } function sub_unit_name(match, p1, offset, string) { @@ -635,8 +648,21 @@ function sub_unit_name(match, p1, offset, string) { return units[u].name } +function on_log_line(text, cn) { + let p = document.createElement("div") + if (cn) p.className = cn + p.innerHTML = text + return p +} + function on_log(text) { let p = document.createElement("div") + + if (text.match(/^>/)) { + text = text.substring(1) + p.className = "i" + } + text = text.replace(/&/g, "&") text = text.replace(/</g, "<") text = text.replace(/>/g, ">") @@ -646,20 +672,20 @@ function on_log(text) { if (text.match(/^\.h1/)) { text = text.substring(4) - p.className = 'h1' + p.className = "h1" } if (text.match(/^\.h2/)) { text = text.substring(4) - if (text.startsWith('Axis')) - p.className = 'h2 axis' - else if (text.startsWith('Allied')) - p.className = 'h2 allied' + if (text.startsWith("Axis")) + p.className = "h2 axis" + else if (text.startsWith("Allied")) + p.className = "h2 allied" else - p.className = 'h2' + p.className = "h2" } if (text.match(/^\.h3/)) { text = text.substring(4) - p.className = 'h3' + p.className = "h3" } if (text.indexOf("\n") < 0) { @@ -668,7 +694,7 @@ function on_log(text) { text = text.split("\n") p.appendChild(on_log_line(text[0])) for (let i = 1; i < text.length; ++i) - p.appendChild(on_log_line(text[i], "indent")) + p.appendChild(on_log_line(text[i], "i")) } return p } |