-
Notifications
You must be signed in to change notification settings - Fork 0
/
bible_webimport.js
38 lines (33 loc) · 1.13 KB
/
bible_webimport.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function ($) {
Drupal.behaviors.biblewebimport = {
attach : function (context, settings) {
$('#progress').each(function () {
var holder = this;
var url = Drupal.settings.bibleurl;
var para = Drupal.settings.biblepara;
var inimsg = Drupal.settings.bibleimsg;
var errmsg = Drupal.settings.bibleemsg;
if (!url) return;
// Success: redirect to the summary.
var updateCallback = function (progress, status, pb) {
if (progress == 100) {
pb.stopMonitoring();
window.location = url;
}
}
// Failure: point out error message and provide link to the summary.
var errorCallback = function (pb) {
var div = document.createElement('p');
div.className = 'error';
$(div).html(errmsg);
$(holder).prepend(div);
$('#wait').hide();
}
var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
progress.setProgress(-1, inimsg);
$(holder).append(progress.element);
progress.startMonitoring(url + para + "&op=bible_webimport", 0);
});
}
};
})(jQuery);