-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from iturgeon/issue/52-udoit-submit-handle-pro…
…cess-error handle process.php and progress.php errors in ajax
- Loading branch information
Showing
1 changed file
with
14 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
* | ||
* Primary Author Contact: Jacob Bates <[email protected]> | ||
*/ | ||
|
||
var progressTimer = null; | ||
|
||
/* Fades out and destroys the popup window and background. */ | ||
function killButton(callback) { | ||
if($("#popup").length > 0) { | ||
|
@@ -85,6 +88,7 @@ function checker() { | |
context_title: context_title | ||
}, | ||
success: function(data){ | ||
clearInterval(progressTimer); | ||
$('#scanner').append('<section id="result">'+data+'</section>'); | ||
killButton(function() { | ||
$('#result').fadeIn(); | ||
|
@@ -93,6 +97,7 @@ function checker() { | |
jscolor.bind(); | ||
}, | ||
error: function(data){ | ||
clearInterval(progressTimer); | ||
killButton(); | ||
$('#failMsg').fadeIn(); | ||
} | ||
|
@@ -145,30 +150,20 @@ $(document).ready(function() { | |
|
||
var old = 0; | ||
|
||
var timer = setInterval(function(){ | ||
|
||
// start progress checker, this is cleared here or from checker() | ||
clearInterval(progressTimer); | ||
progressTimer = setInterval(function(){ | ||
$.ajax({ | ||
url: 'lib/progress.php', | ||
error: function(xhr, status, error) { | ||
clearInterval(progressTimer); | ||
}, | ||
success: function(data){ | ||
// update display if progress state has changed | ||
if(data != old) { | ||
if(data == 'announcements') { | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning announcements...'); | ||
} | ||
if(data == 'assignments') { | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning assignments...'); | ||
} | ||
if(data == 'discussions') { | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning discussions...'); | ||
} | ||
if(data == 'files') { | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning files...'); | ||
} | ||
if(data == 'pages') { | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning pages...'); | ||
} | ||
if(data == 'done') { | ||
clearInterval(timer); | ||
} | ||
old = data; | ||
$('#submit').html('<div id="popup"><div class="circle"></div></div> Scanning '+data+'...'); | ||
} | ||
} | ||
}); | ||
|