Add service worker and offline page (needed to install the webapp on mobile devices)

This commit is contained in:
Lorenzo Breda
2021-09-10 22:35:59 +02:00
parent e9f2f56634
commit 16d39ff9d0
14 changed files with 250 additions and 2 deletions

View File

@@ -19,5 +19,17 @@
<body class="hold-transition login-page">
{% block content %}{% endblock %}
{% block scripts %}{% endblock %}
<script nonce="{{ JS_NONCE }}">
// Initialize the service worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('serviceworker.js?v={{ FF_VERSION }}', {
scope: '{{ route('index') }}'
}).then(
() => console.log('ServiceWorker registration successful'),
(err) => console.log('ServiceWorker registration failed: ', err)
);
}
</script>
</body>
</html>