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..a6bcd66 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 += 'hex | Flight | Squawk | Altitude | ';
- html += 'Speed | Track | ';
- html += 'Msgs | Seen | ';
- for (var p in Planes) {
- var specialStyle = "";
- if (p == Selected) {
- html += '';
- } else {
- html += '
';
- }
- if (Planes[p].validposition) {
- specialStyle = 'bold';
- }
- html += '' + Planes[p].hex + ' | ';
- html += '' + Planes[p].flight + ' | ';
- html += '' + Planes[p].squawk + ' | ';
- html += '' + Planes[p].altitude + ' | ';
- html += '' + Planes[p].speed + ' | ';
- html += '' + Planes[p].track + ' | ';
- html += '' + Planes[p].messages + ' | ';
- html += '' + Planes[p].seen + ' | ';
- html += '
';
- }
- html += '
';
-
- document.getElementById('tabinfo').innerHTML = html;
+ var html = '';
+ html += '';
+ html += 'hex | ';
+ html += 'Flight | ';
+ html += 'Squawk | ';
+ html += 'Altitude | ';
+ html += 'Speed | ';
+ html += 'Track | ';
+ html += 'Msgs | ';
+ html += 'Seen | ';
+ for (var p in Planes) {
+ var specialStyle = "";
+ if (p == Selected) {
+ html += '';
+ } else {
+ html += '
';
+ }
+ if (Planes[p].validposition) {
+ specialStyle = 'bold';
+ }
+ html += '' + Planes[p].hex + ' | ';
+ html += '' + Planes[p].flight + ' | ';
+ html += '' + Planes[p].squawk + ' | ';
+ html += '' + Planes[p].altitude + ' | ';
+ html += '' + Planes[p].speed + ' | ';
+ html += '' + Planes[p].track + ' | ';
+ html += '' + Planes[p].messages + ' | ';
+ html += '' + Planes[p].seen + ' | ';
+ html += '
';
+ }
+ html += '
';
- // 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