Improve error page at loading

- Display the "Reload page" instantly and not after 5 seconds
- Remove stack trace, buggy anyway
- Wrap the error details so it does not expand beyond boundaries (scrollbar would not show up either)
- Do not show the slow-loading warning on error
- Make zeeoe details selectable instead of editable
- Label improvements
This commit is contained in:
Jérémie Astori 2017-12-16 16:19:51 -05:00
parent da7481c23c
commit 0ffd4d60d9
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
3 changed files with 50 additions and 20 deletions

View File

@ -160,6 +160,7 @@ kbd {
} }
#js-copy-hack, #js-copy-hack,
#loading pre,
#help, #help,
#windows .header .title, #windows .header .title,
#windows .header .topic, #windows .header .topic,
@ -1354,10 +1355,24 @@ part/quit messages where we don't load previews (adds a blank line otherwise) */
margin-top: 10px; margin-top: 10px;
} }
#loading-slow { #loading-slow,
#loading-reload {
display: none; display: none;
} }
#loading-reload {
margin-top: 15px;
}
#loading summary {
outline: none;
cursor: pointer;
}
#loading pre {
white-space: normal;
}
#sign-in label { #sign-in label {
display: block; display: block;
margin-top: 10px; margin-top: 10px;

View File

@ -53,10 +53,11 @@
</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>
<div id="loading-slow"> <p id="loading-slow">
<p>This is taking longer than it should, there might be connectivity issues.</p> This is taking longer than it should, there might be
<button id="loading-slow-reload" class="btn">Reload page</button> connectivity issues.
</div> </p>
<button id="loading-reload" class="btn">Reload page</button>
<script async src="js/loading-slow-alert.js"></script> <script async src="js/loading-slow-alert.js"></script>
</div> </div>
</div> </div>

View File

@ -8,40 +8,54 @@
* so that the timeout can be triggered while slow JS is loading * so that the timeout can be triggered while slow JS is loading
*/ */
setTimeout(function() { function displayReload() {
var element = document.getElementById("loading-slow"); var loadingReload = document.getElementById("loading-reload");
if (loadingReload) {
loadingReload.style.display = "block";
}
}
if (element) { var loadingSlowTimeout = setTimeout(function() {
element.style.display = "block"; var loadingSlow = document.getElementById("loading-slow");
// The parent element, #loading, is being removed when the app is loaded.
// Since the timer is not cancelled, `loadingSlow` can be not found after
// 5s. Wrap everything in this block to make sure nothing happens if the
// element does not exist (i.e. page has loaded).
if (loadingSlow) {
loadingSlow.style.display = "block";
displayReload();
} }
}, 5000); }, 5000);
document.getElementById("loading-slow-reload").addEventListener("click", function() { document.getElementById("loading-reload").addEventListener("click", function() {
location.reload(); location.reload();
}); });
window.g_LoungeErrorHandler = function LoungeErrorHandler(error) { window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
var title = document.getElementById("loading-title"); var title = document.getElementById("loading-title");
title.textContent = "An error has occured"; title.textContent = "An error has occured";
title = document.getElementById("loading-page-message"); var message = document.getElementById("loading-page-message");
title.textContent = "An error has occured that prevented the client from loading correctly."; message.textContent = "An error has occured that prevented the client from loading correctly.";
var summary = document.createElement("summary"); var summary = document.createElement("summary");
summary.textContent = "More details"; summary.textContent = "More details";
if (error instanceof ErrorEvent) {
error = error.message + "\n\n" + error.stack + "\n\nView developer tools console for more information and a better stacktrace.";
}
var data = document.createElement("pre"); var data = document.createElement("pre");
data.contentEditable = true; data.textContent = e.message; // e is an ErrorEvent
data.textContent = error;
var info = document.createElement("p");
info.textContent = "Open the developer tools of your browser for more information.";
var details = document.createElement("details"); var details = document.createElement("details");
details.appendChild(summary); details.appendChild(summary);
details.appendChild(data); details.appendChild(data);
title.parentNode.insertBefore(details, title.nextSibling); details.appendChild(info);
message.parentNode.insertBefore(details, message.nextSibling);
window.clearTimeout(loadingSlowTimeout);
displayReload();
}; };
window.addEventListener("error", window.g_LoungeErrorHandler); window.addEventListener("error", window.g_LoungeErrorHandler);