From d818566e2e80b4cbb4eab80c95229e317bf9332d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 31 Dec 2023 17:47:38 +0100 Subject: WIP paintings and wikipedia links --- play.html | 14 ++++++++++++++ play.js | 13 +++++++++++++ rules.js | 1 + tools/gendata.js | 1 + 4 files changed, 29 insertions(+) diff --git a/play.html b/play.html index dec92ea..1155ccd 100644 --- a/play.html +++ b/play.html @@ -53,6 +53,15 @@ padding: 2px 8px; } +#log .h1 a { + color: black; + text-decoration: none; +} + +#log .h1 a:hover { + text-decoration: underline; +} + #log .h2 { text-align: center; font-variant: small-caps; @@ -70,6 +79,11 @@ #log div.i1 { padding-left: 32px; text-indent: -12px; } #log div.i2 { padding-left: 44px; text-indent: -12px; } +#log img { + padding: 0; + max-width: 100%; +} + #log .lore { font-style: italic; text-indent: 0; diff --git a/play.js b/play.js index 9fed183..c853573 100644 --- a/play.js +++ b/play.js @@ -511,6 +511,14 @@ function on_log(text) { if (text.match(/^\.h1 /)) { text = text.substring(4) p.className = "h1" + let w = null + for (let s of data.scenarios) + if (s.name === text) + w = s.wikipedia + if (w) { + p.innerHTML = `${text}` + return p + } } else if (text.match(/^\.h2 /)) { text = text.substring(4) @@ -540,6 +548,11 @@ function on_log(text) { text = text.substring(1) p.className = "i1" } + else if (text.match(/^.img /)) { + p = document.createElement("img") + p.src = "paintings/" + text.substring(5) + ".jpg" + return p + } text = text.replace(/\bC\d+\b/g, sub_card) text = text.replace(/\b[DPRBK]\d\b/g, sub_icon) diff --git a/rules.js b/rules.js index 2267dc9..8e65a20 100644 --- a/rules.js +++ b/rules.js @@ -443,6 +443,7 @@ exports.setup = function (seed, scenario, options) { log(".h1 " + info.name) log(".h2 " + info.date) + log(".img " + info.name.toLowerCase().replaceAll(" ", "_")) log("") if (info.players[0].tactical > 0 || info.players[1].tactical > 0) { diff --git a/tools/gendata.js b/tools/gendata.js index 6940249..a00a3eb 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -530,6 +530,7 @@ for (let s of scenario_records) { rule: s.rule || undefined, rule_text: s.rule_text || undefined, lore_text: s.lore_text || undefined, + wikipedia: s.wikipedia, }) var html = `
-- cgit v1.2.3