Skip to content

Commit

Permalink
Added prompt if page is closed when still uploading #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Feb 13, 2023
1 parent a313d26 commit 14771f0
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions internal/webserver/web/static/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ var clipboard = new ClipboardJS('.btn');
var dropzoneObject;
var isE2EEnabled = false;

var isUploading = false;

window.addEventListener('beforeunload', (event) => {
if (isUploading) {
event.returnValue = 'Upload is still in progress. Do you want to close this page?';
}
});

Dropzone.options.uploaddropzone = {
paramName: "file",
dictDefaultMessage: "Drop files, paste or click here to upload",
Expand All @@ -12,15 +20,20 @@ Dropzone.options.uploaddropzone = {
},
init: function() {
dropzoneObject = this;
this.on("sending", function(file, xhr, formData) {});
// This will be executed after the page has loaded. If e2e ist enabled, the end2end_admin.js has set isE2EEnabled to true
if (isE2EEnabled) {
dropzoneObject.disable();
dropzoneObject.options.dictDefaultMessage = "Loading end-to-end encryption...";
document.getElementsByClassName("dz-button")[0].innerText = "Loading end-to-end encryption...";
setE2eUpload();
}
},
this.on("queuecomplete", function() {
isUploading = false;
});
this.on("sending", function(file, xhr, formData) {
isUploading = true;
});
// This will be executed after the page has loaded. If e2e ist enabled, the end2end_admin.js has set isE2EEnabled to true
if (isE2EEnabled) {
dropzoneObject.disable();
dropzoneObject.options.dictDefaultMessage = "Loading end-to-end encryption...";
document.getElementsByClassName("dz-button")[0].innerText = "Loading end-to-end encryption...";
setE2eUpload();
}
},
};

document.onpaste = function(event) {
Expand Down

0 comments on commit 14771f0

Please sign in to comment.