From 4e85d56e9cd74f3e2b2c596ce3ca31312f281661 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 5 Mar 2022 11:08:22 +0100 Subject: Change create_log_entry variable to on_log function. Use typeof to check if it is callable. --- public/common/play.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'public') diff --git a/public/common/play.js b/public/common/play.js index 8a748c6..e58ca04 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -412,19 +412,20 @@ function on_update_header() { /* LOG */ -let create_log_entry = function (text) { - let div = document.createElement("div"); - div.textContent = text; - return div; -} - function on_update_log() { let div = document.getElementById("log"); let to_delete = div.children.length - view.log_start; while (to_delete-- > 0) div.removeChild(div.lastChild); - for (let entry of view.log) - div.appendChild(create_log_entry(entry)); + for (let text of view.log) { + if (typeof on_log === 'function') { + div.appendChild(on_log(text)); + } else { + let entry = document.createElement("div"); + entry.textContent = text; + div.appendChild(entry); + } + } scroll_log_to_end(); } -- cgit v1.2.3