From 760356c4ffc56a3c622e4a4ac4b7a73f74132a83 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 6 Nov 2020 19:28:36 +0530 Subject: [PATCH] patch loading.js --- customize.dist/loading.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index edb66ef0a..1db126fa5 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -312,15 +312,24 @@ button.primary:hover{ return bar; }; + var hideSpinner = function () { + try { + document.querySelector('.cp-loading-spinner-container').style.display = 'none'; + document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); + } catch (err) { return; } + }; + var hasErrored = false; var updateLoadingProgress = function (data) { if (!built || !data) { return; } var c = types.indexOf(data.type); if (c < current) { return console.error(data); } try { - document.querySelector('.cp-loading-spinner-container').style.display = 'none'; - document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data); - document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data); + hideSpinner(); + var list = document.querySelector('.cp-loading-progress-list'); + list && (list.innerHTML = makeList(data)); + var container = document.querySelector('.cp-loading-progress-container'); + container && (container.innerHTML = makeBar(data)); } catch (e) { if (!hasErrored) { console.error(e); } } @@ -329,6 +338,7 @@ button.primary:hover{ window.CryptPad_loadingError = function (err) { if (!built) { return; } + console.error(err); hasErrored = true; var err2; if (err === 'Script error.') { @@ -339,10 +349,12 @@ button.primary:hover{ var node = document.querySelector('.cp-loading-progress'); if (!node) { return; } if (node.parentNode) { node.parentNode.removeChild(node); } - document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); + hideSpinner(); document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;'); document.querySelector('#cp-loading-message').innerText = err2 || err; - } catch (e) { console.error(e); } + } catch (e) { + console.error(e); + } }; return function () { built = true;