Map lighbox on permalink fixed

This commit is contained in:
hbrain 2026-06-20 20:16:16 +02:00
parent 2d38a1673b
commit 981c56ed24

View file

@ -6,7 +6,7 @@
function b64uToUint8Array(s){ const pad='='.repeat((4-s.length%4)%4); const b64=(s+pad).replace(/-/g,'+').replace(/_/g,'/'); const raw=atob(b64); return Uint8Array.from([...raw].map(c=>c.charCodeAt(0))); } function b64uToUint8Array(s){ const pad='='.repeat((4-s.length%4)%4); const b64=(s+pad).replace(/-/g,'+').replace(/_/g,'/'); const raw=atob(b64); return Uint8Array.from([...raw].map(c=>c.charCodeAt(0))); }
async function state(reg){ const sub=await reg.pushManager.getSubscription(); btn.classList.toggle('active', !!sub); btn.title=sub?'Notifications on':'Notifications'; btn.hidden=false; return sub; } async function state(reg){ const sub=await reg.pushManager.getSubscription(); btn.classList.toggle('active', !!sub); btn.title=sub?'Notifications on':'Notifications'; btn.hidden=false; return sub; }
navigator.serviceWorker.register('/sw.js').then(async reg=>{ navigator.serviceWorker.register('/sw.js').then(async reg=>{
const cfg=await fetch('push_config.php',{cache:'no-store'}).then(r=>r.json()).catch(()=>({enabled:false})); const cfg=await fetch('/push_config.php',{cache:'no-store'}).then(r=>r.json()).catch(()=>({enabled:false}));
if(!cfg.enabled || !cfg.publicKey) return; if(!cfg.enabled || !cfg.publicKey) return;
await state(reg); await state(reg);
btn.addEventListener('click', async ()=>{ btn.addEventListener('click', async ()=>{
@ -19,7 +19,7 @@
const perm=await Notification.requestPermission(); const perm=await Notification.requestPermission();
if(perm!=='granted') return; if(perm!=='granted') return;
sub=await reg.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:b64uToUint8Array(cfg.publicKey)}); sub=await reg.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:b64uToUint8Array(cfg.publicKey)});
await fetch('push_subscribe.php',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(sub)}); await fetch('/push_subscribe.php',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(sub)});
} }
await state(reg); await state(reg);
}catch(e){ alert(e.message || 'Could not update notifications'); } }catch(e){ alert(e.message || 'Could not update notifications'); }
@ -28,4 +28,4 @@
}); });
})(); })();
</script> </script>
<script src="js/map_lightbox.js?v=20260531b" defer></script> <script src="/js/map_lightbox.js?v=20260531b" defer></script>