panosteal/server/static/worker.js

62 lines
1.3 KiB
JavaScript
Raw Normal View History

$("#options").hide();
2018-10-19 16:21:59 +00:00
$body = $("body");
function toggleOptions() {
$("#options").toggle();
}
2018-10-19 16:21:59 +00:00
function lockform() {
2018-10-21 09:07:03 +00:00
$("#theform :input").prop("disabled", true);
$body.addClass("loading");
2018-10-19 16:21:59 +00:00
}
function unlockform() {
2018-10-21 09:07:03 +00:00
$("#theform :input").prop("disabled", false);
$body.removeClass("loading");
2018-10-19 16:21:59 +00:00
}
$('#theform').submit(function(event){
2018-10-21 09:07:03 +00:00
event.preventDefault();
if(this.checkValidity()) {
$.ajax({
type: "POST",
url: "/addjob",
data: $('#theform').serialize(),
success: function(msg){
lockform();
interval = setInterval(checkServerForFile,3000,msg);
window.panaxworking = false;
function checkServerForFile(jobid) {
if (!window.panaxworking) {
window.panaxworking = true;
$.ajax({
type: "GET",
cache: false,
url: "/getjob/" + jobid,
statusCode: {
404: function() {
clearInterval(interval);
unlockform();
},
200: function() {
clearInterval(interval);
unlockform();
2018-10-21 09:12:49 +00:00
window.location.href = "/getjob/" + jobid;
2018-10-21 09:07:03 +00:00
},
500: function() {
clearInterval(interval);
window.alert("Failed to process request. The URL may be incorrect or unsupported.")
unlockform();
}
}
});
window.panaxworking = false;
};
}
2018-10-19 16:21:59 +00:00
2018-10-21 09:07:03 +00:00
}
});}
2018-10-19 16:21:59 +00:00
});