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.
This commit is contained in:
Ben Harris
2022-11-24 21:03:31 +00:00
parent 36c9062cbd
commit 38e17ebab2

View File

@ -190,6 +190,13 @@ function disable_menu_item(item, disabledFlag) {
// 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");