Map lighbox on permalink fixed
This commit is contained in:
parent
2d38a1673b
commit
981c56ed24
1 changed files with 3 additions and 3 deletions
|
|
@ -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))); }
|
||||
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=>{
|
||||
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;
|
||||
await state(reg);
|
||||
btn.addEventListener('click', async ()=>{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
const perm=await Notification.requestPermission();
|
||||
if(perm!=='granted') return;
|
||||
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);
|
||||
}catch(e){ alert(e.message || 'Could not update notifications'); }
|
||||
|
|
@ -28,4 +28,4 @@
|
|||
});
|
||||
})();
|
||||
</script>
|
||||
<script src="js/map_lightbox.js?v=20260531b" defer></script>
|
||||
<script src="/js/map_lightbox.js?v=20260531b" defer></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue