Fix HTTPS warning positioning. Also doesn't matter for localhost

pull/246/head
Gordon Williams 2020-04-07 10:53:02 +01:00
parent 9f91b5559b
commit 3b2558ddd8
2 changed files with 5 additions and 13 deletions

View File

@ -65,18 +65,10 @@
</section>-->
</header>
<div class="floating">
<p id="requireHTTPS" class="hidden">
<b>STOP!</b> This page <b>must</b> be served over HTTPS.
Please <a>reload this page via HTTPS</a>.
</p>
</div>
<div class="container" style="padding-top:4px">
<p id="requireHTTPS" class="hidden">
<b>STOP!</b> This page <b>must</b> be served over HTTPS. Please <a>reload this page via HTTPS</a>.
</p>
<p><b>Note:</b> If you have a version of Bangle.js firmware before 2v04, please update to the <a href="https://www.espruino.com/Bangle.js#firmware-updates" target="_blank">latest firmware</a> or
<a href="https://banglejs.com/oldapps/">use the legacy app loader</a>.
</p>

View File

@ -45,9 +45,9 @@ if ('serviceWorker' in navigator) {
* Installability requires a service worker with a fetch event handler, and
* if the page isn't served over HTTPS, the service worker won't load.
*/
if (window.location.protocol === 'http:') {
if (window.location.protocol === 'http:' && window.location.hostname!="localhost") {
const requireHTTPS = document.getElementById('requireHTTPS');
const link = requireHTTPS.querySelector('a');
link.href = window.location.href.replace('http://', 'https://');
requireHTTPS.classList.remove('hidden');
}
}