From 57e4ce349c14917e8fc2b1b54e1bddd4f6769460 Mon Sep 17 00:00:00 2001 From: Kenneth Kam Date: Mon, 19 Feb 2024 21:38:56 +0000 Subject: [PATCH] Add icon for HDJT with E55P icon --- public/img/aircraft/HDJT.png | Bin 0 -> 692 bytes public/js/simaware_app/app.js | 2 +- src/js/simaware_app/simaware-map.js | 41 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 public/img/aircraft/HDJT.png diff --git a/public/img/aircraft/HDJT.png b/public/img/aircraft/HDJT.png new file mode 100644 index 0000000000000000000000000000000000000000..20be04a1bb9053b97bf130013a37e525efcc7a10 GIT binary patch literal 692 zcmV;l0!#ggP)(maOwDOx5^xFlG=l+Q@; zz+8rTB-mrAT!MmNfvY^2QLP0w1q&>3fF~{R>fZyNwZOaof&UD!NNT2%p>M#8QYHiX zzdXID4C+|GI}QlY>3C=ke~YwMMl%jEINeqxw>7whf6M6eKz zK>*{{s9K8^K^B8Sg5tJDMbd4L%eY`)P1#bd>TiS-g0)KF_Vwn5ouM^{for(;!window.hasOwnProperty("airports")||!window.hasOwnProperty("flights");)await new Promise(e=>setTimeout(e,10));airport=airports[e],null!=airport&&($("#airport-icao").html(airport.icao),$("#airport-city").html(airport.city),$("#airport-name").html(airport.name)),el=document.getElementById("sidebar-container"),L.DomEvent.disableScrollPropagation(el),L.DomEvent.disableClickPropagation(el)})()}function zoomToAirport(a,e=0){$("#map").length&&!manual||(window.location.href="/?airport="+a),returnToView(),returnSidebarToView("airport-sidebar","control-airport-pullout"),$("#user-sidebar").hide(0),$("#user-sidebar").hide(0),$("#airport-sidebar").show(),"undefined"!=typeof ap_featuregroup&&map.hasLayer(ap_featuregroup)&&(map.removeLayer(ap_featuregroup),delete ap_featuregroup),ap_featuregroup=new L.FeatureGroup,initializeAirport(a),updateAirportFlights(airports,flights,a);var r=[];map.removeLayer(plane_featuregroup),$.each(flights,(e,t)=>{t.dep!=a&&t.arr!=a||(ap_featuregroup.addLayer(plane_array[e]),r.push([t.lat,t.lon]))}),console.log(r),map.addLayer(ap_featuregroup),e||map.fitBounds(r),$("#search-wrapper").hide(),window.history.pushState(a,a,"/?airport="+a)}function returnFromAirport(){"undefined"!=typeof ap_featuregroup&&(map.removeLayer(ap_featuregroup),delete ap_featuregroup),map.hasLayer(plane_featuregroup)||map.addLayer(plane_featuregroup),window.history.pushState("home","home","/"),$("#airport-sidebar").hide()}function updateAirportFlights(a,e,r){console.log("Updating Airports");var s=[],i=[];$.each(e,(e,t)=>{console.log(t.callsign+" "+t.dep+" "+t.arr),console.log(t.arr==r),console.log(r),t.arr==r?i.push(t):t.dep==r&&s.push(t)}),html="",depscount=0,arrscount=0,$.each(s,(e,t)=>{[airportname,airportcity]=getAirportDetails(a,t.arr),html=html+''+t.callsign+'to'+t.arr+''+airportcity+"",depscount++}),$.each(i,(e,t)=>{[airportname,airportcity]=getAirportDetails(a,t.dep),html=html+''+t.callsign+'from'+t.dep+''+airportcity+"",arrscount++}),$("#airport-list").html(html),$("#depcount").html(depscount),$("#arrcount").html(arrscount)}function getAirportLoad(a){var r=0;return $.each(flights,(e,t)=>{t.dep!=a&&t.arr!=a||r++}),r}function getAirportDetails(e,t){return null!=e[t]?returnvalue=[e[t].name,e[t].city]:(returnvalue=["Unknown Airport","Unknown City"],console.log("UNKNOWN: "+t)),returnvalue}function getAtisCode(e,a){return atis_exploded=e.replace("."," ").replace(","," ").toUpperCase().split(" "),delete code,$.each(atis_exploded,function(e,t){if("INFO"==t||"INFORMATION"==t||"ATIS"==t&&atis_exploded[e-1]==a&&"INFO"!=atis_exploded[e+1]&&"INFORMATION"!=atis_exploded[e+1])return code=atis_exploded[e+1],!1}),"undefined"==typeof code&&$.each(atis_exploded,function(e,t){if(t==a)return code=atis_exploded[e+1],!1}),"undefined"!=typeof code?1==code.length?code:convertToLetter(code):"-"}function convertToLetter(e){return void 0!==codes[e]?codes[e]:"-"}function getAtisRwy(e){var t,a=["RWY IN USE","RWYS IN USE","RUNWAY IN USE","RUNWAYS IN USE","RUNWAY","RWY","ILS","VISUAL","APCHS","APCH","APPR","LANDING"],r=[];for(t in a){var s=a[t];if(e.includes(s)){const n={zero:"0",one:"1",two:"2",three:"3",four:"4",five:"5",six:"6",seven:"7",eight:"8",niner:"9"};var i=new RegExp("\\b("+Object.keys(n).join("|")+")\\b","ig"),[,...s]=(e=e.replace(i,e=>n[e.toLowerCase()]).replace(/[,.]/g,"").replace(/RIGHT/gi,"R").replace(/LEFT/gi,"L").replace(/\b(\d)\s+(\d)\s+([RL])\b/gi,"$1$2$3").replace(/\b(\d)\s+([RL])\b/gi,"$1$2")).split(s),o=s.join(" ").split(" ");for(j in o){if(15'+moment.utc(eventdata.event.start).format("MMM")+''+moment.utc(eventdata.event.start).format("D")+''+eventdata.event.name+'
'+moment.utc(eventdata.event.start).format("HHmm")+"-"+moment.utc(eventdata.event.end).format("HHmm")+"Z
"),$("#event-date").html(moment(eventdata.event.start).format("MMMM Do, YYYY"));var a="",r={};aar={},$.each(eventdata.event.airports,(e,t)=>{r[t.icao]=airportSearch(t.icao),aar[t.icao]={deps:[],arrs:[]},a+='
'+t.icao+"
"}),$("#events-aps").html(a),$.each(eventdata.departures,(e,t)=>{1{ll.push([t[0],t[1]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#00cc66",opacity:.4,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e])),t.accel&&t.dep&&didDepart(t,r)&&aar[t.dep].deps.push([t])}),$.each(eventdata.arrivals,(e,t)=>{1{ll.push([t[0],t[1]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#3366ff",opacity:.4,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e])),t.decel&&t.arr&&didArrive(t,r)&&aar[t.arr].arrs.push([t])}),aarbins=[];var t="";start=moment(eventdata.event.start),end=moment(eventdata.event.end),0==start.minutes()?start.add(-60,"minutes"):start.startOf("hour"),0==end.minutes?end.add(60,"minutes"):end.add(60,"minutes").startOf("hour");for(var s=1e3*start.unix();s<1e3*end.unix();s+=18e5)(B={}).start=s,B.stop=s+1799999,aarbins.push(B);var i=0;for(y in aar){t+='';var o=aar[y],n=[],l=[];for(_ in aarbins){var c,d=aarbins[_],p=[],u=[];for(c in o.deps)(x=o.deps[c][0]).accel>d.start&&x.acceld.start&&x.decel':_%2==1?'"}for(_ in t+='',aar[y].deps)t+=0==_?"";for(_ in t+="",aarbins)_%2==0&&(t+=0==_?'":t+=moment(aarbins[_].start).hour()+"Z");t+=""}$("#events-table").html(t),$(".analysis-button").attr("onclick","showAnalysis('"+eventdata.event.airports[0].icao+"'); $('#splitmodal').show();");var f=[];for(s in aar){var m=airportSearch(s),g=Number(m.lat),h=Number(m.lon);f.push([g,h]);m=new L.divIcon({className:"simaware-ap-tooltip",html:getEventTooltipNew(m,aar),iconSize:"auto"});oloc=new L.marker([g,h],{icon:m}),map.addLayer(oloc)}map.fitBounds(f,[50,50]),10'+y+"":b+=''+y+"",$("#analysis_airports").html(b),t+='';var _,w=[];for(_ in v.arrs){var x,B,A,C=v.arrs[_];for(c in C)(x=C[c]).landoffset&&didArrive(x,r)&&(B={},A=getEventOffset(x,r[y],eventdata,start),B.flight=x,B.lenpct=(x.landoffset-A)/(1e3*end.unix()-1e3*start.unix())*15e5,B.right=100*(1e3*end.unix()-x.decel)/(1e3*end.unix()-1e3*start.unix()),B.timeinMins=15e3*(x.landoffset-A)/6e4,w.push(B))}w.sort(function(e,t){return t.right-e.right}),aar[y].analysis=w}b="",t="";for(s in aar)b+=''+s+"";cycleEvents(0)}function showAnalysis(r){var e="";$(".analysis_chooser").each(function(){$(this).attr("id")==r?$(this).css({"background-color":"#3137fd"}):$(this).css({"background-color":"transparent"})});var t,s="",i=end.diff(start,"minutes");for(t in $.each(aarbins,(e,t)=>{var a=moment(t.start),a=moment(t.stop).diff(a,"minutes")/i*100;borderleft="dashed",borderright="dashed",s+='",console.log(s),$("#analysis_toptable").html(s),aar[r].analysis)0 ');var o='
ARR '+aar[r].arrs[e].length+"
DEP "+aar[r].deps[e].length}),s+="
';console.log(aar[r]);for(let e=0;e{console.log(t);var a=moment(t.start),t=moment(t.stop).diff(a,"minutes")/i*100;borderleft="dashed",borderright="dashed",o+='"}),o+="";o+="
'+a.format("HHmm")+" Z
",$("#analysis").html(e+o),$('[data-toggle="tooltip"]').tooltip()}function getEventOffset(e,t,a,r){for(var s in e.logs){var i=e.logs[s];if(distance(t.lat,t.lon,i[0],i[1])<80)return s}}async function loadLegacyEvent(e){response=await fetch("/legacyevents/eventsummary"+e+".json"),eventdata=await response.json(),$("#event-name").html(eventdata.name),$("#event-date").html(moment(eventdata.start).format("MMMM Do, YYYY"));let a="";$.each(eventdata.airports.split(","),(e,t)=>{a+='
'+t+"
"}),$("#events-aps").html(a),$("#events-table").html(returnEventsTable(eventdata.aarstore[0])),(1==Object.keys(eventdata.aarstore).length?replaceAarData:cycleLegacyEvents)(0),bounds=[],$.each(eventdata.aarstore,(e,t)=>{var a=Number(t.ap.lat),r=Number(t.ap.lon);bounds.push([a,r]);t=new L.divIcon({className:"simaware-ap-tooltip",html:getEventTooltip(t),iconSize:"auto"});oloc=new L.marker([a,r],{icon:t}),map.addLayer(oloc)}),map.fitBounds(bounds,[50,50]),1==bounds.length&&map.setZoom(8),response=await fetch("/legacyevents/event"+e+".json"),eventpaths=await response.json(),polyline_array=[],polyline_featuregroup=new L.FeatureGroup,map.addLayer(polyline_featuregroup),$.each(eventpaths,(e,t)=>{1{ll.push([t[1],t[0]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#fff",opacity:.2,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e]))})}function getEventTooltip(e){let a=0;return $.each(e.aar,(e,t)=>{a+=t[2]}),'
'+e.ap.icao+'
'+a+"
"}function getEventTooltipNew(e){let t=0;for(var a in aar[e.icao].deps)t+=aar[e.icao].deps[a].length;for(var a in aar[e.icao].arrs)t+=aar[e.icao].arrs[a].length;return'
'+e.icao+'
'+t+"
"}function getWfTooltip(e){return'
'+e.icao+'
'+getAirportLoad(e.icao)+"
"}function cycleEvents(e){var t,a;e>=Object.keys(aar).length?cycleEvents(0):(a=airportSearch(t=Object.keys(aar)[e]),$("#event-ap").html(""+a.icao+" "+a.name+'
'+a.city+""),$(".events-e#"+t).fadeIn(300,function(){1=Object.keys(eventdata.aarstore).length?cycleLegacyEvents(0):(replaceAarData(e),$(".aarelement").each(function(){$(this).animate({opacity:1},300)}),$("#events-airport").animate({opacity:1},300,function(){$(".aarelement").each(function(){$(this).delay(5e3).animate({opacity:0},150)}),$(this).delay(5e3).animate({opacity:0},150,function(){cycleLegacyEvents(e+1)})}))}function returnEventsTable(e){for(element in ct=Object.keys(e.aar).length,text='',e.aar)text+='';for(element in text+='",e.aar)text+='";return text+="
 
 

'+moment(e.aar[0][0].date).format("HHmm[Z]")+"

'+moment(e.aar[element][1].date).format("HHmm[Z]")+"
",text}function getCity(e){return city=e.ap.city==e.ap.country?e.ap.city:e.ap.state?e.ap.city+", "+e.ap.state:e.ap.city+", "+e.ap.country,city}function replaceAarData(e){$("#events-name").html(eventdata.aarstore[e].ap.name),$("#events-icao").html(eventdata.aarstore[e].ap.icao),$("#events-city").html(getCity(eventdata.aarstore[e])),$.each(eventdata.aarstore[e].aar,function(e,t){$("#aar"+e).html(''+t[2]+"")})}async function loadUpcomingEvents(){let e=await fetch(dataserver+"api/livedata/events.json");events=await e.json();let r=[];return $.each(events.future,(e,a)=>{var t;0<=moment.duration(moment(a.start).diff(moment())).asDays()&&moment.duration(moment(a.start).diff(moment())).asDays()<14&&(t=a.airports,$.each(t,(e,t)=>{void 0!==r[t.icao]?r[t.icao].push(a):r[t.icao]=[a]}))}),r}function didDepart(e,t){for(var a in e.logs){a=e.logs[a];if(distance(a[0],a[1],t[e.dep].lat,t[e.dep].lon)<5)return!0}return!1}function didArrive(e,t){for(var a in e.logs){a=e.logs[a];if(distance(a[0],a[1],t[e.arr].lat,t[e.arr].lon)<5)return!0}return!1}async function initializeInfobar(){await initializePatrons(),await updateInfobar(),infobar_streamers()}async function updateInfobar(){al={},$.each(bnfoairports,e=>{al[e]=bnfoairports[e].departures+bnfoairports[e].arrivals});let t=[];for(var e in al)t.push([e,al[e]]);t.sort(function(e,t){return t[1]-e[1]}),infoairports=[];var r='
Popular Airports
';for(let e=0;e<10;e++){var a=airportSearch(bnfoairports[t[e][0]].icao);infoairports.push(bnfoairports[t[e][0]]),r+=""}r+="
#'+(e+1)+''+getLocalTooltip(bnfoairports[t[e][0]].icao)+''+a.name+'
'+a.city+'
'+bnfoairports[t[e][0]].departures+' '+bnfoairports[t[e][0]].arrivals+"
",$("#ap-wrapper").html(r),r='
Upcoming Events
',prevdate=null;let s=0,i=0;for(;i<10;){if(events.future[s].end>moment.now()){for(var o in r+='",r+='",prevdate=moment.utc(events.future[s].start).format("MMMD"),i++}s++}r+="
',prevdate!=moment.utc(events.future[s].start).format("MMMD")&&(r+='
'+moment.utc(events.future[s].start).format("MMM")+'
'+moment.utc(events.future[s].start).format("D")+"
"),r+="
',r+='
',r+=''+events.future[s].name+"",moment.now()>events.future[s].start&&moment.now()Live'),r+="
",r+=""+moment.utc(events.future[s].start).format("HHmm")+"-"+moment.utc(events.future[s].end).format("HHmm")+"Z ",events.future[s].airports)r+='"+events.future[s].airports[o].icao+" ";r+="
",$("#events-wrapper").html(r),$("#events-wrapper .event-date:first").css({"background-color":"rgba(255, 255, 255, 0.1)","border-radius":"5px"}),infostreamers={pilots:[],controllers:[]},r='
Active Streamers
',$.each(flights,(t,a)=>{if(patrons[a.cid]&&(2<=patrons[a.cid].tier||!patrons[a.cid].tier)&&streamers[patrons[a.cid].twitch]){let e={};e.uid=t,e.dep=a.dep,e.arr=a.arr,e.dep||(e.dep="NONE"),e.arr||(e.arr="NONE"),e.streamername=patrons[a.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.callsign=a.callsign,infostreamers.pilots.push(e);t=plane_array[e.uid].flight,a=getStatus(t);r+='"}}),$.each(tracons,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),$.each(sectors,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),$.each(localsraw,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]&&!t.callsign.includes("_ATIS")){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),r+="
'+e.streamername+''+e.dep+'
'+e.arr+"
'+e.streamername+''+e.position+"
'+e.streamername+''+e.position+"
'+e.streamername+''+e.position+"
",$("#streamers-wrapper").html(r)}function infobar_airports(){$("#infobar-title").html('Popular Airports'),$("#infobar-title").delay(500).fadeIn(250,()=>{infobar_airports_scroll(0)})}function infobar_airports_scroll(e,t=10){t<=e?$("#infobar-title").fadeOut(250,function(){infobar_streamers()}):(airport=airports[infoairports[e].icao],$("#infobar-content").html(""),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_airports_scroll(e+1)})}))}function infobar_streamers(){0==infostreamers.pilots.length&&0==infostreamers.controllers.length?infobar_airports():($("#infobar-title").html('Streamers'),$("#infobar-title").delay(500).fadeIn(250,()=>{infobar_streamers_scroll(0,"pilots")}))}function infobar_streamers_scroll(a,r){if(void 0===infostreamers[r]||void 0===infostreamers[r][a])"pilots"==r&&infobar_streamers_scroll(0,"controllers"),"controllers"==r&&$("#infobar-title").fadeOut(500,function(){infobar_airports()});else if("pilots"==r&&void 0!==plane_array[infostreamers[r][a].uid]){var s=plane_array[infostreamers[r][a].uid].flight,i=getStatus(s);let e=infostreamers[r][a].dep,t=infostreamers[r][a].arr;e=e||"NONE",t=t||"NONE";var o="https://twitch.tv/"+infostreamers[r][a].streamername;$("#infobar-content").html('
"),$("#infobar-flights-progressbar-plane").css({color:i.color}),$("#infobar-flights-progressbar-elapsed").css({"background-color":i.color}),$("#infobar-flights-progressbar-elapsed").css({width:getInfoElapsedWidth(s)+"%"}),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_streamers_scroll(a+1,r)})})}else"controllers"==r?(s="twitch"==infostreamers[r][a].platform?"https://twitch.tv/"+infostreamers[r][a].streamername:"https://youtube.com/c/"+infostreamers[r][a].streamername+"/live",$("#infobar-content").html('
'+infostreamers[r][a].position+"
"),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_streamers_scroll(a+1,r)})})):infobar_streamers_scroll(a+1,r)}codes={ALPHA:"A",BRAVO:"B",CHARLIE:"C",DELTA:"D",ECHO:"E",FOXTROT:"F",GOLF:"G",HOTEL:"H",INDIA:"I",JULIET:"J",KILO:"K",LIMA:"L",MIKE:"M",NOVEMBER:"N",OSCAR:"O",PAPA:"P",QUEBEC:"Q",ROMEO:"R",SIERRA:"S",TANGO:"T",UNIFORM:"U",VICTOR:"V",WHISKEY:"W",XRAY:"X",YANKEE:"Y",ZULU:"Z"},$(document).ready(()=>{$("#ap-toggle").on("click",()=>{$("#ap-wrapper").toggle(),$("#streamers-wrapper").hide(),$("#events-wrapper").hide(),$("#streamers-toggle").removeClass("toggle-item-active"),$("#events-toggle").removeClass("toggle-item-active"),$("#ap-wrapper").is(":visible")?$("#ap-toggle").addClass("toggle-item-active"):$("#ap-toggle").removeClass("toggle-item-active")}),$("#streamers-toggle").on("click",()=>{$("#streamers-wrapper").toggle(),$("#ap-wrapper").hide(),$("#events-wrapper").hide(),$("#streamers-wrapper").is(":visible")?$("#streamers-toggle").addClass("toggle-item-active"):$("#streamers-toggle").removeClass("toggle-item-active"),$("#events-toggle").removeClass("toggle-item-active"),$("#ap-toggle").removeClass("toggle-item-active")}),$("#events-toggle").on("click",()=>{$("#events-wrapper").toggle(),$("#ap-wrapper").hide(),$("#streamers-wrapper").hide(),$("#events--toggle").removeClass("toggle-item-active"),$("#events-wrapper").is(":visible")?$("#events-toggle").addClass("toggle-item-active"):$("#events-toggle").removeClass("toggle-item-active"),$("#events-toggle").addClass("toggle-item-active"),$("#ap-toggle").removeClass("toggle-item-active")})}),r2server="https://r2.simaware.ca/",dataserver="https://data.simaware.ca/";const warnings={NAT0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information.",CZQO0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information.",EGGX0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information."},wf=["YSSY","YMML","YWKS","SCGC","SAWH","SAVC","SUMU","SBBR","SBEG","TNCC","MMUN","MMGL","KIAH","KATL","KBOS","CYWG","LPPD","GMMN","DAAG","LPFR","LIMC","LFQQ","EGFF","ELLX","ESGG","EVRA","UKBB","LLBG","HEGN","ORBI","OBBI","OOMS","VOHS","VEPT","VGHS","ZULS","ZLLL","ZUTF","RCTP","VHHH","VTBS","WIMM","WIDD","WAHI","YPDN","YBCS","YBBN","YSSY"];async function initializeMap(e=0,t=0){$(".os-host-flexbox").overlayScrollbars({}),plane_array=[],active_uids=[],active_firs=[],active_tracons=[],tracons_array=[],layers_array=[],active_layers_pos=[],active_layers_sectors=[],layers_markers_array=[],tracmarkers_array=[],icons_array=[],firs_array=[],firmarkers_array=[],sigmets_array=[],sigmarkers_array=[],active_flight=null,layers_alt=50,await initializeIcons(),$.cookie("init")||$("#disclaimer").removeClass("d-none").addClass("d-flex"),await initializeFirData();var t=t?"active-area-landscape":"active-area";$("#map").length&&(map=L.map("map",{zoomControl:!1,preferCanvas:!0,keyboard:!1}).setView([30,0],3).setActiveArea(t),map.doubleClickZoom.disable(),basemap=L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB | SimAware on GitHub | VATGlasses Data on GitHub | Not for real-world navigation.',subdomains:"abcd"}).addTo(map),map.attributionControl.setPosition("topright"),$.cookie("mapView")&&(t=JSON.parse($.cookie("mapView")),map.setView([t.lat,t.lng],t.zoom,!0)),$.each(["controls","flights-sidebar","search-field","user-sidebar","footer-background","streamers-bar"],(e,t)=>{el=document.getElementById(t),el&&(L.DomEvent.disableClickPropagation(el),L.DomEvent.disableScrollPropagation(el))}),map.on("moveend",function(e){var t={lat:map.getCenter().lat,lng:map.getCenter().lng,zoom:map.getZoom()};$.cookie("mapView",JSON.stringify(t))}),map.on("click",function(){flightpath&&map.hasLayer(flightpath)&&returnToView(),$("#search-wrapper").hide()}),$("#search-field").click(()=>{$("#search-wrapper").show();var e=$("#search-field").val().toLowerCase();$("#search-results").html(compileSearchResults(e))})),plane_featuregroup=new L.FeatureGroup,e||map.addLayer(plane_featuregroup),atc_featuregroup=new L.FeatureGroup,atc_leg_featuregroup=new L.FeatureGroup,active_featuregroup=new L.FeatureGroup,tracons_featuregroup=new L.FeatureGroup,locals_featuregroup=new L.FeatureGroup,sigmets_featuregroup=new L.FeatureGroup,events_featuregroup=new L.FeatureGroup,nats_featuregroup=new L.FeatureGroup,wf_featuregroup=new L.FeatureGroup,fp_featuregroup=new L.FeatureGroup,layers_featuregroup=new L.FeatureGroup,atc_featuregroup.addLayer(atc_leg_featuregroup),flightpath=null}function initializeIcons(){$.each(["B739"],function(e,t){icons_array[t]=new L.divIcon({className:t,iconSize:[18,18],iconAnchor:[9,9]})})}function initializeWorldFlight(){$.each(wf,(e,t)=>{0'+t+"":""}async function initializeAirports(){airportsByIata=[],airportsByPrefix=[],airportsByApac=[];let e=await fetchRetry(dataserver+"api/livedata/airports.json");airports=await e.json(),$.each(airports,(e,t)=>{(airportsByIata[t.iata]=t).prefix&&(airportsByPrefix[t.prefix]=t),t.apac&&(airportsByApac[t.apac]=t)})}async function initializeFirData(){let e=await fetchRetry(dataserver+"api/livedata/countries.json");countries=await e.json(),e=await fetchRetry(dataserver+"api/livedata/firs.json"),firs=await e.json(),e=await fetchRetry(dataserver+"api/livedata/uirs.json"),uirs=await e.json()}function getAirline(e){if(e.callsign.match(/[A-Z]+/)&&void 0!==airlines[e.callsign.match(/[A-Z]+/)[0]])return airlines[e.callsign.match(/[A-Z]+/)[0]]}async function initializeNexrad(){response=await fetchRetry("https://tilecache.rainviewer.com/api/maps.json"),data=await response.json(),ts=data[0],nexrad=L.tileLayer("https://tilecache.rainviewer.com/v2/radar/"+ts+"/512/{z}/{x}/{y}/6/0_1.png",{tileSize:256,opacity:.4})}async function initializePatrons(){response=await fetchRetry(dataserver+"api/livedata/patrons.json"),ret=await response.json(),patrons={},$.each(ret,e=>{ret[e].cid&&(patrons[ret[e].cid]=ret[e])}),response=await fetchRetry(dataserver+"api/livedata/streamers.json"),streamers=await response.json()}async function initializeATC(){layers_positions={};let e=await fetch("/livedata/layers_positions.json");var t=await e.json();for(i in t){var a=t[i];for(j in a.prefix){var r=a.prefix[j];layers_positions[r]?layers_positions[r].push(a):layers_positions[r]=[a]}}atisdata={},layers_s={},$.ajax({url:"/livedata/layers.json",xhrFields:{withCredentials:!1},success:function(e){for(var t in layers_map=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:0,color:"#222"}}),$.each(layers_map._layers,function(e,t){e=layers_map.getLayer(e);layers_array[e.feature.properties.facility]?layers_array[e.feature.properties.facility].push(e):layers_array[e.feature.properties.facility]=[e]}),layers_array)for(var a in layers_array[t])for(var r in layers_array[t][a].feature.properties.owner)layers_s[layers_array[t][a].feature.properties.owner[r]]?layers_s[layers_array[t][a].feature.properties.owner[r]].push(t+"|"+a):layers_s[layers_array[t][a].feature.properties.owner[r]]=[t+"|"+a]}}),$.ajax({url:"/livedata/firboundaries.json",xhrFields:{withCredentials:!1},success:function(e){firmap=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:1,color:"#333"}}),$.each(firmap._layers,function(e,t){var a=firmap.getLayer(e),e=t.feature.properties.oceanic,t=t.feature.properties.id;void 0===firs_array[t+e]?firs_array[t+e]=[a]:firs_array[t+e].push(a)}),atc_leg_featuregroup.addLayer(firmap)}}),$.ajax({url:"/livedata/traconboundaries.json",xhrFields:{withCredentials:!1},success:function(e){traconmap=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:.01,color:"#222"}}),$.each(traconmap._layers,function(e,t){var r=traconmap.getLayer(e),e=t.feature.properties.prefix,s=void 0===t.feature.properties.suffix||null===t.feature.properties.suffix?"APP":t.feature.properties.suffix;$.each(e,(e,t)=>{var a;null!=tracons_array[t]?tracons_array[t][s]=r:((a=[])[s]=r,tracons_array[t]=a)})}),atc_leg_featuregroup.addLayer(traconmap),atc_leg_featuregroup.addLayer(tracons_featuregroup)}})}async function refreshFlights(e=null,t=null){try{response=await fetchRetry(r2server+"api/livedata/data.json",{credentials:"omit"}),livedata=await response.json()}catch(e){return}for(var a in flights=livedata.pilots,sectors=livedata.onlinefirs,tracons=livedata.appdep,localsraw=livedata.locals,flights=applyFilter(flights,e,t),bnfoairports={},newactive_uids=[],$.each(flights,function(e,t){("undefined"!=typeof map&&void 0!==plane_array[t.uid]?updateLocation:addAircraft)(t),(t.dep||t.arr)&&(bnfoairports[t.dep]?bnfoairports[t.dep].departures++:bnfoairports[t.dep]={icao:t.dep,departures:1,arrivals:0},bnfoairports[t.arr]?bnfoairports[t.arr].arrivals++:bnfoairports[t.arr]={icao:t.arr,departures:0,arrivals:1})}),plane_array)newactive_uids.includes(a)||(plane_featuregroup.removeLayer(plane_array[a]),delete plane_array[a]);return active_flight&&(updateFlightsBox(flights[active_flight]),plane.bringToFront()),active_uids=newactive_uids,$("#navbar-pilots").html(Object.keys(plane_array).length),flights}function interpolateLoc(){for(uid in plane_array){var e=plane_array[uid].getLatLng(),t=6378.1,a=Math.PI*plane_array[uid].flight.hdg/180,r=1.852*plane_array[uid].flight.gndspd/3600*1,s=Math.PI*e.lat/180,i=Math.PI*e.lng/180,e=180*Math.asin(Math.sin(s)*Math.cos(r/t)+Math.cos(s)*Math.sin(r/t)*Math.cos(a))/Math.PI,s=180*(i+Math.atan2(Math.sin(a)*Math.sin(r/t)*Math.cos(s),Math.cos(r/t)-Math.sin(s)*Math.sin(e)))/Math.PI;plane_array[uid].setLatLng(new L.LatLng(e,s))}}function applyFilter(e,a=null,r=null){var s={};return a?($.each(e,(e,t)=>{switch(a){case"airport":t.dep!=r&&t.arr!=r||(s[t.uid]=t);case"fleet":0==t.callsign.indexOf(r)&&(s[t.uid]=t)}}),s):e}function addAircraft(e){var t=createPlaneMarker(e);plane_array[t.uid]=t,plane_featuregroup.addLayer(plane_array[t.uid]),markUID(e)}function createPlaneMarker(e){new Image;var t=getMarker(e.aircraft),t=L.canvasMarker(new L.LatLng(e.lat,e.lon),{radius:16,img:{url:"/img/aircraft/"+t[2]+".png",size:[1.2*Math.pow(t[0],.75),1.2*Math.pow(t[1],.75)],rotate:["BALL"].includes(e.aircraft)?0:e.hdg,offset:{x:0,y:0}}});return t.uid=e.uid,t.flight=e,[offset,dir]=getMarkerDirection(e),t.bindTooltip(getDatablock(e),{offset:offset,direction:dir,permanent:!1,className:"datablock"}),t.on("click",function(e){L.DomEvent.stopPropagation(e),zoomToFlight(this.uid)}),t}function getDatablock(e){return'
'+e.callsign+" "+e.aircraft+"
"+100*Math.round(Number(e.alt)/100)+" "+e.gndspd+"
"+e.dep+" "+e.arr+"
"}function updateLocation(e){try{plane_array[e.uid].setLatLng(new L.LatLng(Number(e.lat),Number(e.lon))),plane_array[e.uid].options.img.rotate=["BALL"].includes(e.aircraft)?0:e.hdg,plane_array[e.uid]._update()}catch(e){}plane_array[e.uid].setTooltipContent(getDatablock(e)),plane_array[e.uid].flight=e,"undefined"!=typeof flightpath&&map&&map.hasLayer(fp_featuregroup)&&plane.flight.uid==e.uid&&flightpath.addLatLng([e.lat,e.lon]),markUID(e)}function getMarkerDirection(e){return dir=Number(e.hdg)<180?(offset=L.point(5,12),"right"):(offset=L.point(-5,12),"left"),[offset,dir]}function markUID(e){0<=$.inArray(e,active_uids)&&active_uids.splice(active_uids.indexOf(e.uid),1),newactive_uids.push(e.uid)}function markFIR(e){0<=$.inArray(e,active_firs)&&active_firs.splice(active_firs.indexOf(e),1)}function airportSearch(e){return airportsByPrefix[e]||airports[e]||airportsByIata[e]||airportsByApac[e]||void 0}function getActiveFIRs(){let e=[];for(var t in firs_array)"#fff"==firs_array[t][0].options.color&&e.push(t);return e}function lightUpTracon(e,t){var a,r,s=tracons_array[t.split("|")[0]][t.split("|")[1]];s.setStyle({weight:1,color:"#40e0d0"}),void 0===tracmarkers_array[t]&&(a=new L.divIcon({className:"simaware-ap-tooltip",html:getTracTooltip(s.feature.properties.id,t),iconSize:"auto"}),r=getTraconMarkerLoc(s),tracmarkers_array[t]=new L.marker(r,{icon:a}),tracmarkers_array[t].bindTooltip(getTraconBlock(e,"DEP"==t.slice(-3)),{opacity:1,sticky:!0}),atc_leg_featuregroup.addLayer(tracmarkers_array[t]),s.bringToFront())}function traconSearch(e){e.replace("__","_");var t=e.slice(0,-4),a=e.slice(-3);return void 0!==tracons_array[t]&&void 0!==tracons_array[t][a]?[tracons_array[t][a],"bounds",t+"|"+a]:void 0!==tracons_array[t]&&void 0!==tracons_array[t].APP?[tracons_array[t].APP,"bounds",t+"|APP"]:void 0!==airportsByIata[t]?[airportsByIata[t],"circles",t]:void 0!==airports[t]?[airports[t],"circles",t]:(t=e.split("_")[0],void 0!==tracons_array[t]&&void 0!==tracons_array[t][a]?[tracons_array[t][a],"bounds",t+"|"+a]:void 0!==tracons_array[t]&&void 0!==tracons_array[t].APP?[tracons_array[t].APP,"bounds",t+"|APP"]:void 0!==airportsByIata[t]?[airportsByIata[t],"circles",t]:void 0!==airports[t]?[airports[t],"circles",t]:null)}function groupTracons(e){return traconsGrouped=[],traconsGrouped.bounds=[],traconsGrouped.circles=[],$.each(e,(e,t)=>{var a;(foundTracon=traconSearch(t.callsign))&&(null==traconsGrouped[foundTracon[1]][foundTracon[2]]?((a=[]).loc=foundTracon[2],a.members=[t],"circles"==foundTracon[1]?(a.airport=foundTracon[0],a.name="Unknown City"==foundTracon[0].city?foundTracon[0].name:foundTracon[0].city.split(",")[0]+" Approach"):a.name=foundTracon[0].feature.properties.name,traconsGrouped[foundTracon[1]][foundTracon[2]]=a):traconsGrouped[foundTracon[1]][foundTracon[2]].members.push(t))}),traconsGrouped}function firSearch(e){var t;t=0<=e.search("_FSS")?"FSS":"CTR";e=e.replace("__","_").replace("_CTR","").replace("_FSS","");if("FSS"==t){if(void 0!==uirs[e])return uirs[e];if(void 0!==uirs[e.split("_")[0]])return uirs[e.split("_")[0]]}return void 0!==firs[e]?firs[e]:void 0!==firs[e.split("_")[0]]?firs[e.split("_")[0]]:void 0!==uirs[e]?uirs[e]:void 0!==uirs[e.split("_")[0]]?uirs[e.split("_")[0]]:void 0}function getCallsign(e){var t;if(void 0===(t=void 0!==uirs[e]?uirs[e]:firSearch(e)))return null;if(void 0!==t.firs)return t.name;var a=getCountry(t);return a&&""!=a.radar?t.name+" "+a.radar:a&&"USA"==a.name?t.name+" Center":e.search("_FSS")?t.name+" Radio":t.name+" Centre"}function getTraconMarkerLoc(e){var t=polylabel(e.feature.geometry.coordinates[0],1),a=[];return $.each(e.getLatLngs()[0][0],(e,t)=>{a.push(t.lat)}),[Math.max(...a),t[1]]}function getCallsignByFir(e,t){if(null==t&&(t=e.icao+"0"),null==e)return"Unknown Position";if("CZUL"==e.icao)return"Centre de Montréal";if(void 0!==e.firs||0{firObj=firs_array[t],turnOffFIR(firObj)}),layers_pos={},$.each(sectors,(e,t)=>{(pos=findLayersPosition(t))&&(layers_pos[pos.id.split("/")[0]]?layers_pos[pos.id.split("/")[0]][pos.id]?(t.callsign,t.cid,t.created_at_timestamp,t.freq,t.name,t.rating,t.time_online,layers_pos[pos.id.split("/")[0]][pos.id].atc.push(t)):(layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]):(layers_pos[pos.id.split("/")[0]]={},layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]))}),$.each(tracons,(e,t)=>{(pos=findLayersPosition(t))&&(layers_pos[pos.id.split("/")[0]]?layers_pos[pos.id.split("/")[0]][pos.id]?(t.callsign,t.cid,t.created_at_timestamp,t.freq,t.name,t.rating,t.time_online,layers_pos[pos.id.split("/")[0]][pos.id].atc.push(t)):(layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]):(layers_pos[pos.id.split("/")[0]]={},layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]))}),layers_sectors=findLayersSectors(layers_pos),$.each(sectors,(e,t)=>{var a=firSearch(t.callsign);if(a&&void 0===a.firs){var r=getFirIndexByCallsign(t.callsign);if(t.time_online=getTimeOnline(t),void 0===newdata[r]){let e={};e.firname=getCallsignByFir(a,r),e.members=[t],e.firicao=a.icao,e.firObj=firs_array[r],newdata[r]=e}else newdata[r].members.push(t);s++}}),$.each(sectors,(e,r)=>{var t=firSearch(r.callsign);r.time_online=getTimeOnline(r),t&&void 0!==t.firs&&(r.fssname=t.name,r.fssicao=t.prefix,$.each(t.firs,(e,t)=>{var a=getFirIndexByCallsign(t);if(void 0===newdata[a]){let e={};e.firname=getCallsignByFir(firSearch(t),a),e.members=[r],e.firicao=t,e.firObj=firs_array[a],newdata[a]=e}else newdata[a].members.push(r);s++}))}),$.each(newdata,(e,t)=>{var a,r,s;1{var a,r,s;-1==t.firname.search("Oceanic")&&(a=t.firObj,r=t.firname,s=t.firicao,lightupFIR(a,t.members,r,s,e),markFIR(e))}),$.each(active_firs,(e,t)=>{firObj=firs_array[t],turnOffFIR(firObj,t)}),"undefined"!=typeof tracons_circles_featuregroup&&tracons_featuregroup.hasLayer(tracons_circles_featuregroup)&&tracons_featuregroup.removeLayer(tracons_circles_featuregroup),tracons_circles_featuregroup=new L.FeatureGroup,traconsGrouped=groupTracons(tracons);var e=[];for(traconid in traconsGrouped.bounds){var t=traconsGrouped.bounds[traconid];0<=$.inArray(traconid,active_tracons)?(active_tracons.splice(active_tracons.indexOf(traconid),1),tracmarkers_array[traconid].setTooltipContent(getTraconBlock(t))):lightUpTracon(t,traconid),e.push(traconid)}for(traconid in $.each(active_tracons,(e,t)=>{turnOffTracon(t)}),traconsGrouped.circles){trac=traconsGrouped.circles[traconid];var a=new L.circle([trac.airport.lat,trac.airport.lon],{radius:6e4,weight:1.25,fillOpacity:0,color:"#40e0d0"});a.bindTooltip(getTraconBlock(trac),{opacity:1}),tracons_circles_featuregroup.addLayer(a)}for(id in active_tracons=e,tracons_featuregroup.addLayer(tracons_circles_featuregroup),$.each(localsraw,function(e,t){t.callsign.includes("_ATIS")||s++}),locals=[],$.each(localsraw,(e,t)=>{var a,r=t.callsign.replace("__","_").split("_"),s=r[0],r=r[r.length-1],s=airportSearch(s);(t.callsign.includes("_A_ATIS")||t.callsign.includes("_ATIS")&&!t.callsign.includes("_D_ATIS"))&&(a=getAtisRwy(t.atis)),void 0!==s&&(void 0===locals[s.icao]?(obj={},obj.loc=s,obj[r]=[t],a&&(obj.rwy=a),locals[s.icao]=obj):(void 0!==locals[s.icao][r]?locals[s.icao][r].push(t):locals[s.icao][r]=[t],a&&(locals[s.icao].rwy=a)))}),atc_featuregroup.hasLayer(locals_featuregroup)&&(atc_featuregroup.removeLayer(locals_featuregroup),locals_featuregroup=new L.FeatureGroup),locals){var r=locals[id],i=Number(r.loc.lat),o=Number(r.loc.lon),n=new L.divIcon({className:"simaware-ap-tooltip",html:getLocalTooltip(r.loc.icao),iconSize:"auto"});oloc=new L.marker([i,o],{icon:n}),oloc.bindTooltip(getLocalBlock(r.loc.icao),{opacity:1,sticky:!0}),locals_featuregroup.addLayer(oloc)}for(icao in eventsByAirport)void 0===locals[icao]&&airports[icao]&&(i=airports[icao].lat,o=airports[icao].lon,n=new L.divIcon({className:"simaware-ap-tooltip",html:getLocalTooltip(icao),iconSize:"auto"}),oloc=new L.marker([i,o],{icon:n}),oloc.bindTooltip(getLocalBlock(icao),{opacity:1,sticky:!0}),locals_featuregroup.addLayer(oloc));atc_featuregroup.addLayer(locals_featuregroup),$("#navbar-atc").html(s),showLayersView(layers_alt)}async function updateSigmet(){for(var e in response=await fetchRetry(dataserver+"api/livedata/sigmets.json"),data=await response.json(),sigmets_array)sigmets_featuregroup.removeLayer(sigmets_array[e]),sigmets_featuregroup.removeLayer(sigmarkers_array[e]);$.each(data.AIRSIGMET,(e,t)=>{if("CONVECTIVE"==t.hazard["@attributes"].type){let a=[],r=[];var s,i=getSigmetCode(t);$.each(t.area.point,(e,t)=>{a.push([Number(t.latitude),Number(t.longitude)]),r.push([Number(t.longitude),Number(t.latitude)])}),""!=i&&(sigmets_array[i]=new L.Polygon(a,{color:"#ffcc33",weight:1.5}),s=new L.divIcon({className:"simaware-ap-tooltip",html:'
'+i+"
",iconSize:"auto"}),sigmets_featuregroup.addLayer(sigmets_array[i]),sigmarkers_array[i]=new L.marker(polylabel([r],1),{icon:s}),sigmarkers_array[i].bindTooltip(getSigmetBlock(t),{opacity:.9}),sigmets_featuregroup.addLayer(sigmarkers_array[i]))}})}function getSigmetBlock(e){return list='
Convective SIGMET '+getSigmetCode(e)+'
'+nl2br(e.raw_text)+"
",list}function getSigmetCode(e){return e.raw_text.split(/\r?\n/)[2].split(" ")[2]}function lightupFIR(e,a,r,s,i){if("object"==typeof e){var t=[];for(idx in e){e[idx].setStyle({color:"#fff",weight:1,fillColor:"#fff",fillOpacity:.1}),latlng=[Number(e[idx].feature.properties.label_lat),Number(e[idx].feature.properties.label_lon)];var o=new L.divIcon({className:"simaware-ap-tooltip",html:getFirTooltip(s,i,a),iconSize:"auto"});void 0===firmarkers_array[i]?(t[idx]=new L.marker(latlng,{icon:o}),t[idx].bindTooltip(getControllerBlock(e[idx],a,r,s,i),{opacity:1,sticky:!0})):$.each(firmarkers_array[i],(e,t)=>{t.setTooltipContent(getControllerBlock(t[idx],a,r,s,i))}),e[idx].bringToFront()}if(void 0===firmarkers_array[i])for(idx in firmarkers_array[i]=t,firmarkers_array[i])atc_leg_featuregroup.addLayer(firmarkers_array[i][idx])}}function turnOffFIR(e,a){"object"==typeof e&&$.each(e,function(e,t){for(e in t.setStyle({color:"#333",weight:1,fillOpacity:0}).bringToBack(),firmarkers_array[a])atc_leg_featuregroup.removeLayer(firmarkers_array[a][e]);firmarkers_array[a]=void 0})}function turnOffTracon(e){tracons_array[e.split("|")[0]][e.split("|")[1]].setStyle({weight:0,color:"#000"}),atc_leg_featuregroup.removeLayer(tracmarkers_array[e]),tracmarkers_array[e]=void 0}function getFirIndex(e){var t=e.fir.icao+Number(e.fir.is_fss);return t=void 0===firs_array[t]?e.fir.icao+"0":t}function getFirIndexByCallsign(e){var t;t=0
'+e+"
";return r&&(e+='
'+s+"
"),e+="
"}function getTracTooltip(e,t){return'
',ct+=1),e.GND&&(i+='',ct+=1),e.TWR&&(i+='',ct+=1),e.ATIS&&(i+='',ct+=1),""!=i&&(i="
'+e+"
"}function highlightFIR(e){$.each(firs_array[e],(e,t)=>{t.setStyle({fillColor:"#fff",fillOpacity:.4})})}function dehighlightFIR(e){$.each(firs_array[e],(e,t)=>{t.setStyle({fillOpacity:.1})})}function highlightTracon(e){var t=e.split("|");for(idx in tracons_array[t[0]])idx==t[1]&&tracons_array[t[0]][t[1]].setStyle({fillColor:"#40d0e0",fillOpacity:.2})}function dehighlightTracon(e){var t=e.split("|");for(idx in tracons_array[t[0]])idx==t[1]&&tracons_array[t[0]][t[1]].setStyle({fillOpacity:0})}function highlightSigmet(e){sigmets_array[e].setStyle({fillOpacity:.4})}function dehighlightSigmet(e){sigmets_array[e].setStyle({fillOpacity:.1})}function getLocalTooltip(t){var e;locals[t]?e=locals[t]:((e=[]).loc=[],e.loc.icao=t),ct=0,i="";let a="text-white-50",r="rgba(0,0,0,0)";e.DEL&&(i+='
DGTA
"+i+"
",a="text-light",r="rgba(255,255,255,0.1)");let s="";if(eventsByAirport[t]){for(id in days_rem=999,eventsByAirport[t])s=eventsByAirport[t][id],days_rem=Math.min(moment.duration(moment(s.start).diff(moment())).asDays(),days_rem);let e="";e=days_rem<1?"background-color: "+red:days_rem<7?"border: 2px solid rgba(218,41,46,0.5);background-color: rgba(0,0,0,0.5)":"border: 2px solid rgba(218,41,46,0.25);background-color: rgba(0,0,0,0.25)",s='
'}var i="
'+s+'
'+e.loc.icao+"
"+i+"
";return i}function getLocalBlock(a){var e;void 0!==airports[a]&&(city=airports[a].city),void 0!==locals[a]?e=locals[a]:(e=[]).loc=airports[a],ct=0,tt="";var r='";if(e.DEL&&$.each(e.DEL,(e,t)=>{r+='"}),e.GND&&$.each(e.GND,(e,t)=>{r+='"}),e.TWR&&$.each(e.TWR,(e,t)=>{r+='"}),e.ATIS&&$.each(e.ATIS,(e,t)=>{r+='"}),eventslist="",eventsByAirport[a])for(id in eventslist='',eventsByAirport[a])eventslist+='";return r='
'+r+"
'+e.loc.name+'
'+city+"
DEL
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
GND
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
TWR
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
ATIS
'+getAtisCode(t.atis,a)+"
"+t.callsign+''+t.name+''+t.freq+''+getTimeOnline(t)+'
'+t.atis+"
Upcoming Events
'+moment(eventsByAirport[a][id].start).utc().format("MMM")+'
'+moment(eventsByAirport[a][id].start).utc().format("D")+'
'+eventsByAirport[a][id].name+'
'+moment(eventsByAirport[a][id].start).utc().format("HHmm")+" - "+moment(eventsByAirport[a][id].end).utc().format("HHmm")+"Z
",eventsByAirport[a]&&(r+='
'+eventslist+"
"),r+="
"}function getNatBlock(e){var a="";$.each(e.route,(e,t)=>{0!=e&&(a+=' '),a+=t.name});e='

'+e.id+'

North Atlantic Track
'+a+'
TMI '+e.tmi+"";return'
'+(e+="
")+'Data courtesy of Gander Oceanic OCA'}function getControllerBlock(e,t,a,r,s){var i='";return warnings[s]&&(i+='"),$.each(t,function(e,t){i=t.fssname?(i=i+"")+'":i+""}),i='
'+i+"
'+r+" "+a+"
'+warnings[s]+"
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+t.time_online+"
'+t.fssname+" covers "+r+" above FL245
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+t.time_online+"
"}function getTraconBlock(e,t=0){return tracon_name=e.name,list='",$.each(e.members,function(e,t){list=list+""}),list='
'+list+"
'+tracon_name+"
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
",list}async function loadAirlines(){return response=await fetchRetry("/livedata/airlines.json"),airlines=await response.json(),airlinesByIcao={},$.each(airlines,(e,t)=>{void 0===airlinesByIcao[t.icao]?airlinesByIcao[t.icao]=[t]:airlinesByIcao[t.icao].push(t)}),airlinesByIcao}async function loadRegprefixes(){return response=await fetchRetry("/livedata/regprefixes.json"),response.json()}async function loadAircraft(){return response=await fetchRetry("/livedata/aircraft.json"),aircraft=await response.json(),aircraftByIcao={},$.each(aircraft,(e,t)=>{aircraftByIcao[t.icao]=t}),aircraftByIcao}async function initializeNat(){}async function zoomToFlight(e){$("#map").length||(window.location.href="/?uid="+e),$("#streamers-bar").is(":visible")&&$("#streamers-bar").addClass("d-none").removeClass("d-flex"),historical=void 0===plane_array[e]?1:0,"undefined"!=typeof dep_point&&(plane_featuregroup.removeLayer(dep_point),delete dep_point),"undefined"!=typeof arr_point&&(plane_featuregroup.removeLayer(arr_point),delete arr_point),"undefined"!=typeof flightpath&&(plane_featuregroup.removeLayer(flightpath),delete flightpath),plane=plane_array[e],bounds=[],bounds.push(plane.getLatLng()),active_flight=e,historical||refreshFlights(filterName,filterCriteria),$("#search-wrapper").hide(),"undefined"!=typeof ap_featuregroup&&$("#airport-sidebar").hide(),"undefined"!=typeof user_sidebar&&user_sidebar&&$("#user-sidebar").hide(),$("#events-container").hide(),[dep_airport,dep_point,dep_name,dep_city]=processAirport(plane.flight.dep),[arr_airport,arr_point,arr_name,arr_city]=processAirport(plane.flight.arr),dep_point&&arr_point&&([dep_point,arr_point]=processAirportForAntimeridian(plane.flight,airports[dep_airport],airports[arr_airport],dep_point,arr_point)),"undefined"!=typeof ap_featuregroup&&map.hasLayer(ap_featuregroup)?(dep_point&&null!=dep_point&&(ap_featuregroup.addLayer(dep_point),bounds.push(dep_point.getLatLng())),arr_point&&null!=arr_point&&(ap_featuregroup.addLayer(arr_point),bounds.push(arr_point.getLatLng()))):(dep_point&&null!=dep_point&&(plane_featuregroup.addLayer(dep_point),bounds.push(dep_point.getLatLng())),arr_point&&null!=arr_point&&(plane_featuregroup.addLayer(arr_point),bounds.push(arr_point.getLatLng()))),"undefined"!=typeof polyline_featuregroup&&map.hasLayer(polyline_featuregroup)&&map.removeLayer(polyline_featuregroup),togglePlaneTooltip(plane,!0),$("#flights-sidebar").show().addClass("d-flex"),updateFlightsBox(plane.flight),$("#sidebar").hide(),addedFlightPathPromise=addFlightPath(dataserver+"api/livedata/logs/"+e+".json",airports[dep_airport],airports[arr_airport],plane.flight),await addedFlightPathPromise,plane.bringToFront(),window.history.pushState(e,e,"/?uid="+e)}async function addFlightPath(e,t,a,r){e=await(await fetchRetry(e)).json();flightpath=await new L.Polyline(adjustLogsForAntimeridian(r,t,a,e),{smoothFactor:1,color:"#acffd6",weight:2,nowrap:!0}),fp_featuregroup.addLayer(flightpath),map.addLayer(fp_featuregroup)}function toggleStreamers(){$(".map-button#streamers").hasClass("map-button-active")?($("#streamers-bar").removeClass("d-flex").addClass("d-none"),$(".map-button#streamers").removeClass("map-button-active")):($("#streamers-bar").removeClass("d-none").addClass("d-flex"),$(".map-button#streamers").addClass("map-button-active"))}function toggleWorldflight(){map.hasLayer(wf_featuregroup)?($(".map-button#wf").removeClass("map-button-active"),map.removeLayer(wf_featuregroup)):($(".map-button#wf").addClass("map-button-active"),map.addLayer(wf_featuregroup))}function toggleLabels(){"undefined"==typeof locLabels?(locLabels=("undefined"==typeof basemap?L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19}):L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/dark_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19})).addTo(map),$(".map-button#labels").addClass("map-button-active"),$.cookie("labels","true",{expires:180})):(map.removeLayer(locLabels),delete locLabels,$(".map-button#labels").removeClass("map-button-active"),$.cookie("labels","false",{expires:180}))}function flipLabels(e){map.removeLayer(locLabels),locLabels=("dark"==e?L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/dark_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19}):L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19})).addTo(map)}function toggleBasemap(){"undefined"==typeof basemap?(map.removeLayer(lightbasemap),basemap=L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png",{attribution:"",subdomains:"abcd"}).addTo(map),$(".map-button#light").removeClass("map-button-active"),setLayerOrder(),setBasemapOrder(),lightbasemap=void 0,$.cookie("lightmap","false",{expires:180}),map.hasLayer(locLabels)&&flipLabels("dark")):(map.removeLayer(basemap),lightbasemap=L.tileLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",{attribution:""}).addTo(map),$(".map-button#light").addClass("map-button-active"),setLayerOrder(),setBasemapOrder(),basemap=void 0,$.cookie("lightmap","true"),"undefined"!=typeof locLabels&&map.hasLayer(locLabels)&&flipLabels("light"))}function togglePlaneTooltip(e,t){e.unbindTooltip(),[offset,dir]=getMarkerDirection(e.flight),e.bindTooltip(getDatablock(e.flight),{permanent:t,direction:dir,offset:offset})}function processAirport(e){var t,e=airports[e]?((t=L.circleMarker(new L.LatLng(airports[e].lat,airports[e].lon),{radius:2,stroke:!1,fillColor:"#00d300",fillOpacity:1})).bindTooltip(airports[e].iata,{permanent:!0,className:"tooltip-airport"}),[e,t,airports[e].name,airports[e].city]):[e,null,"Unknown Airport","Unknown City"];return e}function getColor(e){return e<80?"text-success":e<100?"text-warning":"text-danger"}function getFlightColor(e){1<(e=(e-15)/35)?e=1:e<0&&(e=0);var t=1-2*e;(s=-t)<0&&(s=0),t<0&&(t=0);var a=1-2*Math.abs(e-.5),r=s+t+a,s=s/r;t/=r,a/=r;var i=[255,77,77],e=[51,204,51],r=[255,179,26];return"rgb("+Math.floor(s*i[0]+t*e[0]+a*r[0])+","+Math.floor(s*i[1]+t*e[1]+a*r[1])+","+Math.floor(s*i[2]+t*e[2]+a*r[2])+")"}async function returnToView(){map.hasLayer(fp_featuregroup)&&(togglePlaneTooltip(plane,!1),manual||("undefined"!=typeof ap_featuregroup&&(map.addLayer(ap_featuregroup),$("#airport-sidebar").show()),"undefined"!=typeof user_sidebar&&user_sidebar&&$("#user-sidebar").show()),plane_featuregroup.removeLayer(dep_point),delete dep_point,plane_featuregroup.removeLayer(arr_point),delete arr_point,fp_featuregroup.removeLayer(flightpath),flightpath=null,map.removeLayer(fp_featuregroup),fp_featuregroup=new L.FeatureGroup,$("#flights-sidebar").hide().removeClass("d-flex"),$("#sidebar").show(),$("#events-container").show(),$(".map-button#streamers").hasClass("map-button-active")&&$("#streamers-bar").addClass("d-flex").removeClass("d-none"),active_flight=null),"undefined"!=typeof polyline_featuregroup&&map.addLayer(polyline_featuregroup),window.history.pushState("home","home","/")}function handleCookies(){"true"==$.cookie("atc")&&toggleATC(),"true"==$.cookie("lightmap")&&toggleBasemap(),"true"==$.cookie("sigmet")&&toggleSigmet(),"true"==$.cookie("nat")&&toggleNat(),"true"==$.cookie("wx")&&toggleNexrad(),"true"==$.cookie("labels")&&toggleLabels(),$(".map-button").removeClass("d-none"),$(".loading").addClass("d-none")}function updateFlightsBox(e){$("#flights-callsign").html(e.callsign),flight_status=getStatus(e),$(".flights-liveitem#spd").html(e.gndspd+" kt"),$(".flights-liveitem#alt").html(e.alt+" ft"),$(".flights-liveitem#togo").html(Math.round(getDtg(e))+" nm"),$("#flights-status").html(flight_status.status),$("#flights-status").css({"background-color":flight_status.color}),$("#flights-progressbar-plane").css({color:flight_status.color}),$("#flights-progressbar-elapsed").css({"background-color":flight_status.color}),flight_status.blink?$("#flights-progressbar-plane").addClass("blinking"):$("#flights-progressbar-plane").removeClass("blinking"),updateAirlines(e);var t=getTimeAirborne(e);"nodep"!=t.status?($("#flights-airborne-container").addClass("d-flex").removeClass("d-none"),hrstring=1==t.timeonline[0]?t.timeonline[0]+" hour, ":t.timeonline[0]+" hours, ",mnstring=1==t.timeonline[1]?t.timeonline[1]+" minute":t.timeonline[1]+" minutes",timestring=0==t.timeonline[0]?mnstring:hrstring+mnstring,$("#flights-timeairborne").addClass("mt-2").html("Time Airborne: "+timestring)):($("#flights-airborne-container").addClass("d-none").removeClass("d-flex"),$("#flights-timeairborne").removeClass("mt-2").html("")),[dep_airport,dep_point_,dep_name,dep_city]=processAirport(plane.flight.dep),[arr_airport,arr_point_,arr_name,arr_city]=processAirport(plane.flight.arr),$("#flights-dep-icao").html('"),$("#flights-airport-dep").html('"),$("#flights-arr-icao").html('"),$("#flights-airport-arr").html('"),$("#flights-progressbar-elapsed").css({width:getElapsedWidth(e)+"%"}),$("#flights-route").html(e.route),$("#flights-equipment").html(e.aircraft),$("#flights-name").html(''+e.name+""+getBadge(e.rating)+" "+getPatron(e.cid)),e.xpdr=padToFourDigits(e.xpdr),e.axpdr=padToFourDigits(e.axpdr),$("#flights-squawk").html(e.xpdr+" / "+e.axpdr)}function padToFourDigits(e){return e.toString().padStart(4,"0")}function updateAirlines(e){for(var t in regprefixes)if(e.callsign.match(regprefixes[t].regex))return void $("#flights-airline").html("Privately Registered ("+regprefixes[t].country+")");var r,a;3{var a=t.name;t.va&&(a+=' VA'),r.push(a)}),a=r.join("
"),1 Multiple Airlines

'+a),$("#flights-airline").html(a)):$("#flights-airline").html("")}function getPatron(e){if(!patrons[e])return"";switch(patrons[e].tier){case 1:return' Supporter';case 2:return' Streamer';case 3:return' Diamond';default:return""}}function processAirportForAntimeridian(e,t,a,r,s){return crossesAntimeridian(t,a)&&(dep_latlon=r.getLatLng(),arr_latlon=s.getLatLng(),0Number(e.lon)&&180<=getRhumbLineBearing(Number(e.lat),Number(e.lon),Number(t.lat),Number(t.lon))&&(flag=-1),flag)}function adjustLogsForAntimeridian(a,e,t,r){return newLogs=[],crossesAntimeridian(e,t)?(newLogs=[],$.each(r,function(e,t){lat=Number(t[0]),lon=Number(a.lon)<0&&0\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"
":"
")+"$2")}function getControllerRating(e){return["SP","OBS","S1","S2","S3","C1","C2","C3","I1","I2","I3","SUP","ADM"][e]}function wait(t){return new Promise(e=>setTimeout(e,t))}function fetchRetry(t,a=1e3,r=3,s={}){return fetch(t,s).catch(function(e){if(triesLeft=r-1,!triesLeft)throw e;return wait(a).then(()=>fetchRetry(t,a,triesLeft,s))})}function findLayersPosition(e){var t=e.callsign.split("_")[0];if(layers_positions[t])for(var a in layers_positions[t])if(e.freq==layers_positions[t][a].freq)return layers_positions[t][a];return null}function findLayersSectors(e){var t,a,r={},s=[];for(t in e){var i=Object.keys(e[t]);for(l in layers_array[t]){var o=!1;for(k in layers_array[t][l].feature.properties.owner)i.includes(layers_array[t][l].feature.properties.owner[k])&&!o&&(r[layers_array[t][l].feature.properties.owner[k]]?r[layers_array[t][l].feature.properties.owner[k]].push(t+"|"+l):r[layers_array[t][l].feature.properties.owner[k]]=[t+"|"+l],o=!0,s.push(t+"|"+l))}}for(a in e)for(var n in e[a])for(var l in layers_s[n])s.includes(layers_s[n][l])||(r[n]?r[n].push(layers_s[n][l]):r[n]=[layers_s[n][l]],s.push(layers_s[n][l]));return r}function returnDisplaySectors(e,t){var a,r=[];for(a in e)for(j in e[a]){var s=e[a][j].split("|"),i=layers_array[s[0]][s[1]];if((i.feature.properties.max&&i.feature.properties.max>=t||!i.feature.properties.max)&&(i.feature.properties.min&&i.feature.properties.min<=t||!i.feature.properties.min))if(i.feature.properties.rwy){var o=0;for(c in i.feature.properties.rwy){var n=i.feature.properties.rwy[c].icao;let t=i.feature.properties.rwy[c].runway;if(locals[n]&&locals[n].rwy){let e=locals[n].rwy.join("|");for(var l in t)for(var c in t[l].split("/"))e.includes(t[l].split("/")[c])&&(o=1)}}o&&r.push(e[a][j])}else r.push(e[a][j])}return r}function showLayersView(e){new_active_layers_pos=[],new_active_layers_sectors=[];var t,a,r,s=returnDisplaySectors(layers_sectors,e);for(r in layers_sectors){for(var i in ctr=[],layers_sectors[r]){var o=r.split("/"),n=layers_pos[o[0]][r],l=layers_sectors[r][i].split("|");n.atc&&s.includes(l[0]+"|"+l[1])&&(layers_featuregroup.addLayer(layers_array[l[0]][l[1]]),new_active_layers_sectors.push(l[0]+"|"+l[1]),0<=$.inArray(l[0]+"|"+l[1],active_layers_sectors)&&active_layers_sectors.splice(active_layers_sectors.indexOf(l[0]+"|"+l[1]),1),n.atc[0].callsign.includes("_CTR")||n.atc[0].callsign.includes("_FSS")?layers_array[l[0]][l[1]].setStyle({fillColor:"#aaa",fillOpacity:0,weight:1,color:"#ddd"}):layers_array[l[0]][l[1]].setStyle({fillColor:"#40e0d0",fillOpacity:0,weight:1,color:"#40e0d0"}),ctr.push(layers_array[l[0]][l[1]].feature.geometry.coordinates[0]))}ctr.length&&(t=turf.pointOnFeature(turf.multiPolygon(ctr)),0<=$.inArray(r,active_layers_pos)&&active_layers_pos.splice(active_layers_pos.indexOf(r),1),a=n.atc[0].callsign.includes("_CTR")||n.atc[0].callsign.includes("_FSS")?'
'+n.atc[0].callsign.split("_")[0]+"/"+r.split("/")[1]+"
":'
';var s=Handlebars.compile('{{#if results.length}}{{#each results}}{{/each}}{{else}}{{/if}}'),e=Handlebars.compile('{{#if trigger}}{{#if results.length}}{{#each results}}{{/each}}{{else}}{{/if}}{{else}}{{/if}}'),i=s({results:r.flights}),o=e({results:r.airports,trigger:2
Loading...
');var t=await fetchRetry("https://api.simaware.ca/api/user/"+e);user=await t.json(),$("#pilot-name").html(user.name);t=await(t=await fetchRetry("https://api.simaware.ca/api/moreflights/"+e+"/0")).json();html="",$.each(t,(e,t)=>{html+='
"}),$("#flight-list").html(html)}async function zoomToUser(e){$("#map").length&&!manual||(window.location.href="/?user="+e),"undefined"!=typeof ap_featuregroup&&returnFromAirport(),$("#user-sidebar").show(),$("#search-wrapper").hide(),user_sidebar=!0,await initializeUser(e),window.history.pushState(e,e,"/?user="+e)}$(document).ready(()=>{$("#search-field").on("input",()=>{searchAction()})}); \ No newline at end of file +function initializeAirport(e){(async()=>{for(;!window.hasOwnProperty("airports")||!window.hasOwnProperty("flights");)await new Promise(e=>setTimeout(e,10));airport=airports[e],null!=airport&&($("#airport-icao").html(airport.icao),$("#airport-city").html(airport.city),$("#airport-name").html(airport.name)),el=document.getElementById("sidebar-container"),L.DomEvent.disableScrollPropagation(el),L.DomEvent.disableClickPropagation(el)})()}function zoomToAirport(a,e=0){$("#map").length&&!manual||(window.location.href="/?airport="+a),returnToView(),returnSidebarToView("airport-sidebar","control-airport-pullout"),$("#user-sidebar").hide(0),$("#user-sidebar").hide(0),$("#airport-sidebar").show(),"undefined"!=typeof ap_featuregroup&&map.hasLayer(ap_featuregroup)&&(map.removeLayer(ap_featuregroup),delete ap_featuregroup),ap_featuregroup=new L.FeatureGroup,initializeAirport(a),updateAirportFlights(airports,flights,a);var r=[];map.removeLayer(plane_featuregroup),$.each(flights,(e,t)=>{t.dep!=a&&t.arr!=a||(ap_featuregroup.addLayer(plane_array[e]),r.push([t.lat,t.lon]))}),console.log(r),map.addLayer(ap_featuregroup),e||map.fitBounds(r),$("#search-wrapper").hide(),window.history.pushState(a,a,"/?airport="+a)}function returnFromAirport(){"undefined"!=typeof ap_featuregroup&&(map.removeLayer(ap_featuregroup),delete ap_featuregroup),map.hasLayer(plane_featuregroup)||map.addLayer(plane_featuregroup),window.history.pushState("home","home","/"),$("#airport-sidebar").hide()}function updateAirportFlights(a,e,r){console.log("Updating Airports");var s=[],i=[];$.each(e,(e,t)=>{console.log(t.callsign+" "+t.dep+" "+t.arr),console.log(t.arr==r),console.log(r),t.arr==r?i.push(t):t.dep==r&&s.push(t)}),html="",depscount=0,arrscount=0,$.each(s,(e,t)=>{[airportname,airportcity]=getAirportDetails(a,t.arr),html=html+'",depscount++}),$.each(i,(e,t)=>{[airportname,airportcity]=getAirportDetails(a,t.dep),html=html+'",arrscount++}),$("#airport-list").html(html),$("#depcount").html(depscount),$("#arrcount").html(arrscount)}function getAirportLoad(a){var r=0;return $.each(flights,(e,t)=>{t.dep!=a&&t.arr!=a||r++}),r}function getAirportDetails(e,t){return null!=e[t]?returnvalue=[e[t].name,e[t].city]:(returnvalue=["Unknown Airport","Unknown City"],console.log("UNKNOWN: "+t)),returnvalue}function getAtisCode(e,a){return atis_exploded=e.replace("."," ").replace(","," ").toUpperCase().split(" "),delete code,$.each(atis_exploded,function(e,t){if("INFO"==t||"INFORMATION"==t||"ATIS"==t&&atis_exploded[e-1]==a&&"INFO"!=atis_exploded[e+1]&&"INFORMATION"!=atis_exploded[e+1])return code=atis_exploded[e+1],!1}),"undefined"==typeof code&&$.each(atis_exploded,function(e,t){if(t==a)return code=atis_exploded[e+1],!1}),"undefined"!=typeof code?1==code.length?code:convertToLetter(code):"-"}function convertToLetter(e){return void 0!==codes[e]?codes[e]:"-"}function getAtisRwy(e){var t,a=["RWY IN USE","RWYS IN USE","RUNWAY IN USE","RUNWAYS IN USE","RUNWAY","RWY","ILS","VISUAL","APCHS","APCH","APPR","LANDING"],r=[];for(t in a){var s=a[t];if(e.includes(s)){const n={zero:"0",one:"1",two:"2",three:"3",four:"4",five:"5",six:"6",seven:"7",eight:"8",niner:"9"};var i=new RegExp("\\b("+Object.keys(n).join("|")+")\\b","ig"),[,...s]=(e=e.replace(i,e=>n[e.toLowerCase()]).replace(/[,.]/g,"").replace(/RIGHT/gi,"R").replace(/LEFT/gi,"L").replace(/\b(\d)\s+(\d)\s+([RL])\b/gi,"$1$2$3").replace(/\b(\d)\s+([RL])\b/gi,"$1$2")).split(s),o=s.join(" ").split(" ");for(j in o){if(15
'+n.atc[0].callsign.split("_")[0]+"/"+r.split("/")[1]+"
",a=new L.divIcon({className:"simaware-layers-tooltip",html:a,iconSize:"auto"}),layers_markers_array[r]?(layers_markers_array[r].setLatLng([t.geometry.coordinates[1],t.geometry.coordinates[0]]),layers_markers_array[r].setTooltipContent(getLayersControllerBlock(n))):(layers_markers_array[r]=new L.marker([t.geometry.coordinates[1],t.geometry.coordinates[0]],{icon:a}),layers_markers_array[r].bindTooltip(getLayersControllerBlock(n),{opacity:1,sticky:!0}),layers_featuregroup.addLayer(layers_markers_array[r]))),new_active_layers_pos.push(r)}for(r in active_layers_sectors){l=active_layers_sectors[r].split("|");layers_featuregroup.removeLayer(layers_array[l[0]][l[1]])}for(r in active_layers_pos)layers_featuregroup.removeLayer(layers_markers_array[active_layers_pos[r]]);active_layers_pos=new_active_layers_pos,active_layers_sectors=new_active_layers_sectors,$("#layers-alt").html(100*layers_alt)}function highlightLayersObject(e){var t=layers_sectors[e];for(idx in t){var a=t[idx].split("|");layers_array[a[0]][a[1]].setStyle({fillOpacity:.4})}}function dehighlightLayersObject(e){var t=layers_sectors[e];for(idx in t){var a=t[idx].split("|");layers_array[a[0]][a[1]].setStyle({fillOpacity:0})}}function getLayersControllerBlock(e){for(var t in tracon_name=e.name,list='",e.atc)list+="";return list='
'+list+"
'+e.callsign+"
"+e.atc[t].callsign+''+e.atc[t].name+''+getControllerRating(e.atc[t].rating)+''+e.atc[t].freq+''+getTimeOnline(e.atc[t])+"
",list}var green="#13b955",blue="#009cdc",yellow="#efa31d",red="#da292e",gray="#aaaaaa";function getElapsedWidth(e){return 100*(getDfd(e)/getTotalDistance(e)-$("#flights-progressbar-plane").width()/2/$("#flights-progressbar").width())}function getInfoElapsedWidth(e){return value=getDfd(e)/getTotalDistance(e)*100-6,value<0?0:value}function getRhumbLineBearing(e,t,a,r){return dLon=deg2rad(r)-deg2rad(t),dPhi=Math.log(Math.tan(deg2rad(a)/2+Math.PI/4)/Math.tan(deg2rad(e)/2+Math.PI/4)),Math.abs(dLon)>Math.PI&&(dLon=0{var a,r;a="al"==i?(console.log(t.callsign),(null!==a&&null!==(a=t.callsign.match(/[A-Z]+/))&&a.length?a[0]:t.callsign).toLowerCase()):("dep"==i?t.dep:"arr"==i?t.arr:t.aircraft+"|"+t.arr+"|"+t.callsign+"|"+t.dep+"|"+t.cid+"|"+t.route).toLowerCase(),"al"==i||"dep"==i||"arr"==i?a==s&&(r=getStatus(t),o.flights.push({callsign:t.callsign,aircraft:t.aircraft,arr:t.arr,dep:t.dep,route:t.route,uid:t.uid,status:r})):a.includes(s)&&(r=getStatus(t),o.flights.push({callsign:t.callsign,aircraft:t.aircraft,arr:t.arr,dep:t.dep,route:t.route,uid:t.uid,status:r}))}),2{(t.icao+"|"+t.name+"|").toLowerCase().includes(s)&&o.airports.push({icao:t.icao,name:t.name,iata:t.iata,city:t.city})}),o}function compileSearchResults(e){var[t,a]=parseSearch(e),r=runSearch(a,t);if(!a.length)return'
Begin typing to search.

Helpers:
ap:Airport search
al:Airline search
flight:Callsign search
dep:Search by departure airport
arr:Search by arrival airport
Flights ({{ results.length }})

{{ this.callsign }}

{{ this.cid }} {{#if this.dep }}{{ this.dep }} - {{ this.arr }} - {{ this.aircraft }} - {{ this.status.status }}{{ else }} No flightplan {{/if}}
No results.
Airports ({{ results.length }})

{{ this.icao }} / {{ this.iata }}
{{ this.name }}

No results.
At least 3 characters required.
',void 0!==plane_array[t.uid]?html+='Live':html+=t.date,html+=''+t.callsign+"
"+t.dep+" ("+t.depicao+")
"+t.arr+" ("+t.arricao+")
'+t.callsign+'to'+t.arr+''+airportcity+"
'+t.callsign+'from'+t.dep+''+airportcity+"
'+moment.utc(eventdata.event.start).format("MMM")+'
'+moment.utc(eventdata.event.start).format("D")+'
'+eventdata.event.name+'
'+moment.utc(eventdata.event.start).format("HHmm")+"-"+moment.utc(eventdata.event.end).format("HHmm")+"Z
"),$("#event-date").html(moment(eventdata.event.start).format("MMMM Do, YYYY"));var a="",r={};aar={},$.each(eventdata.event.airports,(e,t)=>{r[t.icao]=airportSearch(t.icao),aar[t.icao]={deps:[],arrs:[]},a+='
'+t.icao+"
"}),$("#events-aps").html(a),$.each(eventdata.departures,(e,t)=>{1{ll.push([t[0],t[1]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#00cc66",opacity:.4,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e])),t.accel&&t.dep&&didDepart(t,r)&&aar[t.dep].deps.push([t])}),$.each(eventdata.arrivals,(e,t)=>{1{ll.push([t[0],t[1]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#3366ff",opacity:.4,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e])),t.decel&&t.arr&&didArrive(t,r)&&aar[t.arr].arrs.push([t])}),aarbins=[];var t="";start=moment(eventdata.event.start),end=moment(eventdata.event.end),0==start.minutes()?start.add(-60,"minutes"):start.startOf("hour"),0==end.minutes?end.add(60,"minutes"):end.add(60,"minutes").startOf("hour");for(var s=1e3*start.unix();s<1e3*end.unix();s+=18e5)(B={}).start=s,B.stop=s+1799999,aarbins.push(B);var i=0;for(y in aar){t+='';var o=aar[y],n=[],l=[];for(_ in aarbins){var c,d=aarbins[_],p=[],u=[];for(c in o.deps)(x=o.deps[c][0]).accel>d.start&&x.acceld.start&&x.decel':_%2==1?'"}for(_ in t+='',aar[y].deps)t+=0==_?"";for(_ in t+="",aarbins)_%2==0&&(t+=0==_?'":t+=moment(aarbins[_].start).hour()+"Z");t+=""}$("#events-table").html(t),$(".analysis-button").attr("onclick","showAnalysis('"+eventdata.event.airports[0].icao+"'); $('#splitmodal').show();");var f=[];for(s in aar){var m=airportSearch(s),g=Number(m.lat),h=Number(m.lon);f.push([g,h]);m=new L.divIcon({className:"simaware-ap-tooltip",html:getEventTooltipNew(m,aar),iconSize:"auto"});oloc=new L.marker([g,h],{icon:m}),map.addLayer(oloc)}map.fitBounds(f,[50,50]),10'+y+"":b+=''+y+"",$("#analysis_airports").html(b),t+='';var _,w=[];for(_ in v.arrs){var x,B,A,C=v.arrs[_];for(c in C)(x=C[c]).landoffset&&didArrive(x,r)&&(B={},A=getEventOffset(x,r[y],eventdata,start),B.flight=x,B.lenpct=(x.landoffset-A)/(1e3*end.unix()-1e3*start.unix())*15e5,B.right=100*(1e3*end.unix()-x.decel)/(1e3*end.unix()-1e3*start.unix()),B.timeinMins=15e3*(x.landoffset-A)/6e4,w.push(B))}w.sort(function(e,t){return t.right-e.right}),aar[y].analysis=w}b="",t="";for(s in aar)b+=''+s+"";cycleEvents(0)}function showAnalysis(r){var e="";$(".analysis_chooser").each(function(){$(this).attr("id")==r?$(this).css({"background-color":"#3137fd"}):$(this).css({"background-color":"transparent"})});var t,s="",i=end.diff(start,"minutes");for(t in $.each(aarbins,(e,t)=>{var a=moment(t.start),a=moment(t.stop).diff(a,"minutes")/i*100;borderleft="dashed",borderright="dashed",s+='",console.log(s),$("#analysis_toptable").html(s),aar[r].analysis)0 ');var o='
ARR '+aar[r].arrs[e].length+"
DEP "+aar[r].deps[e].length}),s+="
';console.log(aar[r]);for(let e=0;e{console.log(t);var a=moment(t.start),t=moment(t.stop).diff(a,"minutes")/i*100;borderleft="dashed",borderright="dashed",o+='"}),o+="";o+="
'+a.format("HHmm")+" Z
",$("#analysis").html(e+o),$('[data-toggle="tooltip"]').tooltip()}function getEventOffset(e,t,a,r){for(var s in e.logs){var i=e.logs[s];if(distance(t.lat,t.lon,i[0],i[1])<80)return s}}async function loadLegacyEvent(e){response=await fetch("/legacyevents/eventsummary"+e+".json"),eventdata=await response.json(),$("#event-name").html(eventdata.name),$("#event-date").html(moment(eventdata.start).format("MMMM Do, YYYY"));let a="";$.each(eventdata.airports.split(","),(e,t)=>{a+='
'+t+"
"}),$("#events-aps").html(a),$("#events-table").html(returnEventsTable(eventdata.aarstore[0])),(1==Object.keys(eventdata.aarstore).length?replaceAarData:cycleLegacyEvents)(0),bounds=[],$.each(eventdata.aarstore,(e,t)=>{var a=Number(t.ap.lat),r=Number(t.ap.lon);bounds.push([a,r]);t=new L.divIcon({className:"simaware-ap-tooltip",html:getEventTooltip(t),iconSize:"auto"});oloc=new L.marker([a,r],{icon:t}),map.addLayer(oloc)}),map.fitBounds(bounds,[50,50]),1==bounds.length&&map.setZoom(8),response=await fetch("/legacyevents/event"+e+".json"),eventpaths=await response.json(),polyline_array=[],polyline_featuregroup=new L.FeatureGroup,map.addLayer(polyline_featuregroup),$.each(eventpaths,(e,t)=>{1{ll.push([t[1],t[0]])}),polyline=new L.Wrapped.Polyline(ll,{color:"#fff",opacity:.2,weight:2}),polyline_array[e]=polyline,polyline_featuregroup.addLayer(polyline_array[e]))})}function getEventTooltip(e){let a=0;return $.each(e.aar,(e,t)=>{a+=t[2]}),'
'+e.ap.icao+'
'+a+"
"}function getEventTooltipNew(e){let t=0;for(var a in aar[e.icao].deps)t+=aar[e.icao].deps[a].length;for(var a in aar[e.icao].arrs)t+=aar[e.icao].arrs[a].length;return'
'+e.icao+'
'+t+"
"}function getWfTooltip(e){return'
'+e.icao+'
'+getAirportLoad(e.icao)+"
"}function cycleEvents(e){var t,a;e>=Object.keys(aar).length?cycleEvents(0):(a=airportSearch(t=Object.keys(aar)[e]),$("#event-ap").html(""+a.icao+" "+a.name+'
'+a.city+""),$(".events-e#"+t).fadeIn(300,function(){1=Object.keys(eventdata.aarstore).length?cycleLegacyEvents(0):(replaceAarData(e),$(".aarelement").each(function(){$(this).animate({opacity:1},300)}),$("#events-airport").animate({opacity:1},300,function(){$(".aarelement").each(function(){$(this).delay(5e3).animate({opacity:0},150)}),$(this).delay(5e3).animate({opacity:0},150,function(){cycleLegacyEvents(e+1)})}))}function returnEventsTable(e){for(element in ct=Object.keys(e.aar).length,text='',e.aar)text+='';for(element in text+='",e.aar)text+='";return text+="
 
 

'+moment(e.aar[0][0].date).format("HHmm[Z]")+"

'+moment(e.aar[element][1].date).format("HHmm[Z]")+"
",text}function getCity(e){return city=e.ap.city==e.ap.country?e.ap.city:e.ap.state?e.ap.city+", "+e.ap.state:e.ap.city+", "+e.ap.country,city}function replaceAarData(e){$("#events-name").html(eventdata.aarstore[e].ap.name),$("#events-icao").html(eventdata.aarstore[e].ap.icao),$("#events-city").html(getCity(eventdata.aarstore[e])),$.each(eventdata.aarstore[e].aar,function(e,t){$("#aar"+e).html(''+t[2]+"")})}async function loadUpcomingEvents(){let e=await fetch(dataserver+"api/livedata/events.json");events=await e.json();let r=[];return $.each(events.future,(e,a)=>{var t;0<=moment.duration(moment(a.start).diff(moment())).asDays()&&moment.duration(moment(a.start).diff(moment())).asDays()<14&&(t=a.airports,$.each(t,(e,t)=>{void 0!==r[t.icao]?r[t.icao].push(a):r[t.icao]=[a]}))}),r}function didDepart(e,t){for(var a in e.logs){a=e.logs[a];if(distance(a[0],a[1],t[e.dep].lat,t[e.dep].lon)<5)return!0}return!1}function didArrive(e,t){for(var a in e.logs){a=e.logs[a];if(distance(a[0],a[1],t[e.arr].lat,t[e.arr].lon)<5)return!0}return!1}async function initializeInfobar(){await initializePatrons(),await updateInfobar(),infobar_streamers()}async function updateInfobar(){al={},$.each(bnfoairports,e=>{al[e]=bnfoairports[e].departures+bnfoairports[e].arrivals});let t=[];for(var e in al)t.push([e,al[e]]);t.sort(function(e,t){return t[1]-e[1]}),infoairports=[];var r='
Popular Airports
';for(let e=0;e<10;e++){var a=airportSearch(bnfoairports[t[e][0]].icao);infoairports.push(bnfoairports[t[e][0]]),r+=""}r+="
#'+(e+1)+''+getLocalTooltip(bnfoairports[t[e][0]].icao)+''+a.name+'
'+a.city+'
'+bnfoairports[t[e][0]].departures+' '+bnfoairports[t[e][0]].arrivals+"
",$("#ap-wrapper").html(r),r='
Upcoming Events
',prevdate=null;let s=0,i=0;for(;i<10;){if(events.future[s].end>moment.now()){for(var o in r+='",r+='",prevdate=moment.utc(events.future[s].start).format("MMMD"),i++}s++}r+="
',prevdate!=moment.utc(events.future[s].start).format("MMMD")&&(r+='
'+moment.utc(events.future[s].start).format("MMM")+'
'+moment.utc(events.future[s].start).format("D")+"
"),r+="
',r+='
',r+=''+events.future[s].name+"",moment.now()>events.future[s].start&&moment.now()Live'),r+="
",r+=""+moment.utc(events.future[s].start).format("HHmm")+"-"+moment.utc(events.future[s].end).format("HHmm")+"Z ",events.future[s].airports)r+='"+events.future[s].airports[o].icao+" ";r+="
",$("#events-wrapper").html(r),$("#events-wrapper .event-date:first").css({"background-color":"rgba(255, 255, 255, 0.1)","border-radius":"5px"}),infostreamers={pilots:[],controllers:[]},r='
Active Streamers
',$.each(flights,(t,a)=>{if(patrons[a.cid]&&(2<=patrons[a.cid].tier||!patrons[a.cid].tier)&&streamers[patrons[a.cid].twitch]){let e={};e.uid=t,e.dep=a.dep,e.arr=a.arr,e.dep||(e.dep="NONE"),e.arr||(e.arr="NONE"),e.streamername=patrons[a.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.callsign=a.callsign,infostreamers.pilots.push(e);t=plane_array[e.uid].flight,a=getStatus(t);r+='"}}),$.each(tracons,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),$.each(sectors,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),$.each(localsraw,(e,t)=>{if(patrons[t.cid]&&(2<=patrons[t.cid].tier||!patrons[t.cid].tier)&&streamers[patrons[t.cid].twitch]&&!t.callsign.includes("_ATIS")){let e={};e.cid=t.cid,e.name=t.name,e.streamername=patrons[t.cid].twitch,e.url="https://twitch.tv/"+e.streamername,e.position=t.callsign,infostreamers.controllers.push(e),r+='"}}),r+="
'+e.streamername+''+e.dep+'
'+e.arr+"
'+e.streamername+''+e.position+"
'+e.streamername+''+e.position+"
'+e.streamername+''+e.position+"
",$("#streamers-wrapper").html(r)}function infobar_airports(){$("#infobar-title").html('Popular Airports'),$("#infobar-title").delay(500).fadeIn(250,()=>{infobar_airports_scroll(0)})}function infobar_airports_scroll(e,t=10){t<=e?$("#infobar-title").fadeOut(250,function(){infobar_streamers()}):(airport=airports[infoairports[e].icao],$("#infobar-content").html(""),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_airports_scroll(e+1)})}))}function infobar_streamers(){0==infostreamers.pilots.length&&0==infostreamers.controllers.length?infobar_airports():($("#infobar-title").html('Streamers'),$("#infobar-title").delay(500).fadeIn(250,()=>{infobar_streamers_scroll(0,"pilots")}))}function infobar_streamers_scroll(a,r){if(void 0===infostreamers[r]||void 0===infostreamers[r][a])"pilots"==r&&infobar_streamers_scroll(0,"controllers"),"controllers"==r&&$("#infobar-title").fadeOut(500,function(){infobar_airports()});else if("pilots"==r&&void 0!==plane_array[infostreamers[r][a].uid]){var s=plane_array[infostreamers[r][a].uid].flight,i=getStatus(s);let e=infostreamers[r][a].dep,t=infostreamers[r][a].arr;e=e||"NONE",t=t||"NONE";var o="https://twitch.tv/"+infostreamers[r][a].streamername;$("#infobar-content").html('
"),$("#infobar-flights-progressbar-plane").css({color:i.color}),$("#infobar-flights-progressbar-elapsed").css({"background-color":i.color}),$("#infobar-flights-progressbar-elapsed").css({width:getInfoElapsedWidth(s)+"%"}),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_streamers_scroll(a+1,r)})})}else"controllers"==r?(s="twitch"==infostreamers[r][a].platform?"https://twitch.tv/"+infostreamers[r][a].streamername:"https://youtube.com/c/"+infostreamers[r][a].streamername+"/live",$("#infobar-content").html('
'+infostreamers[r][a].position+"
"),$("#infobar-content").delay(300).animate({left:"0px",opacity:1},250,"easeOutSine",()=>{$("#infobar-content").delay(5e3).animate({opacity:0},250,"easeOutSine",function(){$("#infobar-content").css({left:"-20px"}),infobar_streamers_scroll(a+1,r)})})):infobar_streamers_scroll(a+1,r)}codes={ALPHA:"A",BRAVO:"B",CHARLIE:"C",DELTA:"D",ECHO:"E",FOXTROT:"F",GOLF:"G",HOTEL:"H",INDIA:"I",JULIET:"J",KILO:"K",LIMA:"L",MIKE:"M",NOVEMBER:"N",OSCAR:"O",PAPA:"P",QUEBEC:"Q",ROMEO:"R",SIERRA:"S",TANGO:"T",UNIFORM:"U",VICTOR:"V",WHISKEY:"W",XRAY:"X",YANKEE:"Y",ZULU:"Z"},$(document).ready(()=>{$("#ap-toggle").on("click",()=>{$("#ap-wrapper").toggle(),$("#streamers-wrapper").hide(),$("#events-wrapper").hide(),$("#streamers-toggle").removeClass("toggle-item-active"),$("#events-toggle").removeClass("toggle-item-active"),$("#ap-wrapper").is(":visible")?$("#ap-toggle").addClass("toggle-item-active"):$("#ap-toggle").removeClass("toggle-item-active")}),$("#streamers-toggle").on("click",()=>{$("#streamers-wrapper").toggle(),$("#ap-wrapper").hide(),$("#events-wrapper").hide(),$("#streamers-wrapper").is(":visible")?$("#streamers-toggle").addClass("toggle-item-active"):$("#streamers-toggle").removeClass("toggle-item-active"),$("#events-toggle").removeClass("toggle-item-active"),$("#ap-toggle").removeClass("toggle-item-active")}),$("#events-toggle").on("click",()=>{$("#events-wrapper").toggle(),$("#ap-wrapper").hide(),$("#streamers-wrapper").hide(),$("#events--toggle").removeClass("toggle-item-active"),$("#events-wrapper").is(":visible")?$("#events-toggle").addClass("toggle-item-active"):$("#events-toggle").removeClass("toggle-item-active"),$("#events-toggle").addClass("toggle-item-active"),$("#ap-toggle").removeClass("toggle-item-active")})}),r2server="https://r2.simaware.ca/",dataserver="https://data.simaware.ca/";const warnings={NAT0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information.",CZQO0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information.",EGGX0:"Oceanic clearance required for entry. See ganderoceanic.ca for more information."},wf=["YSSY","YMML","YWKS","SCGC","SAWH","SAVC","SUMU","SBBR","SBEG","TNCC","MMUN","MMGL","KIAH","KATL","KBOS","CYWG","LPPD","GMMN","DAAG","LPFR","LIMC","LFQQ","EGFF","ELLX","ESGG","EVRA","UKBB","LLBG","HEGN","ORBI","OBBI","OOMS","VOHS","VEPT","VGHS","ZULS","ZLLL","ZUTF","RCTP","VHHH","VTBS","WIMM","WIDD","WAHI","YPDN","YBCS","YBBN","YSSY"];async function initializeMap(e=0,t=0){$(".os-host-flexbox").overlayScrollbars({}),plane_array=[],active_uids=[],active_firs=[],active_tracons=[],tracons_array=[],layers_array=[],active_layers_pos=[],active_layers_sectors=[],layers_markers_array=[],tracmarkers_array=[],icons_array=[],firs_array=[],firmarkers_array=[],sigmets_array=[],sigmarkers_array=[],active_flight=null,layers_alt=50,await initializeIcons(),$.cookie("init")||$("#disclaimer").removeClass("d-none").addClass("d-flex"),await initializeFirData();var t=t?"active-area-landscape":"active-area";$("#map").length&&(map=L.map("map",{zoomControl:!1,preferCanvas:!0,keyboard:!1}).setView([30,0],3).setActiveArea(t),map.doubleClickZoom.disable(),basemap=L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB | SimAware on GitHub | VATGlasses Data on GitHub | Not for real-world navigation.',subdomains:"abcd"}).addTo(map),map.attributionControl.setPosition("topright"),$.cookie("mapView")&&(t=JSON.parse($.cookie("mapView")),map.setView([t.lat,t.lng],t.zoom,!0)),$.each(["controls","flights-sidebar","search-field","user-sidebar","footer-background","streamers-bar"],(e,t)=>{el=document.getElementById(t),el&&(L.DomEvent.disableClickPropagation(el),L.DomEvent.disableScrollPropagation(el))}),map.on("moveend",function(e){var t={lat:map.getCenter().lat,lng:map.getCenter().lng,zoom:map.getZoom()};$.cookie("mapView",JSON.stringify(t))}),map.on("click",function(){flightpath&&map.hasLayer(flightpath)&&returnToView(),$("#search-wrapper").hide()}),$("#search-field").click(()=>{$("#search-wrapper").show();var e=$("#search-field").val().toLowerCase();$("#search-results").html(compileSearchResults(e))})),plane_featuregroup=new L.FeatureGroup,e||map.addLayer(plane_featuregroup),atc_featuregroup=new L.FeatureGroup,atc_leg_featuregroup=new L.FeatureGroup,active_featuregroup=new L.FeatureGroup,tracons_featuregroup=new L.FeatureGroup,locals_featuregroup=new L.FeatureGroup,sigmets_featuregroup=new L.FeatureGroup,events_featuregroup=new L.FeatureGroup,nats_featuregroup=new L.FeatureGroup,wf_featuregroup=new L.FeatureGroup,fp_featuregroup=new L.FeatureGroup,layers_featuregroup=new L.FeatureGroup,atc_featuregroup.addLayer(atc_leg_featuregroup),flightpath=null}function initializeIcons(){$.each(["B739"],function(e,t){icons_array[t]=new L.divIcon({className:t,iconSize:[18,18],iconAnchor:[9,9]})})}function initializeWorldFlight(){$.each(wf,(e,t)=>{0'+t+"":""}async function initializeAirports(){airportsByIata=[],airportsByPrefix=[],airportsByApac=[];let e=await fetchRetry(dataserver+"api/livedata/airports.json");airports=await e.json(),$.each(airports,(e,t)=>{(airportsByIata[t.iata]=t).prefix&&(airportsByPrefix[t.prefix]=t),t.apac&&(airportsByApac[t.apac]=t)})}async function initializeFirData(){let e=await fetchRetry(dataserver+"api/livedata/countries.json");countries=await e.json(),e=await fetchRetry(dataserver+"api/livedata/firs.json"),firs=await e.json(),e=await fetchRetry(dataserver+"api/livedata/uirs.json"),uirs=await e.json()}function getAirline(e){if(e.callsign.match(/[A-Z]+/)&&void 0!==airlines[e.callsign.match(/[A-Z]+/)[0]])return airlines[e.callsign.match(/[A-Z]+/)[0]]}async function initializeNexrad(){response=await fetchRetry("https://tilecache.rainviewer.com/api/maps.json"),data=await response.json(),ts=data[0],nexrad=L.tileLayer("https://tilecache.rainviewer.com/v2/radar/"+ts+"/512/{z}/{x}/{y}/6/0_1.png",{tileSize:256,opacity:.4})}async function initializePatrons(){response=await fetchRetry(dataserver+"api/livedata/patrons.json"),ret=await response.json(),patrons={},$.each(ret,e=>{ret[e].cid&&(patrons[ret[e].cid]=ret[e])}),response=await fetchRetry(dataserver+"api/livedata/streamers.json"),streamers=await response.json()}async function initializeATC(){layers_positions={};let e=await fetch("/livedata/layers_positions.json");var t=await e.json();for(i in t){var a=t[i];for(j in a.prefix){var r=a.prefix[j];layers_positions[r]?layers_positions[r].push(a):layers_positions[r]=[a]}}atisdata={},layers_s={},$.ajax({url:"/livedata/layers.json",xhrFields:{withCredentials:!1},success:function(e){for(var t in layers_map=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:0,color:"#222"}}),$.each(layers_map._layers,function(e,t){e=layers_map.getLayer(e);layers_array[e.feature.properties.facility]?layers_array[e.feature.properties.facility].push(e):layers_array[e.feature.properties.facility]=[e]}),layers_array)for(var a in layers_array[t])for(var r in layers_array[t][a].feature.properties.owner)layers_s[layers_array[t][a].feature.properties.owner[r]]?layers_s[layers_array[t][a].feature.properties.owner[r]].push(t+"|"+a):layers_s[layers_array[t][a].feature.properties.owner[r]]=[t+"|"+a]}}),$.ajax({url:"/livedata/firboundaries.json",xhrFields:{withCredentials:!1},success:function(e){firmap=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:1,color:"#333"}}),$.each(firmap._layers,function(e,t){var a=firmap.getLayer(e),e=t.feature.properties.oceanic,t=t.feature.properties.id;void 0===firs_array[t+e]?firs_array[t+e]=[a]:firs_array[t+e].push(a)}),atc_leg_featuregroup.addLayer(firmap)}}),$.ajax({url:"/livedata/traconboundaries.json",xhrFields:{withCredentials:!1},success:function(e){traconmap=new L.geoJSON(e,{style:{fillColor:"#fff",fillOpacity:0,weight:.01,color:"#222"}}),$.each(traconmap._layers,function(e,t){var r=traconmap.getLayer(e),e=t.feature.properties.prefix,s=void 0===t.feature.properties.suffix||null===t.feature.properties.suffix?"APP":t.feature.properties.suffix;$.each(e,(e,t)=>{var a;null!=tracons_array[t]?tracons_array[t][s]=r:((a=[])[s]=r,tracons_array[t]=a)})}),atc_leg_featuregroup.addLayer(traconmap),atc_leg_featuregroup.addLayer(tracons_featuregroup)}})}async function refreshFlights(e=null,t=null){try{response=await fetchRetry(r2server+"api/livedata/data.json",{credentials:"omit"}),livedata=await response.json()}catch(e){return}for(var a in flights=livedata.pilots,sectors=livedata.onlinefirs,tracons=livedata.appdep,localsraw=livedata.locals,flights=applyFilter(flights,e,t),bnfoairports={},newactive_uids=[],$.each(flights,function(e,t){("undefined"!=typeof map&&void 0!==plane_array[t.uid]?updateLocation:addAircraft)(t),(t.dep||t.arr)&&(bnfoairports[t.dep]?bnfoairports[t.dep].departures++:bnfoairports[t.dep]={icao:t.dep,departures:1,arrivals:0},bnfoairports[t.arr]?bnfoairports[t.arr].arrivals++:bnfoairports[t.arr]={icao:t.arr,departures:0,arrivals:1})}),plane_array)newactive_uids.includes(a)||(plane_featuregroup.removeLayer(plane_array[a]),delete plane_array[a]);return active_flight&&(updateFlightsBox(flights[active_flight]),plane.bringToFront()),active_uids=newactive_uids,$("#navbar-pilots").html(Object.keys(plane_array).length),flights}function interpolateLoc(){for(uid in plane_array){var e=plane_array[uid].getLatLng(),t=6378.1,a=Math.PI*plane_array[uid].flight.hdg/180,r=1.852*plane_array[uid].flight.gndspd/3600*1,s=Math.PI*e.lat/180,i=Math.PI*e.lng/180,e=180*Math.asin(Math.sin(s)*Math.cos(r/t)+Math.cos(s)*Math.sin(r/t)*Math.cos(a))/Math.PI,s=180*(i+Math.atan2(Math.sin(a)*Math.sin(r/t)*Math.cos(s),Math.cos(r/t)-Math.sin(s)*Math.sin(e)))/Math.PI;plane_array[uid].setLatLng(new L.LatLng(e,s))}}function applyFilter(e,a=null,r=null){var s={};return a?($.each(e,(e,t)=>{switch(a){case"airport":t.dep!=r&&t.arr!=r||(s[t.uid]=t);case"fleet":0==t.callsign.indexOf(r)&&(s[t.uid]=t)}}),s):e}function addAircraft(e){var t=createPlaneMarker(e);plane_array[t.uid]=t,plane_featuregroup.addLayer(plane_array[t.uid]),markUID(e)}function createPlaneMarker(e){new Image;var t=getMarker(e.aircraft),t=L.canvasMarker(new L.LatLng(e.lat,e.lon),{radius:16,img:{url:"/img/aircraft/"+t[2]+".png",size:[1.2*Math.pow(t[0],.75),1.2*Math.pow(t[1],.75)],rotate:["BALL"].includes(e.aircraft)?0:e.hdg,offset:{x:0,y:0}}});return t.uid=e.uid,t.flight=e,[offset,dir]=getMarkerDirection(e),t.bindTooltip(getDatablock(e),{offset:offset,direction:dir,permanent:!1,className:"datablock"}),t.on("click",function(e){L.DomEvent.stopPropagation(e),zoomToFlight(this.uid)}),t}function getDatablock(e){return'
'+e.callsign+" "+e.aircraft+"
"+100*Math.round(Number(e.alt)/100)+" "+e.gndspd+"
"+e.dep+" "+e.arr+"
"}function updateLocation(e){try{plane_array[e.uid].setLatLng(new L.LatLng(Number(e.lat),Number(e.lon))),plane_array[e.uid].options.img.rotate=["BALL"].includes(e.aircraft)?0:e.hdg,plane_array[e.uid]._update()}catch(e){}plane_array[e.uid].setTooltipContent(getDatablock(e)),plane_array[e.uid].flight=e,"undefined"!=typeof flightpath&&map&&map.hasLayer(fp_featuregroup)&&plane.flight.uid==e.uid&&flightpath.addLatLng([e.lat,e.lon]),markUID(e)}function getMarkerDirection(e){return dir=Number(e.hdg)<180?(offset=L.point(5,12),"right"):(offset=L.point(-5,12),"left"),[offset,dir]}function markUID(e){0<=$.inArray(e,active_uids)&&active_uids.splice(active_uids.indexOf(e.uid),1),newactive_uids.push(e.uid)}function markFIR(e){0<=$.inArray(e,active_firs)&&active_firs.splice(active_firs.indexOf(e),1)}function airportSearch(e){return airportsByPrefix[e]||airports[e]||airportsByIata[e]||airportsByApac[e]||void 0}function getActiveFIRs(){let e=[];for(var t in firs_array)"#fff"==firs_array[t][0].options.color&&e.push(t);return e}function lightUpTracon(e,t){var a,r,s=tracons_array[t.split("|")[0]][t.split("|")[1]];s.setStyle({weight:1,color:"#40e0d0"}),void 0===tracmarkers_array[t]&&(a=new L.divIcon({className:"simaware-ap-tooltip",html:getTracTooltip(s.feature.properties.id,t),iconSize:"auto"}),r=getTraconMarkerLoc(s),tracmarkers_array[t]=new L.marker(r,{icon:a}),tracmarkers_array[t].bindTooltip(getTraconBlock(e,"DEP"==t.slice(-3)),{opacity:1,sticky:!0}),atc_leg_featuregroup.addLayer(tracmarkers_array[t]),s.bringToFront())}function traconSearch(e){e.replace("__","_");var t=e.slice(0,-4),a=e.slice(-3);return void 0!==tracons_array[t]&&void 0!==tracons_array[t][a]?[tracons_array[t][a],"bounds",t+"|"+a]:void 0!==tracons_array[t]&&void 0!==tracons_array[t].APP?[tracons_array[t].APP,"bounds",t+"|APP"]:void 0!==airportsByIata[t]?[airportsByIata[t],"circles",t]:void 0!==airports[t]?[airports[t],"circles",t]:(t=e.split("_")[0],void 0!==tracons_array[t]&&void 0!==tracons_array[t][a]?[tracons_array[t][a],"bounds",t+"|"+a]:void 0!==tracons_array[t]&&void 0!==tracons_array[t].APP?[tracons_array[t].APP,"bounds",t+"|APP"]:void 0!==airportsByIata[t]?[airportsByIata[t],"circles",t]:void 0!==airports[t]?[airports[t],"circles",t]:null)}function groupTracons(e){return traconsGrouped=[],traconsGrouped.bounds=[],traconsGrouped.circles=[],$.each(e,(e,t)=>{var a;(foundTracon=traconSearch(t.callsign))&&(null==traconsGrouped[foundTracon[1]][foundTracon[2]]?((a=[]).loc=foundTracon[2],a.members=[t],"circles"==foundTracon[1]?(a.airport=foundTracon[0],a.name="Unknown City"==foundTracon[0].city?foundTracon[0].name:foundTracon[0].city.split(",")[0]+" Approach"):a.name=foundTracon[0].feature.properties.name,traconsGrouped[foundTracon[1]][foundTracon[2]]=a):traconsGrouped[foundTracon[1]][foundTracon[2]].members.push(t))}),traconsGrouped}function firSearch(e){var t;t=0<=e.search("_FSS")?"FSS":"CTR";e=e.replace("__","_").replace("_CTR","").replace("_FSS","");if("FSS"==t){if(void 0!==uirs[e])return uirs[e];if(void 0!==uirs[e.split("_")[0]])return uirs[e.split("_")[0]]}return void 0!==firs[e]?firs[e]:void 0!==firs[e.split("_")[0]]?firs[e.split("_")[0]]:void 0!==uirs[e]?uirs[e]:void 0!==uirs[e.split("_")[0]]?uirs[e.split("_")[0]]:void 0}function getCallsign(e){var t;if(void 0===(t=void 0!==uirs[e]?uirs[e]:firSearch(e)))return null;if(void 0!==t.firs)return t.name;var a=getCountry(t);return a&&""!=a.radar?t.name+" "+a.radar:a&&"USA"==a.name?t.name+" Center":e.search("_FSS")?t.name+" Radio":t.name+" Centre"}function getTraconMarkerLoc(e){var t=polylabel(e.feature.geometry.coordinates[0],1),a=[];return $.each(e.getLatLngs()[0][0],(e,t)=>{a.push(t.lat)}),[Math.max(...a),t[1]]}function getCallsignByFir(e,t){if(null==t&&(t=e.icao+"0"),null==e)return"Unknown Position";if("CZUL"==e.icao)return"Centre de Montréal";if(void 0!==e.firs||0{firObj=firs_array[t],turnOffFIR(firObj)}),layers_pos={},$.each(sectors,(e,t)=>{(pos=findLayersPosition(t))&&(layers_pos[pos.id.split("/")[0]]?layers_pos[pos.id.split("/")[0]][pos.id]?(t.callsign,t.cid,t.created_at_timestamp,t.freq,t.name,t.rating,t.time_online,layers_pos[pos.id.split("/")[0]][pos.id].atc.push(t)):(layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]):(layers_pos[pos.id.split("/")[0]]={},layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]))}),$.each(tracons,(e,t)=>{(pos=findLayersPosition(t))&&(layers_pos[pos.id.split("/")[0]]?layers_pos[pos.id.split("/")[0]][pos.id]?(t.callsign,t.cid,t.created_at_timestamp,t.freq,t.name,t.rating,t.time_online,layers_pos[pos.id.split("/")[0]][pos.id].atc.push(t)):(layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]):(layers_pos[pos.id.split("/")[0]]={},layers_pos[pos.id.split("/")[0]][pos.id]=pos,layers_pos[pos.id.split("/")[0]][pos.id].atc=[t]))}),layers_sectors=findLayersSectors(layers_pos),$.each(sectors,(e,t)=>{var a=firSearch(t.callsign);if(a&&void 0===a.firs){var r=getFirIndexByCallsign(t.callsign);if(t.time_online=getTimeOnline(t),void 0===newdata[r]){let e={};e.firname=getCallsignByFir(a,r),e.members=[t],e.firicao=a.icao,e.firObj=firs_array[r],newdata[r]=e}else newdata[r].members.push(t);s++}}),$.each(sectors,(e,r)=>{var t=firSearch(r.callsign);r.time_online=getTimeOnline(r),t&&void 0!==t.firs&&(r.fssname=t.name,r.fssicao=t.prefix,$.each(t.firs,(e,t)=>{var a=getFirIndexByCallsign(t);if(void 0===newdata[a]){let e={};e.firname=getCallsignByFir(firSearch(t),a),e.members=[r],e.firicao=t,e.firObj=firs_array[a],newdata[a]=e}else newdata[a].members.push(r);s++}))}),$.each(newdata,(e,t)=>{var a,r,s;1{var a,r,s;-1==t.firname.search("Oceanic")&&(a=t.firObj,r=t.firname,s=t.firicao,lightupFIR(a,t.members,r,s,e),markFIR(e))}),$.each(active_firs,(e,t)=>{firObj=firs_array[t],turnOffFIR(firObj,t)}),"undefined"!=typeof tracons_circles_featuregroup&&tracons_featuregroup.hasLayer(tracons_circles_featuregroup)&&tracons_featuregroup.removeLayer(tracons_circles_featuregroup),tracons_circles_featuregroup=new L.FeatureGroup,traconsGrouped=groupTracons(tracons);var e=[];for(traconid in traconsGrouped.bounds){var t=traconsGrouped.bounds[traconid];0<=$.inArray(traconid,active_tracons)?(active_tracons.splice(active_tracons.indexOf(traconid),1),tracmarkers_array[traconid].setTooltipContent(getTraconBlock(t))):lightUpTracon(t,traconid),e.push(traconid)}for(traconid in $.each(active_tracons,(e,t)=>{turnOffTracon(t)}),traconsGrouped.circles){trac=traconsGrouped.circles[traconid];var a=new L.circle([trac.airport.lat,trac.airport.lon],{radius:6e4,weight:1.25,fillOpacity:0,color:"#40e0d0"});a.bindTooltip(getTraconBlock(trac),{opacity:1}),tracons_circles_featuregroup.addLayer(a)}for(id in active_tracons=e,tracons_featuregroup.addLayer(tracons_circles_featuregroup),$.each(localsraw,function(e,t){t.callsign.includes("_ATIS")||s++}),locals=[],$.each(localsraw,(e,t)=>{var a,r=t.callsign.replace("__","_").split("_"),s=r[0],r=r[r.length-1],s=airportSearch(s);(t.callsign.includes("_A_ATIS")||t.callsign.includes("_ATIS")&&!t.callsign.includes("_D_ATIS"))&&(a=getAtisRwy(t.atis)),void 0!==s&&(void 0===locals[s.icao]?(obj={},obj.loc=s,obj[r]=[t],a&&(obj.rwy=a),locals[s.icao]=obj):(void 0!==locals[s.icao][r]?locals[s.icao][r].push(t):locals[s.icao][r]=[t],a&&(locals[s.icao].rwy=a)))}),atc_featuregroup.hasLayer(locals_featuregroup)&&(atc_featuregroup.removeLayer(locals_featuregroup),locals_featuregroup=new L.FeatureGroup),locals){var r=locals[id],i=Number(r.loc.lat),o=Number(r.loc.lon),n=new L.divIcon({className:"simaware-ap-tooltip",html:getLocalTooltip(r.loc.icao),iconSize:"auto"});oloc=new L.marker([i,o],{icon:n}),oloc.bindTooltip(getLocalBlock(r.loc.icao),{opacity:1,sticky:!0}),locals_featuregroup.addLayer(oloc)}for(icao in eventsByAirport)void 0===locals[icao]&&airports[icao]&&(i=airports[icao].lat,o=airports[icao].lon,n=new L.divIcon({className:"simaware-ap-tooltip",html:getLocalTooltip(icao),iconSize:"auto"}),oloc=new L.marker([i,o],{icon:n}),oloc.bindTooltip(getLocalBlock(icao),{opacity:1,sticky:!0}),locals_featuregroup.addLayer(oloc));atc_featuregroup.addLayer(locals_featuregroup),$("#navbar-atc").html(s),showLayersView(layers_alt)}async function updateSigmet(){for(var e in response=await fetchRetry(dataserver+"api/livedata/sigmets.json"),data=await response.json(),sigmets_array)sigmets_featuregroup.removeLayer(sigmets_array[e]),sigmets_featuregroup.removeLayer(sigmarkers_array[e]);$.each(data.AIRSIGMET,(e,t)=>{if("CONVECTIVE"==t.hazard["@attributes"].type){let a=[],r=[];var s,i=getSigmetCode(t);$.each(t.area.point,(e,t)=>{a.push([Number(t.latitude),Number(t.longitude)]),r.push([Number(t.longitude),Number(t.latitude)])}),""!=i&&(sigmets_array[i]=new L.Polygon(a,{color:"#ffcc33",weight:1.5}),s=new L.divIcon({className:"simaware-ap-tooltip",html:'
'+i+"
",iconSize:"auto"}),sigmets_featuregroup.addLayer(sigmets_array[i]),sigmarkers_array[i]=new L.marker(polylabel([r],1),{icon:s}),sigmarkers_array[i].bindTooltip(getSigmetBlock(t),{opacity:.9}),sigmets_featuregroup.addLayer(sigmarkers_array[i]))}})}function getSigmetBlock(e){return list='
Convective SIGMET '+getSigmetCode(e)+'
'+nl2br(e.raw_text)+"
",list}function getSigmetCode(e){return e.raw_text.split(/\r?\n/)[2].split(" ")[2]}function lightupFIR(e,a,r,s,i){if("object"==typeof e){var t=[];for(idx in e){e[idx].setStyle({color:"#fff",weight:1,fillColor:"#fff",fillOpacity:.1}),latlng=[Number(e[idx].feature.properties.label_lat),Number(e[idx].feature.properties.label_lon)];var o=new L.divIcon({className:"simaware-ap-tooltip",html:getFirTooltip(s,i,a),iconSize:"auto"});void 0===firmarkers_array[i]?(t[idx]=new L.marker(latlng,{icon:o}),t[idx].bindTooltip(getControllerBlock(e[idx],a,r,s,i),{opacity:1,sticky:!0})):$.each(firmarkers_array[i],(e,t)=>{t.setTooltipContent(getControllerBlock(t[idx],a,r,s,i))}),e[idx].bringToFront()}if(void 0===firmarkers_array[i])for(idx in firmarkers_array[i]=t,firmarkers_array[i])atc_leg_featuregroup.addLayer(firmarkers_array[i][idx])}}function turnOffFIR(e,a){"object"==typeof e&&$.each(e,function(e,t){for(e in t.setStyle({color:"#333",weight:1,fillOpacity:0}).bringToBack(),firmarkers_array[a])atc_leg_featuregroup.removeLayer(firmarkers_array[a][e]);firmarkers_array[a]=void 0})}function turnOffTracon(e){tracons_array[e.split("|")[0]][e.split("|")[1]].setStyle({weight:0,color:"#000"}),atc_leg_featuregroup.removeLayer(tracmarkers_array[e]),tracmarkers_array[e]=void 0}function getFirIndex(e){var t=e.fir.icao+Number(e.fir.is_fss);return t=void 0===firs_array[t]?e.fir.icao+"0":t}function getFirIndexByCallsign(e){var t;t=0
'+e+"
";return r&&(e+='
'+s+"
"),e+="
"}function getTracTooltip(e,t){return'
',ct+=1),e.GND&&(i+='',ct+=1),e.TWR&&(i+='',ct+=1),e.ATIS&&(i+='',ct+=1),""!=i&&(i="
'+e+"
"}function highlightFIR(e){$.each(firs_array[e],(e,t)=>{t.setStyle({fillColor:"#fff",fillOpacity:.4})})}function dehighlightFIR(e){$.each(firs_array[e],(e,t)=>{t.setStyle({fillOpacity:.1})})}function highlightTracon(e){var t=e.split("|");for(idx in tracons_array[t[0]])idx==t[1]&&tracons_array[t[0]][t[1]].setStyle({fillColor:"#40d0e0",fillOpacity:.2})}function dehighlightTracon(e){var t=e.split("|");for(idx in tracons_array[t[0]])idx==t[1]&&tracons_array[t[0]][t[1]].setStyle({fillOpacity:0})}function highlightSigmet(e){sigmets_array[e].setStyle({fillOpacity:.4})}function dehighlightSigmet(e){sigmets_array[e].setStyle({fillOpacity:.1})}function getLocalTooltip(t){var e;locals[t]?e=locals[t]:((e=[]).loc=[],e.loc.icao=t),ct=0,i="";let a="text-white-50",r="rgba(0,0,0,0)";e.DEL&&(i+='
DGTA
"+i+"
",a="text-light",r="rgba(255,255,255,0.1)");let s="";if(eventsByAirport[t]){for(id in days_rem=999,eventsByAirport[t])s=eventsByAirport[t][id],days_rem=Math.min(moment.duration(moment(s.start).diff(moment())).asDays(),days_rem);let e="";e=days_rem<1?"background-color: "+red:days_rem<7?"border: 2px solid rgba(218,41,46,0.5);background-color: rgba(0,0,0,0.5)":"border: 2px solid rgba(218,41,46,0.25);background-color: rgba(0,0,0,0.25)",s='
'}var i="
'+s+'
'+e.loc.icao+"
"+i+"
";return i}function getLocalBlock(a){var e;void 0!==airports[a]&&(city=airports[a].city),void 0!==locals[a]?e=locals[a]:(e=[]).loc=airports[a],ct=0,tt="";var r='";if(e.DEL&&$.each(e.DEL,(e,t)=>{r+='"}),e.GND&&$.each(e.GND,(e,t)=>{r+='"}),e.TWR&&$.each(e.TWR,(e,t)=>{r+='"}),e.ATIS&&$.each(e.ATIS,(e,t)=>{r+='"}),eventslist="",eventsByAirport[a])for(id in eventslist='',eventsByAirport[a])eventslist+='";return r='
'+r+"
'+e.loc.name+'
'+city+"
DEL
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
GND
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
TWR
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
ATIS
'+getAtisCode(t.atis,a)+"
"+t.callsign+''+t.name+''+t.freq+''+getTimeOnline(t)+'
'+t.atis+"
Upcoming Events
'+moment(eventsByAirport[a][id].start).utc().format("MMM")+'
'+moment(eventsByAirport[a][id].start).utc().format("D")+'
'+eventsByAirport[a][id].name+'
'+moment(eventsByAirport[a][id].start).utc().format("HHmm")+" - "+moment(eventsByAirport[a][id].end).utc().format("HHmm")+"Z
",eventsByAirport[a]&&(r+='
'+eventslist+"
"),r+="
"}function getNatBlock(e){var a="";$.each(e.route,(e,t)=>{0!=e&&(a+=' '),a+=t.name});e='

'+e.id+'

North Atlantic Track
'+a+'
TMI '+e.tmi+"";return'
'+(e+="
")+'Data courtesy of Gander Oceanic OCA'}function getControllerBlock(e,t,a,r,s){var i='";return warnings[s]&&(i+='"),$.each(t,function(e,t){i=t.fssname?(i=i+"")+'":i+""}),i='
'+i+"
'+r+" "+a+"
'+warnings[s]+"
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+t.time_online+"
'+t.fssname+" covers "+r+" above FL245
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+t.time_online+"
"}function getTraconBlock(e,t=0){return tracon_name=e.name,list='",$.each(e.members,function(e,t){list=list+""}),list='
'+list+"
'+tracon_name+"
"+t.callsign+''+t.name+''+getControllerRating(t.rating)+''+t.freq+''+getTimeOnline(t)+"
",list}async function loadAirlines(){return response=await fetchRetry("/livedata/airlines.json"),airlines=await response.json(),airlinesByIcao={},$.each(airlines,(e,t)=>{void 0===airlinesByIcao[t.icao]?airlinesByIcao[t.icao]=[t]:airlinesByIcao[t.icao].push(t)}),airlinesByIcao}async function loadRegprefixes(){return response=await fetchRetry("/livedata/regprefixes.json"),response.json()}async function loadAircraft(){return response=await fetchRetry("/livedata/aircraft.json"),aircraft=await response.json(),aircraftByIcao={},$.each(aircraft,(e,t)=>{aircraftByIcao[t.icao]=t}),aircraftByIcao}async function initializeNat(){}async function zoomToFlight(e){$("#map").length||(window.location.href="/?uid="+e),$("#streamers-bar").is(":visible")&&$("#streamers-bar").addClass("d-none").removeClass("d-flex"),historical=void 0===plane_array[e]?1:0,"undefined"!=typeof dep_point&&(plane_featuregroup.removeLayer(dep_point),delete dep_point),"undefined"!=typeof arr_point&&(plane_featuregroup.removeLayer(arr_point),delete arr_point),"undefined"!=typeof flightpath&&(plane_featuregroup.removeLayer(flightpath),delete flightpath),plane=plane_array[e],bounds=[],bounds.push(plane.getLatLng()),active_flight=e,historical||refreshFlights(filterName,filterCriteria),$("#search-wrapper").hide(),"undefined"!=typeof ap_featuregroup&&$("#airport-sidebar").hide(),"undefined"!=typeof user_sidebar&&user_sidebar&&$("#user-sidebar").hide(),$("#events-container").hide(),[dep_airport,dep_point,dep_name,dep_city]=processAirport(plane.flight.dep),[arr_airport,arr_point,arr_name,arr_city]=processAirport(plane.flight.arr),dep_point&&arr_point&&([dep_point,arr_point]=processAirportForAntimeridian(plane.flight,airports[dep_airport],airports[arr_airport],dep_point,arr_point)),"undefined"!=typeof ap_featuregroup&&map.hasLayer(ap_featuregroup)?(dep_point&&null!=dep_point&&(ap_featuregroup.addLayer(dep_point),bounds.push(dep_point.getLatLng())),arr_point&&null!=arr_point&&(ap_featuregroup.addLayer(arr_point),bounds.push(arr_point.getLatLng()))):(dep_point&&null!=dep_point&&(plane_featuregroup.addLayer(dep_point),bounds.push(dep_point.getLatLng())),arr_point&&null!=arr_point&&(plane_featuregroup.addLayer(arr_point),bounds.push(arr_point.getLatLng()))),"undefined"!=typeof polyline_featuregroup&&map.hasLayer(polyline_featuregroup)&&map.removeLayer(polyline_featuregroup),togglePlaneTooltip(plane,!0),$("#flights-sidebar").show().addClass("d-flex"),updateFlightsBox(plane.flight),$("#sidebar").hide(),addedFlightPathPromise=addFlightPath(dataserver+"api/livedata/logs/"+e+".json",airports[dep_airport],airports[arr_airport],plane.flight),await addedFlightPathPromise,plane.bringToFront(),window.history.pushState(e,e,"/?uid="+e)}async function addFlightPath(e,t,a,r){e=await(await fetchRetry(e)).json();flightpath=await new L.Polyline(adjustLogsForAntimeridian(r,t,a,e),{smoothFactor:1,color:"#acffd6",weight:2,nowrap:!0}),fp_featuregroup.addLayer(flightpath),map.addLayer(fp_featuregroup)}function toggleStreamers(){$(".map-button#streamers").hasClass("map-button-active")?($("#streamers-bar").removeClass("d-flex").addClass("d-none"),$(".map-button#streamers").removeClass("map-button-active")):($("#streamers-bar").removeClass("d-none").addClass("d-flex"),$(".map-button#streamers").addClass("map-button-active"))}function toggleWorldflight(){map.hasLayer(wf_featuregroup)?($(".map-button#wf").removeClass("map-button-active"),map.removeLayer(wf_featuregroup)):($(".map-button#wf").addClass("map-button-active"),map.addLayer(wf_featuregroup))}function toggleLabels(){"undefined"==typeof locLabels?(locLabels=("undefined"==typeof basemap?L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19}):L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/dark_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19})).addTo(map),$(".map-button#labels").addClass("map-button-active"),$.cookie("labels","true",{expires:180})):(map.removeLayer(locLabels),delete locLabels,$(".map-button#labels").removeClass("map-button-active"),$.cookie("labels","false",{expires:180}))}function flipLabels(e){map.removeLayer(locLabels),locLabels=("dark"==e?L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/dark_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19}):L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png",{attribution:'© OpenStreetMap © CartoDB',subdomains:"abcd",maxZoom:19})).addTo(map)}function toggleBasemap(){"undefined"==typeof basemap?(map.removeLayer(lightbasemap),basemap=L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png",{attribution:"",subdomains:"abcd"}).addTo(map),$(".map-button#light").removeClass("map-button-active"),setLayerOrder(),setBasemapOrder(),lightbasemap=void 0,$.cookie("lightmap","false",{expires:180}),map.hasLayer(locLabels)&&flipLabels("dark")):(map.removeLayer(basemap),lightbasemap=L.tileLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",{attribution:""}).addTo(map),$(".map-button#light").addClass("map-button-active"),setLayerOrder(),setBasemapOrder(),basemap=void 0,$.cookie("lightmap","true"),"undefined"!=typeof locLabels&&map.hasLayer(locLabels)&&flipLabels("light"))}function togglePlaneTooltip(e,t){e.unbindTooltip(),[offset,dir]=getMarkerDirection(e.flight),e.bindTooltip(getDatablock(e.flight),{permanent:t,direction:dir,offset:offset})}function processAirport(e){var t,e=airports[e]?((t=L.circleMarker(new L.LatLng(airports[e].lat,airports[e].lon),{radius:2,stroke:!1,fillColor:"#00d300",fillOpacity:1})).bindTooltip(airports[e].iata,{permanent:!0,className:"tooltip-airport"}),[e,t,airports[e].name,airports[e].city]):[e,null,"Unknown Airport","Unknown City"];return e}function getColor(e){return e<80?"text-success":e<100?"text-warning":"text-danger"}function getFlightColor(e){1<(e=(e-15)/35)?e=1:e<0&&(e=0);var t=1-2*e;(s=-t)<0&&(s=0),t<0&&(t=0);var a=1-2*Math.abs(e-.5),r=s+t+a,s=s/r;t/=r,a/=r;var i=[255,77,77],e=[51,204,51],r=[255,179,26];return"rgb("+Math.floor(s*i[0]+t*e[0]+a*r[0])+","+Math.floor(s*i[1]+t*e[1]+a*r[1])+","+Math.floor(s*i[2]+t*e[2]+a*r[2])+")"}async function returnToView(){map.hasLayer(fp_featuregroup)&&(togglePlaneTooltip(plane,!1),manual||("undefined"!=typeof ap_featuregroup&&(map.addLayer(ap_featuregroup),$("#airport-sidebar").show()),"undefined"!=typeof user_sidebar&&user_sidebar&&$("#user-sidebar").show()),plane_featuregroup.removeLayer(dep_point),delete dep_point,plane_featuregroup.removeLayer(arr_point),delete arr_point,fp_featuregroup.removeLayer(flightpath),flightpath=null,map.removeLayer(fp_featuregroup),fp_featuregroup=new L.FeatureGroup,$("#flights-sidebar").hide().removeClass("d-flex"),$("#sidebar").show(),$("#events-container").show(),$(".map-button#streamers").hasClass("map-button-active")&&$("#streamers-bar").addClass("d-flex").removeClass("d-none"),active_flight=null),"undefined"!=typeof polyline_featuregroup&&map.addLayer(polyline_featuregroup),window.history.pushState("home","home","/")}function handleCookies(){"true"==$.cookie("atc")&&toggleATC(),"true"==$.cookie("lightmap")&&toggleBasemap(),"true"==$.cookie("sigmet")&&toggleSigmet(),"true"==$.cookie("nat")&&toggleNat(),"true"==$.cookie("wx")&&toggleNexrad(),"true"==$.cookie("labels")&&toggleLabels(),$(".map-button").removeClass("d-none"),$(".loading").addClass("d-none")}function updateFlightsBox(e){$("#flights-callsign").html(e.callsign),flight_status=getStatus(e),$(".flights-liveitem#spd").html(e.gndspd+" kt"),$(".flights-liveitem#alt").html(e.alt+" ft"),$(".flights-liveitem#togo").html(Math.round(getDtg(e))+" nm"),$("#flights-status").html(flight_status.status),$("#flights-status").css({"background-color":flight_status.color}),$("#flights-progressbar-plane").css({color:flight_status.color}),$("#flights-progressbar-elapsed").css({"background-color":flight_status.color}),flight_status.blink?$("#flights-progressbar-plane").addClass("blinking"):$("#flights-progressbar-plane").removeClass("blinking"),updateAirlines(e);var t=getTimeAirborne(e);"nodep"!=t.status?($("#flights-airborne-container").addClass("d-flex").removeClass("d-none"),hrstring=1==t.timeonline[0]?t.timeonline[0]+" hour, ":t.timeonline[0]+" hours, ",mnstring=1==t.timeonline[1]?t.timeonline[1]+" minute":t.timeonline[1]+" minutes",timestring=0==t.timeonline[0]?mnstring:hrstring+mnstring,$("#flights-timeairborne").addClass("mt-2").html("Time Airborne: "+timestring)):($("#flights-airborne-container").addClass("d-none").removeClass("d-flex"),$("#flights-timeairborne").removeClass("mt-2").html("")),[dep_airport,dep_point_,dep_name,dep_city]=processAirport(plane.flight.dep),[arr_airport,arr_point_,arr_name,arr_city]=processAirport(plane.flight.arr),$("#flights-dep-icao").html('"),$("#flights-airport-dep").html('"),$("#flights-arr-icao").html('"),$("#flights-airport-arr").html('"),$("#flights-progressbar-elapsed").css({width:getElapsedWidth(e)+"%"}),$("#flights-route").html(e.route),$("#flights-equipment").html(e.aircraft),$("#flights-name").html(''+e.name+""+getBadge(e.rating)+" "+getPatron(e.cid)),e.xpdr=padToFourDigits(e.xpdr),e.axpdr=padToFourDigits(e.axpdr),$("#flights-squawk").html(e.xpdr+" / "+e.axpdr)}function padToFourDigits(e){return e.toString().padStart(4,"0")}function updateAirlines(e){for(var t in regprefixes)if(e.callsign.match(regprefixes[t].regex))return void $("#flights-airline").html("Privately Registered ("+regprefixes[t].country+")");var r,a;3{var a=t.name;t.va&&(a+=' VA'),r.push(a)}),a=r.join("
"),1 Multiple Airlines

'+a),$("#flights-airline").html(a)):$("#flights-airline").html("")}function getPatron(e){if(!patrons[e])return"";switch(patrons[e].tier){case 1:return' Supporter';case 2:return' Streamer';case 3:return' Diamond';default:return""}}function processAirportForAntimeridian(e,t,a,r,s){return crossesAntimeridian(t,a)&&(dep_latlon=r.getLatLng(),arr_latlon=s.getLatLng(),0Number(e.lon)&&180<=getRhumbLineBearing(Number(e.lat),Number(e.lon),Number(t.lat),Number(t.lon))&&(flag=-1),flag)}function adjustLogsForAntimeridian(a,e,t,r){return newLogs=[],crossesAntimeridian(e,t)?(newLogs=[],$.each(r,function(e,t){lat=Number(t[0]),lon=Number(a.lon)<0&&0\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"
":"
")+"$2")}function getControllerRating(e){return["SP","OBS","S1","S2","S3","C1","C2","C3","I1","I2","I3","SUP","ADM"][e]}function wait(t){return new Promise(e=>setTimeout(e,t))}function fetchRetry(t,a=1e3,r=3,s={}){return fetch(t,s).catch(function(e){if(triesLeft=r-1,!triesLeft)throw e;return wait(a).then(()=>fetchRetry(t,a,triesLeft,s))})}function findLayersPosition(e){var t=e.callsign.split("_")[0];if(layers_positions[t])for(var a in layers_positions[t])if(e.freq==layers_positions[t][a].freq)return layers_positions[t][a];return null}function findLayersSectors(e){var t,a,r={},s=[];for(t in e){var i=Object.keys(e[t]);for(l in layers_array[t]){var o=!1;for(k in layers_array[t][l].feature.properties.owner)i.includes(layers_array[t][l].feature.properties.owner[k])&&!o&&(r[layers_array[t][l].feature.properties.owner[k]]?r[layers_array[t][l].feature.properties.owner[k]].push(t+"|"+l):r[layers_array[t][l].feature.properties.owner[k]]=[t+"|"+l],o=!0,s.push(t+"|"+l))}}for(a in e)for(var n in e[a])for(var l in layers_s[n])s.includes(layers_s[n][l])||(r[n]?r[n].push(layers_s[n][l]):r[n]=[layers_s[n][l]],s.push(layers_s[n][l]));return r}function returnDisplaySectors(e,t){var a,r=[];for(a in e)for(j in e[a]){var s=e[a][j].split("|"),i=layers_array[s[0]][s[1]];if((i.feature.properties.max&&i.feature.properties.max>=t||!i.feature.properties.max)&&(i.feature.properties.min&&i.feature.properties.min<=t||!i.feature.properties.min))if(i.feature.properties.rwy){var o=0;for(c in i.feature.properties.rwy){var n=i.feature.properties.rwy[c].icao;let t=i.feature.properties.rwy[c].runway;if(locals[n]&&locals[n].rwy){let e=locals[n].rwy.join("|");for(var l in t)for(var c in t[l].split("/"))e.includes(t[l].split("/")[c])&&(o=1)}}o&&r.push(e[a][j])}else r.push(e[a][j])}return r}function showLayersView(e){new_active_layers_pos=[],new_active_layers_sectors=[];var t,a,r,s=returnDisplaySectors(layers_sectors,e);for(r in layers_sectors){for(var i in ctr=[],layers_sectors[r]){var o=r.split("/"),n=layers_pos[o[0]][r],l=layers_sectors[r][i].split("|");n.atc&&s.includes(l[0]+"|"+l[1])&&(layers_featuregroup.addLayer(layers_array[l[0]][l[1]]),new_active_layers_sectors.push(l[0]+"|"+l[1]),0<=$.inArray(l[0]+"|"+l[1],active_layers_sectors)&&active_layers_sectors.splice(active_layers_sectors.indexOf(l[0]+"|"+l[1]),1),n.atc[0].callsign.includes("_CTR")||n.atc[0].callsign.includes("_FSS")?layers_array[l[0]][l[1]].setStyle({fillColor:"#aaa",fillOpacity:0,weight:1,color:"#ddd"}):layers_array[l[0]][l[1]].setStyle({fillColor:"#40e0d0",fillOpacity:0,weight:1,color:"#40e0d0"}),ctr.push(layers_array[l[0]][l[1]].feature.geometry.coordinates[0]))}ctr.length&&(t=turf.pointOnFeature(turf.multiPolygon(ctr)),0<=$.inArray(r,active_layers_pos)&&active_layers_pos.splice(active_layers_pos.indexOf(r),1),a=n.atc[0].callsign.includes("_CTR")||n.atc[0].callsign.includes("_FSS")?'
'+n.atc[0].callsign.split("_")[0]+"/"+r.split("/")[1]+"
":'
';var s=Handlebars.compile('{{#if results.length}}{{#each results}}{{/each}}{{else}}{{/if}}'),e=Handlebars.compile('{{#if trigger}}{{#if results.length}}{{#each results}}{{/each}}{{else}}{{/if}}{{else}}{{/if}}'),i=s({results:r.flights}),o=e({results:r.airports,trigger:2
Loading...
');var t=await fetchRetry("https://api.simaware.ca/api/user/"+e);user=await t.json(),$("#pilot-name").html(user.name);t=await(t=await fetchRetry("https://api.simaware.ca/api/moreflights/"+e+"/0")).json();html="",$.each(t,(e,t)=>{html+='
"}),$("#flight-list").html(html)}async function zoomToUser(e){$("#map").length&&!manual||(window.location.href="/?user="+e),"undefined"!=typeof ap_featuregroup&&returnFromAirport(),$("#user-sidebar").show(),$("#search-wrapper").hide(),user_sidebar=!0,await initializeUser(e),window.history.pushState(e,e,"/?user="+e)}$(document).ready(()=>{$("#search-field").on("input",()=>{searchAction()})}); \ No newline at end of file diff --git a/src/js/simaware_app/simaware-map.js b/src/js/simaware_app/simaware-map.js index c970f4f6..9b48557b 100644 --- a/src/js/simaware_app/simaware-map.js +++ b/src/js/simaware_app/simaware-map.js @@ -2055,8 +2055,8 @@ function toggleBasemap() { map.removeLayer(lightbasemap); basemap = L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png', { - attribution: '', - subdomains: 'abcd', + attribution: '', + subdomains: 'abcd', }).addTo(map); $('.map-button#light').removeClass('map-button-active'); setLayerOrder(); @@ -2072,7 +2072,7 @@ function toggleBasemap() { map.removeLayer(basemap); lightbasemap = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { - attribution: '' + attribution: '' }).addTo(map); $('.map-button#light').addClass('map-button-active'); setLayerOrder(); @@ -2684,7 +2684,7 @@ function getMarker(str) case 'AS55': case 'EC20': case 'EC30': - return [23, 33, 'AS50']; + return [23, 33, 'AS50']; case 'B703': return [44, 47, 'B703']; case 'B720': @@ -2891,7 +2891,6 @@ function getMarker(str) return [43, 57, 'DC86']; case 'CL60': return [33, 35, 'CL60']; - case 'F18': case 'F18': return [20, 30, 'F18']; case 'F35': @@ -2918,7 +2917,7 @@ function getMarker(str) return [21, 30, 'B407']; case 'V22': return [30, 20, 'V22']; - case 'ATP': + case 'ATP': return [31, 28, 'ATP']; case 'H160': return [29, 34, 'H160']; @@ -2938,7 +2937,7 @@ function getMarker(str) return [52, 53, 'C17']; case 'DC3': return [30, 21, 'DC3']; - case 'A400': + case 'A400': return [42, 46, 'A400']; case 'CRJ1': return [24, 30, 'CRJ1']; @@ -2972,32 +2971,34 @@ function getMarker(str) return [125, 26, 'SHIP']; case 'RFAL': return [23, 33, 'RFAL']; - case 'VULC': + case 'VULC': return [36, 33, 'VULC']; - case 'B190': + case 'B190': return [27, 28, 'B190']; - case 'C182': + case 'C182': return [26, 20, 'C182']; - case 'DHC2': + case 'DHC2': return [35, 22, 'DHC2']; - case 'DR40': + case 'DR40': return [28, 22, 'DR40']; - case 'F14': + case 'F14': return [34, 33, 'F14']; - case 'F28': + case 'F28': return [30, 34, 'F28']; - case 'J328': + case 'J328': return [31, 31, 'J328']; - case 'P212': + case 'P212': return [27, 21, 'P212']; - case 'PC6T': + case 'PC6T': return [29, 20, 'PC6T']; - case 'T134': + case 'T134': return [29, 37, 'T134']; - case 'T144': + case 'T144': return [29, 66, 'T144']; - case 'TEX2': + case 'TEX2': return [24, 23, 'TEX2']; + case 'HDJT': + return [28, 28, 'E55P']; default: return [40, 40, 'A320']; }
'+n.atc[0].callsign.split("_")[0]+"/"+r.split("/")[1]+"
",a=new L.divIcon({className:"simaware-layers-tooltip",html:a,iconSize:"auto"}),layers_markers_array[r]?(layers_markers_array[r].setLatLng([t.geometry.coordinates[1],t.geometry.coordinates[0]]),layers_markers_array[r].setTooltipContent(getLayersControllerBlock(n))):(layers_markers_array[r]=new L.marker([t.geometry.coordinates[1],t.geometry.coordinates[0]],{icon:a}),layers_markers_array[r].bindTooltip(getLayersControllerBlock(n),{opacity:1,sticky:!0}),layers_featuregroup.addLayer(layers_markers_array[r]))),new_active_layers_pos.push(r)}for(r in active_layers_sectors){l=active_layers_sectors[r].split("|");layers_featuregroup.removeLayer(layers_array[l[0]][l[1]])}for(r in active_layers_pos)layers_featuregroup.removeLayer(layers_markers_array[active_layers_pos[r]]);active_layers_pos=new_active_layers_pos,active_layers_sectors=new_active_layers_sectors,$("#layers-alt").html(100*layers_alt)}function highlightLayersObject(e){var t=layers_sectors[e];for(idx in t){var a=t[idx].split("|");layers_array[a[0]][a[1]].setStyle({fillOpacity:.4})}}function dehighlightLayersObject(e){var t=layers_sectors[e];for(idx in t){var a=t[idx].split("|");layers_array[a[0]][a[1]].setStyle({fillOpacity:0})}}function getLayersControllerBlock(e){for(var t in tracon_name=e.name,list='",e.atc)list+="";return list='
'+list+"
'+e.callsign+"
"+e.atc[t].callsign+''+e.atc[t].name+''+getControllerRating(e.atc[t].rating)+''+e.atc[t].freq+''+getTimeOnline(e.atc[t])+"
",list}var green="#13b955",blue="#009cdc",yellow="#efa31d",red="#da292e",gray="#aaaaaa";function getElapsedWidth(e){return 100*(getDfd(e)/getTotalDistance(e)-$("#flights-progressbar-plane").width()/2/$("#flights-progressbar").width())}function getInfoElapsedWidth(e){return value=getDfd(e)/getTotalDistance(e)*100-6,value<0?0:value}function getRhumbLineBearing(e,t,a,r){return dLon=deg2rad(r)-deg2rad(t),dPhi=Math.log(Math.tan(deg2rad(a)/2+Math.PI/4)/Math.tan(deg2rad(e)/2+Math.PI/4)),Math.abs(dLon)>Math.PI&&(dLon=0{var a,r;a="al"==i?(console.log(t.callsign),(null!==a&&null!==(a=t.callsign.match(/[A-Z]+/))&&a.length?a[0]:t.callsign).toLowerCase()):("dep"==i?t.dep:"arr"==i?t.arr:t.aircraft+"|"+t.arr+"|"+t.callsign+"|"+t.dep+"|"+t.cid+"|"+t.route).toLowerCase(),"al"==i||"dep"==i||"arr"==i?a==s&&(r=getStatus(t),o.flights.push({callsign:t.callsign,aircraft:t.aircraft,arr:t.arr,dep:t.dep,route:t.route,uid:t.uid,status:r})):a.includes(s)&&(r=getStatus(t),o.flights.push({callsign:t.callsign,aircraft:t.aircraft,arr:t.arr,dep:t.dep,route:t.route,uid:t.uid,status:r}))}),2{(t.icao+"|"+t.name+"|").toLowerCase().includes(s)&&o.airports.push({icao:t.icao,name:t.name,iata:t.iata,city:t.city})}),o}function compileSearchResults(e){var[t,a]=parseSearch(e),r=runSearch(a,t);if(!a.length)return'
Begin typing to search.

Helpers:
ap:Airport search
al:Airline search
flight:Callsign search
dep:Search by departure airport
arr:Search by arrival airport
Flights ({{ results.length }})

{{ this.callsign }}

{{ this.cid }} {{#if this.dep }}{{ this.dep }} - {{ this.arr }} - {{ this.aircraft }} - {{ this.status.status }}{{ else }} No flightplan {{/if}}
No results.
Airports ({{ results.length }})

{{ this.icao }} / {{ this.iata }}
{{ this.name }}

No results.
At least 3 characters required.
',void 0!==plane_array[t.uid]?html+='Live':html+=t.date,html+=''+t.callsign+"
"+t.dep+" ("+t.depicao+")
"+t.arr+" ("+t.arricao+")