diff --git a/public_html/script.js b/public_html/script.js index ed2a4dc..150179c 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -267,6 +267,7 @@ function refreshSelected() { } else if (selected && selected.squawk == 7700) { // General Emergency html += '  Squawking: General Emergency '; } else if (selected && selected.flight != '') { + html += ' [FR24]'; html += ' [FlightStats]'; } @@ -330,12 +331,12 @@ function refreshSelected() { dist /= 1852; } dist = (Math.round((dist)*10)/10).toFixed(1); - html += 'Distance from Site: ' + dist + + html += 'Distance from Site: ' + dist + (Metric ? ' km' : ' NM') + ''; } // End of SiteShow } else { if (SiteShow) { - html += 'Distance from Site: n/a ' + + html += 'Distance from Site: n/a ' + (Metric ? ' km' : ' NM') + ''; } else { html += 'n/a'; @@ -403,11 +404,16 @@ function refreshTableInfo() { 'align="right">Altitude'; html += 'Speed'; - html += 'Distance'; + } + html += 'Track'; - html += 'Msgs'; - html += 'Seen'; for (var tablep in Planes) { var tableplane = Planes[tablep] @@ -451,6 +457,25 @@ function refreshTableInfo() { html += '' + tableplane.altitude + ''; html += '' + tableplane.speed + ''; } + // Add distance column to table if site coordinates are provided + if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) { + html += ''; + if (tableplane.vPosition) { + var siteLatLon = new google.maps.LatLng(SiteLat, SiteLon); + var planeLatLon = new google.maps.LatLng(tableplane.latitude, tableplane.longitude); + var dist = google.maps.geometry.spherical.computeDistanceBetween (siteLatLon, planeLatLon); + if (Metric) { + dist /= 1000; + } else { + dist /= 1852; + } + dist = (Math.round((dist)*10)/10).toFixed(1); + html += dist; + } else { + html += '0'; + } + html += ''; + } html += ''; if (tableplane.vTrack) { @@ -503,6 +528,8 @@ function sortTable(szTableID,iCol) { if (typeof iCol==='undefined'){ if(iSortCol!=-1){ var iCol=iSortCol; + } else if (SiteShow && (typeof SiteLat !== 'undefined' || typeof SiteLon !== 'undefined')) { + var iCol=5; } else { var iCol=iDefaultSortCol; }