Add contact page/includes and refine header action/logo styling
This commit is contained in:
parent
613d7e15a3
commit
be9da9fe86
7 changed files with 404 additions and 231 deletions
31
_footer.php
Normal file
31
_footer.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<footer>Bubulescu.Org</footer>
|
||||
<script>
|
||||
(function(){
|
||||
const btn=document.getElementById('push-toggle');
|
||||
if(!btn || !('serviceWorker' in navigator) || !('PushManager' in window) || !('Notification' in window)) return;
|
||||
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}));
|
||||
if(!cfg.enabled || !cfg.publicKey) return;
|
||||
await state(reg);
|
||||
btn.addEventListener('click', async ()=>{
|
||||
btn.disabled=true;
|
||||
try{
|
||||
let sub=await reg.pushManager.getSubscription();
|
||||
if(sub){
|
||||
return;
|
||||
}else{
|
||||
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 state(reg);
|
||||
}catch(e){ alert(e.message || 'Could not update notifications'); }
|
||||
finally{ await state(reg); }
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script src="js/map_lightbox.js?v=20260531b" defer></script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue