diff --git a/app/styles/base.css b/app/styles/base.css index 03f6583e..b90bcb26 100644 --- a/app/styles/base.css +++ b/app/styles/base.css @@ -172,6 +172,43 @@ input[type=button]:active, select:active { pointer-events: auto; } +/* ---------------------------------------- + * Fallback error + * ---------------------------------------- + */ + +#noVNC_fallback_error { + position: fixed; + z-index: 3; + left: 50%; + transform: translate(-50%, -50px); + transition: 0.5s ease-in-out; + + visibility: hidden; + opacity: 0; + + top: 60px; + padding: 15px; + width: auto; + + text-align: center; + font-weight: bold; + word-wrap: break-word; + color: #fff; + + border-radius: 10px; + box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5); + background: rgba(200,55,55,0.8); +} +#noVNC_fallback_error.noVNC_open { + transform: translate(-50%, 0); + visibility: visible; + opacity: 1; +} +#noVNC_fallback_errormsg { + font-weight: normal; +} + /* ---------------------------------------- * Control Bar * ---------------------------------------- diff --git a/app/ui.js b/app/ui.js index 1e55652b..ceb72092 100644 --- a/app/ui.js +++ b/app/ui.js @@ -25,6 +25,21 @@ var UI; (function () { "use strict"; + // Fallback for all uncought errors + window.addEventListener('error', function(msg, url, line) { + try { + document.getElementById('noVNC_fallback_error') + .classList.add("noVNC_open"); + document.getElementById('noVNC_fallback_errormsg').innerHTML = + url + ' (' + line + ')

' + msg; + } catch (exc) { + document.write("noVNC encountered an error."); + } + // Don't return true since this would prevent the error + // from being printed to the browser console. + return false; + }); + /* [begin skip-as-module] */ // Load supporting scripts WebUtil.load_scripts( diff --git a/vnc.html b/vnc.html index 01828b44..ef880d20 100644 --- a/vnc.html +++ b/vnc.html @@ -65,6 +65,12 @@ + +
+
noVNC encountered an error:
+
+
+