summaryrefslogtreecommitdiff
path: root/misc/batch.js
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-05-04 09:41:37 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-05-04 09:41:37 +0000
commitc740ac7fd58b5f4597bde987ae9263f3d05febd8 (patch)
tree0eb9221dd27cfa6d308e99babc41b1f9fd474c7b /misc/batch.js
parent304400293a997a76290f04c7d1d65680fef2c7d8 (diff)
downloadbrdo-c740ac7fd58b5f4597bde987ae9263f3d05febd8.tar.gz
brdo-c740ac7fd58b5f4597bde987ae9263f3d05febd8.tar.bz2
#127539: progressive operation support, refactoring update.php code to a generic batch API to support runnning operations in multiple HTTP requests
- update.php is already on the batch API - node access rebuilding is in the works - automatic locale importing is in the works Thanks to Yves Chedemois (yched) for the good code quality, very wide awareness of issues related to batches, and the fantastic turnaround times. Hats off.
Diffstat (limited to 'misc/batch.js')
-rw-r--r--misc/batch.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/misc/batch.js b/misc/batch.js
new file mode 100644
index 000000000..43117e243
--- /dev/null
+++ b/misc/batch.js
@@ -0,0 +1,31 @@
+if (Drupal.jsEnabled) {
+ $(document).ready(function() {
+ $('#progress').each(function () {
+ var holder = this;
+ var uri = Drupal.settings.batch.uri;
+ var initMessage = Drupal.settings.batch.initMessage;
+ var errorMessage = Drupal.settings.batch.errorMessage;
+
+ // Success: redirect to the summary.
+ var updateCallback = function (progress, status, pb) {
+ if (progress == 100) {
+ pb.stopMonitoring();
+ window.location = uri+'&op=finished';
+ }
+ }
+
+ var errorCallback = function (pb) {
+ var div = document.createElement('p');
+ div.className = 'error';
+ $(div).html(errorMessage);
+ $(holder).prepend(div);
+ $('#wait').hide();
+ }
+
+ var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
+ progress.setProgress(-1, initMessage);
+ $(holder).append(progress.element);
+ progress.startMonitoring(uri+'&op=do', 10);
+ });
+ });
+}