Wrap entire error loading script in anonymous function to avoid leaks
This commit is contained in:
parent
0ffd4d60d9
commit
84db8d8866
|
@ -8,14 +8,15 @@
|
||||||
* so that the timeout can be triggered while slow JS is loading
|
* so that the timeout can be triggered while slow JS is loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function displayReload() {
|
(function() {
|
||||||
|
var displayReload = function displayReload() {
|
||||||
var loadingReload = document.getElementById("loading-reload");
|
var loadingReload = document.getElementById("loading-reload");
|
||||||
if (loadingReload) {
|
if (loadingReload) {
|
||||||
loadingReload.style.display = "block";
|
loadingReload.style.display = "block";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var loadingSlowTimeout = setTimeout(function() {
|
var loadingSlowTimeout = setTimeout(function() {
|
||||||
var loadingSlow = document.getElementById("loading-slow");
|
var loadingSlow = document.getElementById("loading-slow");
|
||||||
|
|
||||||
// The parent element, #loading, is being removed when the app is loaded.
|
// The parent element, #loading, is being removed when the app is loaded.
|
||||||
|
@ -26,13 +27,13 @@ var loadingSlowTimeout = setTimeout(function() {
|
||||||
loadingSlow.style.display = "block";
|
loadingSlow.style.display = "block";
|
||||||
displayReload();
|
displayReload();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
document.getElementById("loading-reload").addEventListener("click", function() {
|
document.getElementById("loading-reload").addEventListener("click", function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
|
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";
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ window.g_LoungeErrorHandler = function LoungeErrorHandler(e) {
|
||||||
|
|
||||||
window.clearTimeout(loadingSlowTimeout);
|
window.clearTimeout(loadingSlowTimeout);
|
||||||
displayReload();
|
displayReload();
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("error", window.g_LoungeErrorHandler);
|
window.addEventListener("error", window.g_LoungeErrorHandler);
|
||||||
|
})();
|
||||||
|
|
Loading…
Reference in New Issue