{% comment %} PWA head tags for djust - include all PWA-related meta tags and scripts. {% endcomment %} /* Offline/Online body classes */ body.djust-offline [dj-offline-hide], body:not(.djust-online) [dj-offline-hide] { display: none !important; } body.djust-online [dj-offline-show], body:not(.djust-offline) [dj-offline-show] { display: none !important; } body.djust-offline [dj-offline-disable], body:not(.djust-online) [dj-offline-disable] { pointer-events: none !important; opacity: 0.5 !important; cursor: not-allowed !important; } /* Offline indicator animations */ @keyframes djust-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } body.djust-offline .djust-indicator-dot { animation: djust-pulse 2s ease-in-out infinite; } if ('serviceWorker' in navigator) { window.addEventListener('load', function() { navigator.serviceWorker.register('/sw.js', { scope: '/' }) .then(function(registration) { if (window.djust && window.djust.debug) { window.djust.debug('[djust] ServiceWorker registered, scope:', registration.scope); } // Check for updates periodically setInterval(() => { registration.update(); }, 60 * 60 * 1000); // Every hour // Handle updates registration.addEventListener('updatefound', () => { const newWorker = registration.installing; newWorker.addEventListener('statechange', () => { if (newWorker.state === 'installed' && navigator.serviceWorker.controller) { if (window.djust && window.djust.offline) { window.djust.offline.onUpdateAvailable(registration); } } }); }); }) .catch(function(error) { if (window.djust && window.djust.reportError) { window.djust.reportError('[djust] ServiceWorker registration failed:', error); } }); }); }