diff --git a/public_html/gmap.html b/public_html/gmap.html index b26217b..78bfd77 100644 --- a/public_html/gmap.html +++ b/public_html/gmap.html @@ -16,7 +16,7 @@

Dump1090 - 00:00:00 UTC

Click on a plane for info.

-

+
diff --git a/public_html/script.js b/public_html/script.js index e78d9b2..50df145 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -1,11 +1,16 @@ -Map = null; -CenterLat = 45.0; -CenterLon = 9.0; -ZoomLvl = 5; -Planes = {}; -PlanesOnMap = 0; -PlanesOnGrid = 0; -Selected = null; +var Map = null; +var CenterLat = 45.0; +var CenterLon = 9.0; +var ZoomLvl = 5; +var Planes = {}; +var PlanesOnMap = 0; +var PlanesOnGrid = 0; +var Selected = null; + +var iSortCol=-1; +var bSortASC=true; +var bDefaultSortASC=true; +var iDefaultSortCol=3; if (localStorage['CenterLat']) { CenterLat = Number(localStorage['CenterLat']); } if (localStorage['CenterLon']) { CenterLon = Number(localStorage['CenterLon']); } @@ -75,8 +80,8 @@ function selectPlane(selectedPlane) { function refreshGeneralInfo() { var i = document.getElementById('geninfo'); - i.innerHTML = PlanesOnMap + ' planes on map.
'; - i.innerHTML += PlanesOnGrid + ' planes on grid.'; + i.innerHTML = PlanesOnMap + ' planes on the map. '; + i.innerHTML += PlanesOnGrid + ' planes on the grid.'; } function refreshSelectedInfo() { @@ -119,40 +124,104 @@ function refreshSelectedInfo() { } function refreshTableInfo() { - var html = ''; - html += ''; - html += ''; - html += ''; - html += ''; - for (var p in Planes) { - var specialStyle = ""; - if (p == Selected) { - html += ''; - } else { - html += ''; - } - if (Planes[p].validposition) { - specialStyle = 'bold'; - } - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - } - html += '
hexFlightSquawkAltitudeSpeedTrackMsgsSeen
' + Planes[p].hex + '' + Planes[p].flight + '' + Planes[p].squawk + '' + Planes[p].altitude + '' + Planes[p].speed + '' + Planes[p].track + '' + Planes[p].messages + '' + Planes[p].seen + '
'; - - document.getElementById('tabinfo').innerHTML = html; + var html = ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + for (var p in Planes) { + var specialStyle = ""; + if (p == Selected) { + html += ''; + } else { + html += ''; + } + if (Planes[p].validposition) { + specialStyle = 'bold'; + } + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + } + html += '
hexFlightSquawkAltitudeSpeedTrackMsgsSeen
' + Planes[p].hex + '' + Planes[p].flight + '' + Planes[p].squawk + '' + Planes[p].altitude + '' + Planes[p].speed + '' + Planes[p].track + '' + Planes[p].messages + '' + Planes[p].seen + '
'; - // Click event for table - lags sometimes for some reason? - $('#tableinfo').find('tr').click( function(){ - var hex = $(this).find('td:first').text(); - selectPlane(hex); - }); + document.getElementById('tabinfo').innerHTML = html; + + // Click event for table - lags sometimes for some reason? + $('#tableinfo').find('tr').click( function(){ + var hex = $(this).find('td:first').text(); + selectPlane(hex); + }); + + sortTable("tableinfo"); +} + +// Credit goes to a co-worker that needed a similar functions for something else +// we get a copy of it free ;) +function setASC_DESC(iCol) { + if(iSortCol==iCol) { + bSortASC=!bSortASC; + } else { + bSortASC=bDefaultSortASC; + } +} + +function sortTable(szTableID,iCol) { + //if iCol was not provided, and iSortCol is not set, assign default value + if (typeof iCol==='undefined'){ + if(iSortCol!=-1){ + var iCol=iSortCol; + } else { + var iCol=iDefaultSortCol; + } + } + + //retrieve passed table element + var oTbl=document.getElementById(szTableID).tBodies[0]; + var aStore=[]; + + //If supplied col # is greater than the actual number of cols, set sel col = to last col + if (oTbl.rows[0].cells.length<=iCol) + iCol=(oTbl.rows[0].cells.length-1); + + //store the col # + iSortCol=iCol; + + //determine if we are delaing with numerical, or alphanumeric content + bNumeric=!isNaN(parseFloat(oTbl.rows[0].cells[iSortCol].textContent||oTbl.rows[0].cells[iSortCol].innerText))?true:false; + + //loop through the rows, storing each one inro aStore + for (var i=0,iLen=oTbl.rows.length;i