diff --git a/src/static/css/pad/gritter.css b/src/static/css/pad/gritter.css index 076062339..e17367efa 100644 --- a/src/static/css/pad/gritter.css +++ b/src/static/css/pad/gritter.css @@ -14,13 +14,15 @@ .gritter-item.popup { position: relative; - max-width: 450px; visibility: visible; right: auto !important; left: auto !important; top: auto; bottom: auto; } +.gritter-item.popup:not(.error) { + max-width: 450px; +} .gritter-item .popup-content { display: flex; diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index d42cbb022..fbbefdae4 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -526,12 +526,30 @@ function setupGlobalExceptionHandler() { { var errorId = randomString(20); var userAgent = padutils.escapeHtml(navigator.userAgent); - if ($("#editorloadingbox").attr("display") != "none"){ - //show javascript errors to the user - $("#editorloadingbox").css("padding", "10px"); - $("#editorloadingbox").css("padding-top", "45px"); - $("#editorloadingbox").html("
An error occurred
The error was reported with the following id: '" + errorId + "'

Please press and hold Ctrl and press F5 to reload this page, if the problem persists please send this error message to your webmaster:
'" - + "ErrorId: " + errorId + "
URL: " + padutils.escapeHtml(window.location.href) + "
UserAgent: " + userAgent + "
" + msg + " in " + url + " at line " + linenumber + "'
"); + + var msgAlreadyVisible = false; + $('.gritter-item .error-msg').each(function() { + if ($(this).text() === msg) { + msgAlreadyVisible = true; + } + }); + + if (!msgAlreadyVisible) { + errorMsg = "Please press and hold Ctrl and press F5 to reload this page
\ + If the problem persists please send this error message to your webmaster:

\ +
\ + ErrorId: " + errorId + "
\ + URL: " + padutils.escapeHtml(window.location.href) + "
\ + UserAgent: " + userAgent + "
\ + "+ msg + " in " + url + " at line " + linenumber + '
'; + + $.gritter.add({ + title: "An error occurred", + text: errorMsg, + class_name: "error", + position: 'bottom', + sticky: true, + }); } //send javascript errors to the server