summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-03-01 22:19:24 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-03-01 22:19:24 +0000
commit3f2b287d7c6ce2f9ea798406e2458421fb4b0371 (patch)
tree5e6ae137f781c325a84acf8811f7e71256ec6b4b /misc
parent9a014043a467e9710d93c66580b33f374e2f4223 (diff)
downloadbrdo-3f2b287d7c6ce2f9ea798406e2458421fb4b0371.tar.gz
brdo-3f2b287d7c6ce2f9ea798406e2458421fb4b0371.tar.bz2
- #49501: Improve error reporting in the update system
Diffstat (limited to 'misc')
-rw-r--r--misc/progress.js29
-rw-r--r--misc/update.js6
2 files changed, 28 insertions, 7 deletions
diff --git a/misc/progress.js b/misc/progress.js
index 84979d68f..776e2b637 100644
--- a/misc/progress.js
+++ b/misc/progress.js
@@ -8,11 +8,12 @@
* e.g. pb = new progressBar('myProgressBar');
* some_element.appendChild(pb.element);
*/
-function progressBar(id, callback, method) {
+function progressBar(id, updateCallback, method, errorCallback) {
var pb = this;
this.id = id;
this.method = method ? method : HTTPGet;
- this.callback = callback;
+ this.updateCallback = updateCallback;
+ this.errorCallback = errorCallback;
this.element = document.createElement('div');
this.element.id = id;
@@ -41,8 +42,8 @@ progressBar.prototype.setProgress = function (percentage, message) {
divs[i].innerHTML = message;
}
}
- if (this.callback) {
- this.callback(percentage, message, this);
+ if (this.updateCallback) {
+ this.updateCallback(percentage, message, this);
}
}
@@ -82,13 +83,13 @@ progressBar.prototype.sendPing = function () {
*/
progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
if (xmlhttp.status != 200) {
- return alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
+ return pb.displayError('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
}
// Parse response
var progress = parseJson(string);
// Display errors
if (progress.status == 0) {
- alert(progress.data);
+ pb.displayError(progress.data);
return;
}
@@ -97,3 +98,19 @@ progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
// Schedule next timer
pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
}
+
+/**
+ * Display errors on the page.
+ */
+progressBar.prototype.displayError = function (string) {
+ var error = document.createElement('div');
+ error.className = 'error';
+ error.appendChild(document.createTextNode(string));
+
+ this.element.style.display = 'none';
+ this.element.parentNode.insertBefore(error, this.element);
+
+ if (this.errorCallback) {
+ this.errorCallback(this);
+ }
+}
diff --git a/misc/update.js b/misc/update.js
index 2586fbf50..e595e4cb2 100644
--- a/misc/update.js
+++ b/misc/update.js
@@ -12,7 +12,11 @@ if (isJsEnabled()) {
}
}
- var progress = new progressBar('updateprogress', updateCallback, HTTPPost);
+ errorCallback = function (pb) {
+ window.location = window.location.href.split('op=')[0] +'op=error';
+ }
+
+ var progress = new progressBar('updateprogress', updateCallback, HTTPPost, errorCallback);
progress.setProgress(-1, 'Starting updates');
$('progress').appendChild(progress.element);
progress.startMonitoring('update.php?op=do_update', 0);