From 7dc04b2f8fa076e30fd59fecaa4d77ec161ab518 Mon Sep 17 00:00:00 2001 From: Jens Maus Date: Fri, 16 Oct 2026 09:06:53 +0000 Subject: [PATCH 1/2] webui: show an error when a control panel popup fails to load This applies OpenCCU rootfs patch 0089-WebUI-MessagBoxFailureWarning.patch: - cpMessageBox.LoadFromFile() gets an onFailure handler. If the control panel page cannot be loaded, it hides the empty popup and its overlay and shows an error message instead of leaving the WebUI blocked. - CreateCPPopup(), cpMessageBox.initialize() and LoadFromFile() accept an optional errorLbl translation key for that message; without it, the common Ajax_failure() message is shown. --- .../www_source/config/js/cp_functions.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/webui/www_source/config/js/cp_functions.js b/src/webui/www_source/config/js/cp_functions.js index c557ce1a..4b61709a 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,7 +236,7 @@ cpMessageBox.prototype = this.removeMessagebox(); }, - LoadFromFile: function(src, pb) { + LoadFromFile: function(src, pb, errorLbl) { var url = src; if(url.indexOf('?sid=') === -1) { @@ -252,6 +252,15 @@ cpMessageBox.prototype = onComplete: function(trans) { centerMessageBox(); $('messagebox').style.display=""; + }, + onFailure: function(response) { + $('centerbox').hide(); + $('trlayer').hide(); + if(typeof errorLbl != 'undefined') { + MessageBox.show(translateKey('lblError'), translateKey(errorLbl), '', 480,120); + } else { + Ajax_failure(url, response.statusText); + } } }; new Ajax.Updater('messagebox',url,opt); From 0303c5bd446f5a936dabd3f4edd253ebb3623c1d Mon Sep 17 00:00:00 2001 From: Jens Maus Date: Fri, 16 Oct 2026 09:30:31 +0000 Subject: [PATCH 2/2] webui: show an error when a control panel popup fails with status 0 This applies the fix of OpenCCU/OpenCCU#4453, as found in the review of this PR: - Prototype treats HTTP status 0 (e.g. a network error) as success, so onFailure is not called. Handle status 0 in onComplete with the same error handling, now shared in showLoadError(). --- .../www_source/config/js/cp_functions.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/webui/www_source/config/js/cp_functions.js b/src/webui/www_source/config/js/cp_functions.js index 4b61709a..4834aed7 100644 --- a/src/webui/www_source/config/js/cp_functions.js +++ b/src/webui/www_source/config/js/cp_functions.js @@ -243,6 +243,15 @@ cpMessageBox.prototype = 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,17 +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) { - $('centerbox').hide(); - $('trlayer').hide(); - if(typeof errorLbl != 'undefined') { - MessageBox.show(translateKey('lblError'), translateKey(errorLbl), '', 480,120); - } else { - Ajax_failure(url, response.statusText); - } + showLoadError(response.statusText); } }; new Ajax.Updater('messagebox',url,opt);