From 5a84afa4f4ae02dcc38cc752be4c2a7b801c7c4d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 25 Sep 2022 14:23:01 +0200 Subject: Space tool tips in log. --- play.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'play.js') diff --git a/play.js b/play.js index 9ac8880..920b31e 100644 --- a/play.js +++ b/play.js @@ -285,6 +285,18 @@ function on_blur_bpa() { document.getElementById("status").textContent = "" } +function on_focus_space_tip(s) { + ui.space_list[s].classList.add("tip") +} + +function on_blur_space_tip(s) { + ui.space_list[s].classList.remove("tip") +} + +function on_click_space_tip(s) { + ui.space_list[s].scrollIntoView({ block:"center", inline:"center", behavior:"smooth" }) +} + function on_log_line(text, cn) { let p = document.createElement("div") if (cn) p.className = cn @@ -292,6 +304,12 @@ function on_log_line(text, cn) { return p } +function sub_space_name(match, p1, offset, string) { + let s = p1 | 0 + let n = spaces[s].name + return `${n}` +} + function on_log(text) { let p = document.createElement("div") text = text.replace(/&/g, "&") @@ -299,6 +317,8 @@ function on_log(text) { text = text.replace(/>/g, ">") text = text.replace(/#(\d+)[^\]]*\]/g, '$&') + text = text.replace(/%(\d+)/g, sub_space_name) + if (text.match(/^\.h1/)) { text = text.substring(4) p.className = 'h1' @@ -387,6 +407,7 @@ let ui = { pieces: document.getElementById("pieces"), cards: document.getElementById("cards"), last_card: document.getElementById("last_card"), + space_list: [], } const marker_info = { @@ -895,6 +916,8 @@ function build_space(id) { elt.classList.add(pieces[box_leader(id)].faction) ui.spaces.appendChild(elt) + + ui.space_list[id] = elt } function build_leader(id) { -- cgit v1.2.3