Prevent multiple downloads in Chrome
This commit is contained in:
parent
f1fa110eb2
commit
f8eb917a94
1 changed files with 43 additions and 38 deletions
|
@ -7,50 +7,55 @@ function toggleOptions() {
|
|||
}
|
||||
|
||||
function lockform() {
|
||||
$("#theform :input").prop("disabled", true);
|
||||
$body.addClass("loading");
|
||||
$("#theform :input").prop("disabled", true);
|
||||
$body.addClass("loading");
|
||||
}
|
||||
|
||||
function unlockform() {
|
||||
$("#theform :input").prop("disabled", false);
|
||||
$body.removeClass("loading");
|
||||
$("#theform :input").prop("disabled", false);
|
||||
$body.removeClass("loading");
|
||||
}
|
||||
|
||||
$('#theform').submit(function(event){
|
||||
event.preventDefault();
|
||||
if(this.checkValidity()) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/addjob",
|
||||
data: $('#theform').serialize(),
|
||||
success: function(msg){
|
||||
lockform();
|
||||
interval = setInterval(checkServerForFile,3000,msg);
|
||||
function checkServerForFile(jobid) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
cache: false,
|
||||
url: "/getjob/" + jobid,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
clearInterval(interval);
|
||||
unlockform();
|
||||
},
|
||||
200: function() {
|
||||
clearInterval(interval);
|
||||
unlockform();
|
||||
window.location.href = "/getjob/" + jobid
|
||||
},
|
||||
500: function() {
|
||||
clearInterval(interval);
|
||||
window.alert("Failed to process request. The URL may be incorrect or unsupported.")
|
||||
unlockform();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
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();
|
||||
window.location.href = "/getjob/" + jobid
|
||||
},
|
||||
500: function() {
|
||||
clearInterval(interval);
|
||||
window.alert("Failed to process request. The URL may be incorrect or unsupported.")
|
||||
unlockform();
|
||||
}
|
||||
}
|
||||
});
|
||||
window.panaxworking = false;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
});}
|
||||
}
|
||||
});}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue