mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Add function to cancel file upload.
This commit is contained in:
parent
07c4e31510
commit
683b59bb47
@ -1,4 +1,4 @@
|
|||||||
function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
function sendNewJobFormData(newJobFormElement, progressModalElement, request) {
|
||||||
var formData;
|
var formData;
|
||||||
var progress;
|
var progress;
|
||||||
var progressModal;
|
var progressModal;
|
||||||
@ -6,7 +6,6 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
|||||||
|
|
||||||
formData = new FormData(newJobFormElement);
|
formData = new FormData(newJobFormElement);
|
||||||
progressModal = M.Modal.getInstance(progressModalElement);
|
progressModal = M.Modal.getInstance(progressModalElement);
|
||||||
request = new XMLHttpRequest();
|
|
||||||
|
|
||||||
progressModal.options.dismissible = false;
|
progressModal.options.dismissible = false;
|
||||||
progressModalElement.querySelector(".title").innerHTML = newJobFormElement.title.value;
|
progressModalElement.querySelector(".title").innerHTML = newJobFormElement.title.value;
|
||||||
@ -15,7 +14,7 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
|||||||
progressModalElement.querySelector(".total").innerHTML = event.total.toString();
|
progressModalElement.querySelector(".total").innerHTML = event.total.toString();
|
||||||
progressModalElement.querySelector(".determinate").style.width = ((event.loaded / event.total) * 100).toString() + "%";
|
progressModalElement.querySelector(".determinate").style.width = ((event.loaded / event.total) * 100).toString() + "%";
|
||||||
});
|
});
|
||||||
request.addEventListener("loadend", function(event) {
|
request.addEventListener("load", function(event) {
|
||||||
newJobFormElement.reset();
|
newJobFormElement.reset();
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
@ -24,9 +23,18 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
|||||||
request.open("POST", window.location.href);
|
request.open("POST", window.location.href);
|
||||||
request.send(formData);
|
request.send(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initNewJobForm(newJobFormElement, progressModalElement) {
|
function initNewJobForm(newJobFormElement, progressModalElement) {
|
||||||
|
var request;
|
||||||
|
|
||||||
|
request = new XMLHttpRequest();
|
||||||
|
|
||||||
newJobFormElement.addEventListener("submit", function(event) {
|
newJobFormElement.addEventListener("submit", function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
sendNewJobFormData(newJobFormElement, progressModalElement);
|
sendNewJobFormData(newJobFormElement, progressModalElement, request);
|
||||||
|
});
|
||||||
|
|
||||||
|
progressModalElement.querySelector(".cancel").addEventListener("click", function(event) {
|
||||||
|
request.abort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat disabled">Cancel</a>
|
<a href="#!" class="modal-close waves-effect waves-green btn red cancel">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat disabled">Cancel</a>
|
<a href="#!" class="modal-close waves-effect waves-green btn red cancel">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user