summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/play.js b/play.js
index 60d198a..f31015a 100644
--- a/play.js
+++ b/play.js
@@ -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, "&amp;")
+ text = text.replace(/</g, "&lt;")
+ text = text.replace(/>/g, "&gt;")
+ 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'