mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
function sendNewJobFormData(newJobFormElement, progressModalElement) {
|
|
var formData;
|
|
var progress;
|
|
var progressModal;
|
|
var request;
|
|
|
|
formData = new FormData(newJobFormElement);
|
|
progressModal = M.Modal.getInstance(progressModalElement);
|
|
request = new XMLHttpRequest();
|
|
|
|
progressModal.options.dismissible = false;
|
|
progressModalElement.querySelector(".title").innerHTML = newJobFormElement.title.value;
|
|
request.upload.addEventListener("progress", function(event) {
|
|
progressModalElement.querySelector(".loaded").innerHTML = event.loaded.toString();
|
|
progressModalElement.querySelector(".total").innerHTML = event.total.toString();
|
|
progressModalElement.querySelector(".determinate").style.width = ((event.loaded / event.total) * 100).toString() + "%";
|
|
});
|
|
request.addEventListener("loadend", function(event) {
|
|
newJobFormElement.reset();
|
|
location.reload();
|
|
});
|
|
|
|
progressModal.open();
|
|
request.open("POST", window.location.href);
|
|
request.send(formData);
|
|
}
|
|
function initNewJobForm(newJobFormElement, progressModalElement) {
|
|
newJobFormElement.addEventListener("submit", function(event) {
|
|
event.preventDefault();
|
|
sendNewJobFormData(newJobFormElement, progressModalElement);
|
|
});
|
|
}
|