Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
1.1 KiB
JavaScript
13 lines
1.1 KiB
JavaScript
async function loadNear(){let d={};try{d=await (await fetch("/api/adsb",{cache:"no-store"})).json()}catch(e){}
|
||
const l=(d.list||[]);const age=d.t?Math.round(Date.now()/1000-d.t):null;
|
||
// aircraft nearby (ADS-B): just the chips; the box is hidden when there are none
|
||
$("#near").innerHTML=l.slice(0,10).map(acChip).join("")+(l.length>10?`<span class="ac">+${l.length-10}</span>`:"");
|
||
$("#near").title=`ADS-B ${d.src||""}${age!=null?" · "+age+" с назад":""}`;
|
||
$("#near").hidden=!l.length}
|
||
loadNear();setInterval(()=>{if(!document.hidden&&!$("#list").hidden)loadNear()},60000);
|
||
function setTab(t){const src=t==="src";$("#nearwrap").hidden=src;document.body.classList.toggle("srcmode",src);$("#list").hidden=src;$("#stats").hidden=src;$("#src").hidden=!src;
|
||
$("#tab-rec").classList.toggle("on",!src);$("#tab-src").classList.toggle("on",src);LS.set("tab",t);if(src)loadSources()}
|
||
$("#tab-rec").onclick=()=>setTab("rec");$("#tab-src").onclick=()=>setTab("src");
|
||
setInterval(()=>{if(!$("#src").hidden&&!document.hidden)loadSources()},60000);
|
||
if(LS.get("tab","rec")==="src"&&!parseHash())setTab("src");
|