aboutsummaryrefslogtreecommitdiff
path: root/qc_app/static/js
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-01-17 11:15:36 +0300
committerFrederick Muriuki Muriithi2023-01-17 11:15:36 +0300
commit9daa00bc10f8199145cf5952382512f4db95aa4a (patch)
tree7e495457bb9bee3febbebfbbe761fa88bb73e0f2 /qc_app/static/js
parent3fb8a4de897eabd3e85520358619af7abcbd7664 (diff)
downloadgn-uploader-9daa00bc10f8199145cf5952382512f4db95aa4a.tar.gz
upload: Enable cancelling an upload.
Diffstat (limited to 'qc_app/static/js')
-rw-r--r--qc_app/static/js/upload_progress.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/qc_app/static/js/upload_progress.js b/qc_app/static/js/upload_progress.js
index 049dbfe..98a503a 100644
--- a/qc_app/static/js/upload_progress.js
+++ b/qc_app/static/js/upload_progress.js
@@ -35,6 +35,15 @@ function make_progress_updater(file, indicator_elt) {
};
}
+function setup_cancel_upload(request, indicator_elt) {
+ document.getElementById("btn-cancel-upload").addEventListener(
+ "click", function(event) {
+ event.preventDefault();
+ request.abort();
+ indicator_elt.setAttribute("class", "hidden");
+ });
+}
+
function setup_request(file, progress_indicator_elt) {
var request = new XMLHttpRequest();
var updater = make_progress_updater(file, progress_indicator_elt);
@@ -42,6 +51,7 @@ function setup_request(file, progress_indicator_elt) {
request.onload = function(event) {
document.location.assign(request.responseURL);
};
+ setup_cancel_upload(request, progress_indicator_elt)
return request;
}