shithub: puzzles

Download patch

ref: 38e17ebab2488aaac4fcb0d5fb06ed03d5eb7e41
parent: 36c9062cbd01024610032e8a31b66ef12a7c11d9
author: Ben Harris <bjh21@bjh21.me.uk>
date: Thu Nov 24 16:03:31 EST 2022

js: If the HTML contains a dialogue-box form, delete it

This is so that (given time for caches to expire) I can switch to having
a persistent dialogue box in HTML rather than fabricating it from
scratch in JavaScript each time it's used.

--- a/emccpre.js
+++ b/emccpre.js
@@ -190,6 +190,13 @@
 
 // Dialog-box functions called from both C and JS.
 function dialog_init(titletext) {
+    // Forward compatibility: Delete form and dimmer if they already
+    // exist.
+    dlg_dimmer = document.getElementById("dlgdimmer");
+    if (dlg_dimmer) dlg_dimmer.parentElement.removeChild(dlg_dimmer);
+    dlg_form = document.getElementById("dlgform");
+    if (dlg_form) dlg_form.parentElement.removeChild(dlg_form);
+
     // Create an overlay on the page which darkens everything
     // beneath it.
     dlg_dimmer = document.createElement("div");