diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-03-05 11:08:22 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-03-05 16:47:03 +0100 |
commit | 4e85d56e9cd74f3e2b2c596ce3ca31312f281661 (patch) | |
tree | 11697acf9b1a4f51419509973b952ad5627dfcb2 /public | |
parent | a82c2e2ce844a93a749a16ac17706fa3e011d9cc (diff) | |
download | server-4e85d56e9cd74f3e2b2c596ce3ca31312f281661.tar.gz |
Change create_log_entry variable to on_log function.
Use typeof to check if it is callable.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/play.js | 17 |
1 files changed, 9 insertions, 8 deletions
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(); } |