Imported drupal-5.3
[drupal.git] / misc / update.js
blobaa422f19d930b5565343946e9b3bc90ae8a0fe80
1 // $Id: update.js,v 1.10 2006/12/27 14:11:45 unconed Exp $
3 if (Drupal.jsEnabled) {
4 $(document).ready(function() {
5 $('#edit-has-js').each(function() { this.value = 1; });
6 $('#progress').each(function () {
7 var holder = this;
9 // Success: redirect to the summary.
10 var updateCallback = function (progress, status, pb) {
11 if (progress == 100) {
12 pb.stopMonitoring();
13 window.location = window.location.href.split('op=')[0] +'op=finished';
17 // Failure: point out error message and provide link to the summary.
18 var errorCallback = function (pb) {
19 var div = document.createElement('p');
20 div.className = 'error';
21 $(div).html('An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>');
22 $(holder).prepend(div);
23 $('#wait').hide();
26 var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
27 progress.setProgress(-1, 'Starting updates');
28 $(holder).append(progress.element);
29 progress.startMonitoring('update.php?op=do_update', 0);
30 });
31 });