Don't try to destroy the upload window if it doesn't exist.
authorArt Cancro <ajc@citadel.org>
Wed, 11 Oct 2023 22:44:05 +0000 (18:44 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 11 Oct 2023 22:44:05 +0000 (18:44 -0400)
webcit-ng/static/js/upload.js

index 6dbd92e64e935fe372de20263131fb839c70e5da..2d0751bafe0abfe382a103730e95b78560b9e7ad 100644 (file)
@@ -12,7 +12,10 @@ var uploads = [] ;                                                           // everything the user has uploaded
 
 // Remove the upload window completely (even if it's hidden)
 function deactivate_uploads() {
-       document.getElementById("ctdl-upload").remove();
+        upload_window = document.getElementById('ctdl-upload');
+       if (upload_window) {
+               upload_window.remove();
+       }
 }
 
 
@@ -151,7 +154,11 @@ function show_or_hide_upload_window() {
 
 // Flush all uploaded files and close the window
 function flush_uploads() {
-        document.getElementById('ctdl-upload').style.display='none';
+        upload_window = document.getElementById('ctdl-upload');
+
+       if (upload_window) {
+               upload_window.style.display='none';
+       }
 
         // FIXME tell the server to delete the files
        uploads.forEach(u => {