From 5810f17c31b81a85babc12d4aea5c8223e348bec Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 17 Sep 2019 21:41:25 +0200 Subject: [PATCH] fixing HTTP only error detection in Chrome and Android by ensuring all logic is contained in legacy.js --- js/legacy.js | 38 ++++++++++++++++++++++++++++++++++++-- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/js/legacy.js b/js/legacy.js index e0662e8..acfb595 100644 --- a/js/legacy.js +++ b/js/legacy.js @@ -188,6 +188,35 @@ jQuery.Legacy = (function($) { return false; } + /** + * shows an error message + * + * @private + * @name Check.showError + * @param {string} message + * @function + */ + function showError(message) + { + var $error = $('#errormessage'), + $glyphIcon = $error.find(':first'), + $element; + if ($glyphIcon.length) { + // if there is an icon, we need to provide an inner element + // to translate the message into, instead of the parent + $element = $(''); + $error.html(' ').prepend($glyphIcon).append($element); + } else { + $element = $error; + } + if (message.indexOf('switching to HTTPS.', 'https' + window.location.href.slice(4)]); + showError( + 'Your browser may require an HTTPS connection to support the WebCrypto API. Try switching to HTTPS.'.replace( + '%s', + 'https' + window.location.href.slice(4) + ) + ); } $('#oldnotice').removeClass('hidden'); init = true; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index f1df743..f0ab0b5 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -71,7 +71,7 @@ if ($MARKDOWN): endif; ?> - +