aboutsummaryrefslogtreecommitdiff
path: root/emcclib.js
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-11-20 18:01:19 +0000
committerBen Harris <bjh21@bjh21.me.uk>2022-11-20 19:10:23 +0000
commit77c8b50834a8978fbbebe2f6701448aff5d9f08e (patch)
treec9bcb533e2199dfb5c2c739edc5a31c8c8dc2af5 /emcclib.js
parentf86623bbd93e703f1be6432cc221319543a304e6 (diff)
downloadpuzzles-77c8b50834a8978fbbebe2f6701448aff5d9f08e.zip
puzzles-77c8b50834a8978fbbebe2f6701448aff5d9f08e.tar.gz
puzzles-77c8b50834a8978fbbebe2f6701448aff5d9f08e.tar.bz2
puzzles-77c8b50834a8978fbbebe2f6701448aff5d9f08e.tar.xz
js: Allow status bar to be present in the HTML
I'm generally in favour of putting HTML in HTML rather the constructing it in JavaScript, and this will allow for simplifying the code eventually. This only changes the JavaScript to make sure that's in people's caches before I change the HTML itself.
Diffstat (limited to '')
-rw-r--r--emcclib.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/emcclib.js b/emcclib.js
index dad1475..d2316f1 100644
--- a/emcclib.js
+++ b/emcclib.js
@@ -518,11 +518,24 @@ mergeInto(LibraryManager.library, {
* back end turns out to want one.
*/
js_canvas_make_statusbar: function() {
- var statusholder = document.getElementById("statusbarholder");
- statusbar = document.createElement("div");
- statusbar.id = "statusbar";
- statusbar.appendChild(document.createTextNode(" "));
- statusholder.appendChild(statusbar);
+ if (statusbar === null) {
+ var statusholder = document.getElementById("statusbarholder");
+ statusbar = document.createElement("div");
+ statusbar.id = "statusbar";
+ statusbar.appendChild(document.createTextNode(" "));
+ statusholder.appendChild(statusbar);
+ }
+ },
+
+ /*
+ * void js_canvas_remove_statusbar(void);
+ *
+ * Cause a status bar not to exist. Called at setup time if the
+ * puzzle back end turns out not to want one.
+ */
+ js_canvas_remove_statusbar: function() {
+ if (statusbar !== null)
+ statusbar.parentNode.removeChild(statusbar);
},
/*
@@ -531,9 +544,7 @@ mergeInto(LibraryManager.library, {
* Set the text in the status bar.
*/
js_canvas_set_statusbar: function(ptr) {
- var text = UTF8ToString(ptr);
- statusbar.replaceChild(document.createTextNode(text),
- statusbar.lastChild);
+ statusbar.textContent = UTF8ToString(ptr);
},
/*