summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 62e676d..ff8e2d4 100644
--- a/ui.js
+++ b/ui.js
@@ -58,6 +58,34 @@ let ui = {
present: new Set(),
}
+create_log_entry = function (text) {
+ let p = document.createElement("div");
+ text = text.replace(/&/g, "&");
+ text = text.replace(/</g, "&lt;");
+ text = text.replace(/>/g, "&gt;");
+
+ text = text.replace(/\u2192 /g, "\u2192\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 Lancaster turn/))
+ p.className = 'L';
+ else if (text.match(/^Start York turn/))
+ p.className = 'Y';
+ 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;
+}
+
function on_focus_area(evt) {
let where = evt.target.area;
let text = where;