From 59eaf8187c9a097fc0f679da784ed2615e9b1bd8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 Nov 2020 10:28:52 +0530 Subject: [PATCH] handle unhelpful 'Script error.' message --- customize.dist/loading.js | 16 +++++++++++++--- www/common/sframe-boot2.js | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/customize.dist/loading.js b/customize.dist/loading.js index 4f8b79125..740c66081 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -312,25 +312,35 @@ button.primary:hover{ return bar; }; + var hasErrored = false; var updateLoadingProgress = function (data) { - if (!built) { return; } + 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); - } catch (e) { console.error(e); } + } catch (e) { + if (!hasErrored) { console.error(e); } + } }; window.CryptPad_updateLoadingProgress = updateLoadingProgress; + window.CryptPad_loadingError = function (err) { if (!built) { return; } + hasErrored = true; + var err2; + if (err === 'Script error.') { + err2 = Messages.error_unhelpfulScriptError; + } + try { var node = document.querySelector('.cp-loading-progress'); if (node.parentNode) { node.parentNode.removeChild(node); } document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;'); document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;'); - document.querySelector('#cp-loading-message').innerText = err; + document.querySelector('#cp-loading-message').innerText = err2 || err; } catch (e) { console.error(e); } }; return function () { diff --git a/www/common/sframe-boot2.js b/www/common/sframe-boot2.js index 5a68237ad..66a93545f 100644 --- a/www/common/sframe-boot2.js +++ b/www/common/sframe-boot2.js @@ -43,7 +43,7 @@ define([ return void console.log(); } if (window.CryptPad_loadingError) { - window.CryptPad_loadingError(e); + return void window.CryptPad_loadingError(e); } throw e; };