diff --git a/public_html/script.js b/public_html/script.js index ed2a4dc..48df77c 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -403,11 +403,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 +456,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 +527,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; }