Handle javascript errors while loading
This commit is contained in:
parent
2f47307437
commit
e3823803aa
@ -48,7 +48,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<h1 class="title">The Lounge is loading…</h1>
|
<h1 class="title" id="loading-title">The Lounge is loading…</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<p id="loading-page-message">Loading the app… <a href="http://enable-javascript.com/" target="_blank" rel="noopener">Make sure to have JavaScript enabled.</a></p>
|
<p id="loading-page-message">Loading the app… <a href="http://enable-javascript.com/" target="_blank" rel="noopener">Make sure to have JavaScript enabled.</a></p>
|
||||||
|
@ -19,3 +19,18 @@ setTimeout(function() {
|
|||||||
document.getElementById("loading-slow-reload").addEventListener("click", function() {
|
document.getElementById("loading-slow-reload").addEventListener("click", function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.g_LoungeErrorHandler = function LoungeErrorHandler(error) {
|
||||||
|
var title = document.getElementById("loading-title");
|
||||||
|
title.textContent = "An error has occured";
|
||||||
|
|
||||||
|
title = document.getElementById("loading-page-message");
|
||||||
|
title.textContent = "An error has occured that prevented the client from loading correctly.";
|
||||||
|
|
||||||
|
var element = document.createElement("p");
|
||||||
|
element.contentEditable = true;
|
||||||
|
element.textContent = error instanceof ErrorEvent ? error.message : error;
|
||||||
|
title.parentNode.insertBefore(element, title.nextSibling);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("error", window.g_LoungeErrorHandler);
|
||||||
|
@ -44,6 +44,11 @@ socket.on("init", function(data) {
|
|||||||
$("body").removeClass("signed-out");
|
$("body").removeClass("signed-out");
|
||||||
$("#loading").remove();
|
$("#loading").remove();
|
||||||
$("#sign-in").remove();
|
$("#sign-in").remove();
|
||||||
|
|
||||||
|
if (window.g_LoungeErrorHandler) {
|
||||||
|
window.removeEventListener("error", window.g_LoungeErrorHandler);
|
||||||
|
window.g_LoungeErrorHandler = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openCorrectChannel(previousActive, data.active);
|
openCorrectChannel(previousActive, data.active);
|
||||||
|
Loading…
Reference in New Issue
Block a user