make fallback error dismissable

sometimes, an error is not that fatal, and the user may want
to dismiss it, so add a button to do exactly that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-12-21 13:54:19 +01:00
parent 679b45fa3b
commit ea821b5512
2 changed files with 14 additions and 2 deletions

View File

@ -17,9 +17,11 @@ function handleError(event, err) {
return false;
}
// Only show the initial error
// Clear last error
if (msg.hasChildNodes()) {
return false;
while (msg.firstChild) {
msg.removeChild(msg.firstChild);
}
}
let div = document.createElement("div");
@ -58,5 +60,14 @@ function handleError(event, err) {
return false;
}
function hideError() {
document.getElementById('noVNC_fallback_error')
.classList.remove("noVNC_open");
}
window.addEventListener('load', () => {
document.getElementById("noVNC_error_dismiss_button")
.addEventListener('click', hideError);
});
window.addEventListener('error', evt => handleError(evt, evt.error));
window.addEventListener('unhandledrejection', evt => handleError(evt.reason, evt.reason));

View File

@ -66,6 +66,7 @@
<div>noVNC encountered an error:</div>
<br>
<div id="noVNC_fallback_errormsg"></div>
<input id="noVNC_error_dismiss_button" type="button" value="Dismiss" class="noVNC_submit">
</div>
</div>