mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +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 progress;
|
||||
var progressModal;
|
||||
@ -6,7 +6,6 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
||||
|
||||
formData = new FormData(newJobFormElement);
|
||||
progressModal = M.Modal.getInstance(progressModalElement);
|
||||
request = new XMLHttpRequest();
|
||||
|
||||
progressModal.options.dismissible = false;
|
||||
progressModalElement.querySelector(".title").innerHTML = newJobFormElement.title.value;
|
||||
@ -15,7 +14,7 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
||||
progressModalElement.querySelector(".total").innerHTML = event.total.toString();
|
||||
progressModalElement.querySelector(".determinate").style.width = ((event.loaded / event.total) * 100).toString() + "%";
|
||||
});
|
||||
request.addEventListener("loadend", function(event) {
|
||||
request.addEventListener("load", function(event) {
|
||||
newJobFormElement.reset();
|
||||
location.reload();
|
||||
});
|
||||
@ -24,9 +23,18 @@ function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
||||
request.open("POST", window.location.href);
|
||||
request.send(formData);
|
||||
}
|
||||
|
||||
function initNewJobForm(newJobFormElement, progressModalElement) {
|
||||
var request;
|
||||
|
||||
request = new XMLHttpRequest();
|
||||
|
||||
newJobFormElement.addEventListener("submit", function(event) {
|
||||
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 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>
|
||||
|
||||
|
@ -148,7 +148,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user