Permalink
Browse files

FIX: Improved network error popup handling

Network error popups are now shown when an error occurs and hidden again automatically when a subsequent call succeeds
  • Loading branch information...
LarsMichelsen committed Sep 18, 2018
1 parent c36dc13 commit 0eeff8fe363a1c9f44489d7f1c25923e05e65f1f
View
@@ -1,4 +1,7 @@
1.9.10
Frontend
* FIX: Network error popups are now shown when an error occurs and hidden again
automatically when a subsequent call succeeds
1.9.9
Frontend:
@@ -72,6 +72,11 @@ function call_ajax(url, args)
AJAX.onreadystatechange = function() {
if (AJAX && AJAX.readyState == 4) {
if (AJAX.status == 200) {
// in case this is no error remove all frontend messages of type
// serverError which might have been shown by the default
// args.error_handler.
frontendMessageRemove('serverError');
var response = AJAX.responseText;
if (args.decode_json) {
try {
@@ -97,10 +102,6 @@ function call_ajax(url, args)
args.error_handler(AJAX.status, response, args.handler_data);
return '';
}
// in case this is no error remove all frontend messages of type
// serverError which might have been shown by the default
// args.error_handler.
frontendMessageRemove('serverError');
}
if (args.response_handler)
@@ -34,6 +34,10 @@ function frontendMessageRemove(key) {
}
}
function frontendMessageAdd(key, container) {
frontendMessages[key] = container;
}
function frontendMessage(oMessage, key) {
if (oMessage === null) {
throw "Could not display empty frontendMessage()";
@@ -51,8 +55,9 @@ function frontendMessage(oMessage, key) {
if (isset(key) && frontendMessagePresent(key))
return;
popupWindow(sTitle, {'code': '<div class="'+oMessage.type.toLowerCase()+'">'
var container = popupWindow(sTitle, {'code': '<div class="'+oMessage.type.toLowerCase()+'">'
+oMessage.message+'</div>'}, 500, closable);
frontendMessageAdd(key, container);
// Maybe there is a request for a reload/redirect
if (typeof oMessage.reloadTime !== 'undefined' && oMessage.reloadTime !== null) {
@@ -101,16 +101,7 @@ function popupWindowPutContent(oContent) {
}
}
/**
* popupWindow()
*
* Creates a javascript dialog
*
* @param String Window title
* @param Object Object containing the contents
* @return Boolean
* @author Lars Michelsen <lm@larsmichelsen.com>
*/
// Creates a javascript dialog
function popupWindow(title, oContent, sWidth, closable) {
if(oContent === null || oContent.code === null)
return false;
@@ -167,9 +158,8 @@ function popupWindow(title, oContent, sWidth, closable) {
content = null;
document.body.appendChild(oContainerDiv);
oContainerDiv = null;
popupWindowPutContent(oContent);
return false;
return oContainerDiv;
}

0 comments on commit 0eeff8f

Please sign in to comment.