summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-12-19 17:03:16 +0100
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:08:56 +0100
commitbbbd35a5e828a9f19b44544a80af9c1e7daf0299 (patch)
tree45c80857bd7c97d59534c5fc4cc51f043fc20422 /ui.js
parent861c83b63547c9538dda5716bba2113ae458a3ff (diff)
downloadjulius-caesar-bbbd35a5e828a9f19b44544a80af9c1e7daf0299.tar.gz
Prettier logs with formatting and colors.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 2198c7b..8bd27a5 100644
--- a/ui.js
+++ b/ui.js
@@ -74,6 +74,35 @@ let ui = {
cards: {},
};
+create_log_entry = function (text) {
+ let p = document.createElement("div");
+ text = text.replace(/&/g, "&amp;");
+ text = text.replace(/</g, "&lt;");
+ text = text.replace(/>/g, "&gt;");
+
+ text = text.replace(/\u2192 /g, "\u2192\xa0");
+ text = text.replace(/Mare /g, "Mare\xa0");
+
+ text = text.replace(/^([A-Z]):/, '<span class="$1"> $1 </span>');
+
+ if (text.match(/^~ .* ~$/))
+ p.className = 'br', text = text.substring(2, text.length-2);
+ else if (text.match(/^Start Caesar turn/))
+ p.className = 'C';
+ else if (text.match(/^Start Pompeius turn/))
+ p.className = 'P';
+ else if (text.match(/^Start /))
+ p.className = 'st';
+ else if (text.match(/^Battle in/))
+ p.className = 'bs';
+
+ if (text.match(/^Start /))
+ text = text.substring(6);
+
+ p.innerHTML = text;
+ return p;
+}
+
const STEPS = [ 0, "I", "II", "III", "IIII" ];
function block_description(b) {