From d9206c10877280d90fd3cf111885d8f928a8454c Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 13 Jul 2018 10:37:39 +0300 Subject: [PATCH] Check if element exists before trying to change message --- client/js/loading-error-handlers.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/js/loading-error-handlers.js b/client/js/loading-error-handlers.js index 79523547..785a786c 100644 --- a/client/js/loading-error-handlers.js +++ b/client/js/loading-error-handlers.js @@ -9,7 +9,15 @@ */ (function() { - document.getElementById("loading-page-message").textContent = "Loading the app…"; + const msg = document.getElementById("loading-page-message"); + + if (msg) { + msg.textContent = "Loading the app…"; + + document.getElementById("loading-reload").addEventListener("click", function() { + location.reload(true); + }); + } var displayReload = function displayReload() { var loadingReload = document.getElementById("loading-reload"); @@ -32,10 +40,6 @@ } }, 5000); - document.getElementById("loading-reload").addEventListener("click", function() { - location.reload(); - }); - window.g_LoungeErrorHandler = function LoungeErrorHandler(e) { var message = document.getElementById("loading-page-message"); message.textContent = "An error has occurred that prevented the client from loading correctly.";