diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-12 15:00:48 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-12 15:00:48 +0200 |
commit | e7c2b14515a3d8f70c51012db00d58f877d023c4 (patch) | |
tree | f5927efd322486e9b54aab9d3656311c34bcca48 /play.js | |
parent | bd58c7d24791dc7360f380c9277b99dc9426be41 (diff) | |
download | algeria-e7c2b14515a3d8f70c51012db00d58f877d023c4.tar.gz |
highlight
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -585,6 +585,41 @@ function on_update() { // eslint-disable-line no-unused-vars action_button("reset", "Reset") } +function on_focus_area_tip(x) { + ui.areas[x].classList.add("tip") +} + +function on_blur_area_tip(x) { + ui.areas[x].classList.remove("tip") +} + +function on_click_area_tip(x) { + ui.areas[x].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" }) +} + +function sub_area_name(match, p1, offset, string) { + let x = p1 | 0 + let n = data.areas[x].name + return `<span class="tip" onmouseenter="on_focus_area_tip(${x})" onmouseleave="on_blur_area_tip(${x})" onclick="on_click_area_tip(${x})">${n}</span>` +} + +function on_focus_unit_tip(x) { + ui.units[x].classList.add("tip") +} + +function on_blur_unit_tip(x) { + ui.units[x].classList.remove("tip") +} + +function on_click_unit_tip(x) { + ui.units[x].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" }) +} + +function sub_unit_name(match, p1, offset, string) { + let x = p1 | 0 + let n = data.units[x].name + return `<span class="tip" onmouseenter="on_focus_unit_tip(${x})" onmouseleave="on_blur_unit_tip(${x})" onclick="on_click_unit_tip(${x})">${n}</span>` +} function on_log(text) { // eslint-disable-line no-unused-vars let p = document.createElement("div") @@ -594,6 +629,12 @@ function on_log(text) { // eslint-disable-line no-unused-vars p.className = "i" } + text = text.replace(/&/g, "&") + text = text.replace(/</g, "<") + text = text.replace(/>/g, ">") + text = text.replace(/U(\d+)/g, sub_unit_name) + text = text.replace(/A(\d+)/g, sub_area_name) + if (text.match(/^\.h1/)) { text = text.substring(4) p.className = 'h1' |