diff --git a/src/webui/www_source/config/js/cp_functions.js b/src/webui/www_source/config/js/cp_functions.js index c557ce1a..4834aed7 100644 --- a/src/webui/www_source/config/js/cp_functions.js +++ b/src/webui/www_source/config/js/cp_functions.js @@ -59,8 +59,8 @@ showNewFirmwareDownload = function() { CreateCPPopup("/config/cp_maintenance.cgi", "downloadOnly=1"); }; -CreateCPPopup = function(src, pb) { - dlgPopup = new cpMessageBox(src, pb); +CreateCPPopup = function(src, pb, errorLbl) { + dlgPopup = new cpMessageBox(src, pb, errorLbl); PopupClose = function() { dlgPopup.close(); @@ -100,7 +100,7 @@ cpMessageBox = Class.create(); cpMessageBox.prototype = { - initialize: function(src, pb) + initialize: function(src, pb, errorLbl) { if ( $('messagebox') ){ $("messagebox").hide(); @@ -112,7 +112,7 @@ cpMessageBox.prototype = this.setWidth(800); this.createMessagebox(); - this.LoadFromFile(src, pb); + this.LoadFromFile(src, pb, errorLbl); }, getViewPortDim : function() @@ -236,13 +236,22 @@ cpMessageBox.prototype = this.removeMessagebox(); }, - LoadFromFile: function(src, pb) { + LoadFromFile: function(src, pb, errorLbl) { var url = src; if(url.indexOf('?sid=') === -1) { url = url+'?sid='+SessionId; } var t = this; + var showLoadError = function(statusText) { + $('centerbox').hide(); + $('trlayer').hide(); + if(typeof errorLbl != 'undefined') { + MessageBox.show(translateKey('lblError'), translateKey(errorLbl), '', 480,120); + } else { + Ajax_failure(url, statusText); + } + }; var opt = { method: 'post', @@ -250,8 +259,16 @@ cpMessageBox.prototype = postBody: pb, sendXML: false, onComplete: function(trans) { + // Prototype treats status 0 (e.g. a network error) as success and does not call onFailure + if(trans.status == 0) { + showLoadError(trans.statusText); + return; + } centerMessageBox(); $('messagebox').style.display=""; + }, + onFailure: function(response) { + showLoadError(response.statusText); } }; new Ajax.Updater('messagebox',url,opt);