2016-12-18 15:53:28 +00:00
|
|
|
/* eslint strict: 0 */
|
2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2016-06-07 17:56:49 +00:00
|
|
|
/*
|
|
|
|
* This is a separate file for two reasons:
|
|
|
|
* 1. CSP policy does not allow inline javascript
|
|
|
|
* 2. It has to be a small javascript executed before all other scripts,
|
|
|
|
* so that the timeout can be triggered while slow JS is loading
|
|
|
|
*/
|
|
|
|
|
2017-12-16 21:19:51 +00:00
|
|
|
function displayReload() {
|
|
|
|
var loadingReload = document.getElementById("loading-reload");
|
|
|
|
if (loadingReload) {
|
|
|
|
loadingReload.style.display = "block";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var loadingSlowTimeout = setTimeout(function() {
|
|
|
|
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();
|
2016-06-07 17:56:49 +00:00
|
|
|
}
|
|
|
|
}, 5000);
|
2017-05-09 13:12:12 +00:00
|
|
|
|
2017-12-16 21:19:51 +00:00
|
|
|
document.getElementById("loading-reload").addEventListener("click", function() {
|
2017-05-09 13:12:12 +00:00
|
|
|
location.reload();
|
|
|
|
});
|
2017-12-01 18:04:50 +00:00
|
|
|
|
2017-12-16 21:19:51 +00:00
|
|
|
window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
|
2017-12-01 18:04:50 +00:00
|
|
|
var title = document.getElementById("loading-title");
|
|
|
|
title.textContent = "An error has occured";
|
|
|
|
|
2017-12-16 21:19:51 +00:00
|
|
|
var message = document.getElementById("loading-page-message");
|
|
|
|
message.textContent = "An error has occured that prevented the client from loading correctly.";
|
2017-12-01 18:04:50 +00:00
|
|
|
|
2017-12-05 13:17:31 +00:00
|
|
|
var summary = document.createElement("summary");
|
|
|
|
summary.textContent = "More details";
|
|
|
|
|
|
|
|
var data = document.createElement("pre");
|
2017-12-16 21:19:51 +00:00
|
|
|
data.textContent = e.message; // e is an ErrorEvent
|
|
|
|
|
|
|
|
var info = document.createElement("p");
|
|
|
|
info.textContent = "Open the developer tools of your browser for more information.";
|
2017-12-05 13:17:31 +00:00
|
|
|
|
|
|
|
var details = document.createElement("details");
|
|
|
|
details.appendChild(summary);
|
|
|
|
details.appendChild(data);
|
2017-12-16 21:19:51 +00:00
|
|
|
details.appendChild(info);
|
|
|
|
message.parentNode.insertBefore(details, message.nextSibling);
|
|
|
|
|
|
|
|
window.clearTimeout(loadingSlowTimeout);
|
|
|
|
displayReload();
|
2017-12-01 18:04:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener("error", window.g_LoungeErrorHandler);
|