2015-02-22 12:51:58 +01:00
|
|
|
// -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
2015-01-07 18:35:32 +01:00
|
|
|
"use strict";
|
|
|
|
|
2013-05-21 22:28:16 +02:00
|
|
|
// Define our global variables
|
|
|
|
var GoogleMap = null;
|
|
|
|
var Planes = {};
|
2015-01-06 21:15:25 +01:00
|
|
|
var PlanesOrdered = [];
|
2013-05-21 22:28:16 +02:00
|
|
|
var SelectedPlane = null;
|
2015-01-22 15:17:12 +01:00
|
|
|
var FollowSelected = false;
|
2013-05-18 23:54:59 +02:00
|
|
|
|
2015-01-07 17:32:58 +01:00
|
|
|
var SpecialSquawks = {
|
|
|
|
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
|
|
|
|
'7600' : { cssClass: 'squawk7600', markerColor: 'rgb(0, 255, 255)', text: 'Radio Failure' },
|
|
|
|
'7700' : { cssClass: 'squawk7700', markerColor: 'rgb(255, 255, 0)', text: 'General Emergency' }
|
2015-01-06 21:15:25 +01:00
|
|
|
};
|
2013-05-09 16:59:26 +02:00
|
|
|
|
2013-05-25 10:56:32 +02:00
|
|
|
// Get current map settings
|
2015-01-08 00:54:54 +01:00
|
|
|
var CenterLat, CenterLon, ZoomLvl;
|
2013-05-25 10:56:32 +02:00
|
|
|
|
2015-01-07 17:32:58 +01:00
|
|
|
var Dump1090Version = "unknown version";
|
|
|
|
var RefreshInterval = 1000;
|
2014-12-10 18:05:22 +01:00
|
|
|
|
2015-01-07 17:32:58 +01:00
|
|
|
var PlaneRowTemplate = null;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-07 17:32:58 +01:00
|
|
|
var TrackedAircraft = 0;
|
2015-01-07 18:35:32 +01:00
|
|
|
var TrackedAircraftPositions = 0;
|
|
|
|
var TrackedHistorySize = 0;
|
|
|
|
|
|
|
|
var SitePosition = null;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-07 19:39:19 +01:00
|
|
|
var ReceiverClock = null;
|
2015-01-07 19:43:08 +01:00
|
|
|
|
2015-02-11 01:15:48 +01:00
|
|
|
var LastReceiverTimestamp = 0;
|
2015-01-07 19:43:08 +01:00
|
|
|
var StaleReceiverCount = 0;
|
|
|
|
var FetchPending = null;
|
|
|
|
|
2015-01-13 20:10:55 +01:00
|
|
|
var MessageCountHistory = [];
|
2015-02-22 12:51:58 +01:00
|
|
|
var MessageRate = 0;
|
2015-01-13 20:10:55 +01:00
|
|
|
|
2015-01-11 13:02:25 +01:00
|
|
|
var NBSP='\u00a0';
|
|
|
|
|
2015-01-15 22:01:14 +01:00
|
|
|
function processReceiverUpdate(data) {
|
|
|
|
// Loop through all the planes in the data packet
|
|
|
|
var now = data.now;
|
|
|
|
var acs = data.aircraft;
|
|
|
|
|
|
|
|
// Detect stats reset
|
|
|
|
if (MessageCountHistory.length > 0 && MessageCountHistory[MessageCountHistory.length-1].messages > data.messages) {
|
2015-08-30 18:16:40 +02:00
|
|
|
MessageCountHistory = [{'time' : MessageCountHistory[MessageCountHistory.length-1].time,
|
|
|
|
'messages' : 0}];
|
2015-01-15 22:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note the message count in the history
|
|
|
|
MessageCountHistory.push({ 'time' : now, 'messages' : data.messages});
|
|
|
|
// .. and clean up any old values
|
|
|
|
if ((now - MessageCountHistory[0].time) > 30)
|
|
|
|
MessageCountHistory.shift();
|
|
|
|
|
|
|
|
for (var j=0; j < acs.length; j++) {
|
|
|
|
var ac = acs[j];
|
|
|
|
var hex = ac.hex;
|
|
|
|
var plane = null;
|
|
|
|
|
|
|
|
// Do we already have this plane object in Planes?
|
|
|
|
// If not make it.
|
|
|
|
|
|
|
|
if (Planes[hex]) {
|
|
|
|
plane = Planes[hex];
|
|
|
|
} else {
|
|
|
|
plane = new PlaneObject(hex);
|
|
|
|
plane.tr = PlaneRowTemplate.cloneNode(true);
|
2015-08-30 18:16:40 +02:00
|
|
|
|
2015-08-19 06:37:34 +02:00
|
|
|
// Lookup ICAO country flag
|
2015-08-30 18:19:53 +02:00
|
|
|
|
2015-08-19 06:37:34 +02:00
|
|
|
var hexa = +("0x" + hex);
|
|
|
|
|
|
|
|
for (var i = 0; i < ICAO_Codes.length; i++) {
|
|
|
|
if ( hexa >= ICAO_Codes[i].start && hexa <= ICAO_Codes[i].end) {
|
2015-08-30 18:16:40 +02:00
|
|
|
plane.Country = ICAO_Codes[i].Country;
|
|
|
|
plane.Flag = '<img src="' + flag_dir + '/' + ICAO_Codes[i].icon_fn + '" title="' + ICAO_Codes[i].Country + '\">';
|
2015-08-19 06:37:34 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-30 18:16:40 +02:00
|
|
|
// end of flag lookup
|
2015-08-22 02:38:38 +02:00
|
|
|
|
2015-01-22 14:21:47 +01:00
|
|
|
if (hex[0] === '~') {
|
|
|
|
// Non-ICAO address
|
|
|
|
plane.tr.cells[0].textContent = hex.substring(1);
|
2015-01-22 23:19:17 +01:00
|
|
|
$(plane.tr).css('font-style', 'italic');
|
2015-08-30 18:16:40 +02:00
|
|
|
plane.tr.cells[1].textContent = null;
|
|
|
|
} else {
|
|
|
|
plane.tr.cells[0].textContent = hex;
|
|
|
|
plane.tr.cells[1].innerHTML = plane.Flag;
|
2015-01-22 14:21:47 +01:00
|
|
|
}
|
|
|
|
|
2015-01-22 22:28:35 +01:00
|
|
|
plane.tr.addEventListener('click', selectPlaneByHex.bind(undefined,hex,false));
|
|
|
|
plane.tr.addEventListener('dblclick', selectPlaneByHex.bind(undefined,hex,true));
|
2015-01-15 22:01:14 +01:00
|
|
|
|
|
|
|
Planes[hex] = plane;
|
|
|
|
PlanesOrdered.push(plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the function update
|
|
|
|
plane.updateData(now, ac);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-21 22:28:16 +02:00
|
|
|
function fetchData() {
|
2015-01-07 19:43:08 +01:00
|
|
|
if (FetchPending !== null && FetchPending.state() == 'pending') {
|
|
|
|
// don't double up on fetches, let the last one resolve
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FetchPending = $.ajax({ url: 'data/aircraft.json',
|
|
|
|
timeout: 5000,
|
|
|
|
cache: false,
|
|
|
|
dataType: 'json' });
|
|
|
|
FetchPending.done(function(data) {
|
2015-01-06 00:20:03 +01:00
|
|
|
var now = data.now;
|
2015-01-13 20:10:55 +01:00
|
|
|
|
2015-01-15 22:01:14 +01:00
|
|
|
processReceiverUpdate(data);
|
2015-01-07 02:19:05 +01:00
|
|
|
|
|
|
|
// update timestamps, visibility, history track for all planes - not only those updated
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
var plane = PlanesOrdered[i];
|
2015-02-11 01:15:48 +01:00
|
|
|
plane.updateTick(now, LastReceiverTimestamp);
|
2015-01-07 02:19:05 +01:00
|
|
|
}
|
2014-12-10 18:05:22 +01:00
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
refreshTableInfo();
|
|
|
|
refreshSelected();
|
2015-01-07 19:39:19 +01:00
|
|
|
|
|
|
|
if (ReceiverClock) {
|
|
|
|
var rcv = new Date(now * 1000);
|
|
|
|
ReceiverClock.render(rcv.getUTCHours(),rcv.getUTCMinutes(),rcv.getUTCSeconds());
|
|
|
|
}
|
2015-01-07 19:43:08 +01:00
|
|
|
|
|
|
|
// Check for stale receiver data
|
|
|
|
if (LastReceiverTimestamp === now) {
|
|
|
|
StaleReceiverCount++;
|
|
|
|
if (StaleReceiverCount > 5) {
|
|
|
|
$("#update_error_detail").text("The data from dump1090 hasn't been updated in a while. Maybe dump1090 is no longer running?");
|
|
|
|
$("#update_error").css('display','block');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
StaleReceiverCount = 0;
|
|
|
|
LastReceiverTimestamp = now;
|
|
|
|
$("#update_error").css('display','none');
|
|
|
|
}
|
2013-05-21 22:28:16 +02:00
|
|
|
});
|
2015-01-07 19:43:08 +01:00
|
|
|
|
|
|
|
FetchPending.fail(function(jqxhr, status, error) {
|
|
|
|
$("#update_error_detail").text("AJAX call failed (" + status + (error ? (": " + error) : "") + "). Maybe dump1090 is no longer running?");
|
|
|
|
$("#update_error").css('display','block');
|
|
|
|
});
|
2013-05-09 16:59:26 +02:00
|
|
|
}
|
|
|
|
|
2015-01-15 22:01:14 +01:00
|
|
|
var PositionHistorySize = 0;
|
2013-05-21 22:28:16 +02:00
|
|
|
function initialize() {
|
2015-01-22 15:33:42 +01:00
|
|
|
// Set page basics
|
2015-02-22 12:51:58 +01:00
|
|
|
document.title = PageName;
|
2015-01-22 15:33:42 +01:00
|
|
|
$("#infoblock_name").text(PageName);
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
PlaneRowTemplate = document.getElementById("plane_row_template");
|
|
|
|
|
|
|
|
if (!ShowClocks) {
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#timestamps').css('display','none');
|
2015-01-07 19:39:19 +01:00
|
|
|
} else {
|
|
|
|
// Create the clocks.
|
|
|
|
new CoolClock({
|
|
|
|
canvasId: "utcclock",
|
|
|
|
skinId: "classic",
|
|
|
|
displayRadius: 40,
|
|
|
|
showSecondHand: true,
|
2015-01-11 12:54:17 +01:00
|
|
|
gmtOffset: "0", // this has to be a string!
|
2015-01-07 19:39:19 +01:00
|
|
|
showDigital: false,
|
|
|
|
logClock: false,
|
|
|
|
logClockRev: false
|
|
|
|
});
|
|
|
|
|
|
|
|
ReceiverClock = new CoolClock({
|
|
|
|
canvasId: "receiverclock",
|
|
|
|
skinId: "classic",
|
|
|
|
displayRadius: 40,
|
|
|
|
showSecondHand: true,
|
2015-01-11 12:54:17 +01:00
|
|
|
gmtOffset: null,
|
2015-01-07 19:39:19 +01:00
|
|
|
showDigital: false,
|
|
|
|
logClock: false,
|
|
|
|
logClockRev: false
|
|
|
|
});
|
|
|
|
|
|
|
|
// disable ticking on the receiver clock, we will update it ourselves
|
|
|
|
ReceiverClock.tick = (function(){})
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
2015-01-15 23:23:15 +01:00
|
|
|
|
|
|
|
$("#loader").removeClass("hidden");
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2014-12-10 18:05:22 +01:00
|
|
|
// Get receiver metadata, reconfigure using it, then continue
|
|
|
|
// with initialization
|
2015-01-17 22:02:17 +01:00
|
|
|
$.ajax({ url: 'data/receiver.json',
|
|
|
|
timeout: 5000,
|
|
|
|
cache: false,
|
|
|
|
dataType: 'json' })
|
|
|
|
|
2014-12-10 18:05:22 +01:00
|
|
|
.done(function(data) {
|
2014-12-10 22:34:05 +01:00
|
|
|
if (typeof data.lat !== "undefined") {
|
2014-12-10 18:05:22 +01:00
|
|
|
SiteShow = true;
|
2014-12-10 22:34:05 +01:00
|
|
|
SiteLat = data.lat;
|
|
|
|
SiteLon = data.lon;
|
2015-01-08 00:54:54 +01:00
|
|
|
DefaultCenterLat = data.lat;
|
|
|
|
DefaultCenterLon = data.lon;
|
2014-12-10 18:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Dump1090Version = data.version;
|
|
|
|
RefreshInterval = data.refresh;
|
2015-01-15 22:01:14 +01:00
|
|
|
PositionHistorySize = data.history;
|
|
|
|
})
|
2015-01-17 22:02:17 +01:00
|
|
|
|
2015-01-15 22:01:14 +01:00
|
|
|
.always(function() {
|
|
|
|
initialize_map();
|
|
|
|
start_load_history();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var CurrentHistoryFetch = null;
|
|
|
|
var PositionHistoryBuffer = []
|
|
|
|
function start_load_history() {
|
|
|
|
if (PositionHistorySize > 0) {
|
2015-01-15 23:23:15 +01:00
|
|
|
$("#loader_progress").attr('max',PositionHistorySize);
|
|
|
|
console.log("Starting to load history (" + PositionHistorySize + " items)");
|
2015-01-15 22:01:14 +01:00
|
|
|
load_history_item(0);
|
|
|
|
} else {
|
2015-01-25 22:54:40 +01:00
|
|
|
end_load_history();
|
2015-01-15 22:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load_history_item(i) {
|
|
|
|
if (i >= PositionHistorySize) {
|
|
|
|
end_load_history();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("Loading history #" + i);
|
2015-01-15 23:23:15 +01:00
|
|
|
$("#loader_progress").attr('value',i);
|
2015-01-15 22:01:14 +01:00
|
|
|
|
|
|
|
$.ajax({ url: 'data/history_' + i + '.json',
|
|
|
|
timeout: 5000,
|
|
|
|
cache: false,
|
|
|
|
dataType: 'json' })
|
|
|
|
|
|
|
|
.done(function(data) {
|
|
|
|
PositionHistoryBuffer.push(data);
|
|
|
|
load_history_item(i+1);
|
2014-12-10 18:05:22 +01:00
|
|
|
})
|
2015-01-15 22:01:14 +01:00
|
|
|
|
|
|
|
.fail(function(jqxhr, status, error) {
|
|
|
|
// No more history
|
|
|
|
end_load_history();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function end_load_history() {
|
|
|
|
$("#loader").addClass("hidden");
|
|
|
|
|
|
|
|
console.log("Done loading history");
|
|
|
|
|
|
|
|
if (PositionHistoryBuffer.length > 0) {
|
|
|
|
var now, last=0;
|
|
|
|
|
|
|
|
// Sort history by timestamp
|
|
|
|
console.log("Sorting history");
|
|
|
|
PositionHistoryBuffer.sort(function(x,y) { return (x.now - y.now); });
|
|
|
|
|
|
|
|
// Process history
|
|
|
|
for (var h = 0; h < PositionHistoryBuffer.length; ++h) {
|
|
|
|
now = PositionHistoryBuffer[h].now;
|
|
|
|
console.log("Applying history " + h + "/" + PositionHistoryBuffer.length + " at: " + now);
|
|
|
|
processReceiverUpdate(PositionHistoryBuffer[h]);
|
|
|
|
|
|
|
|
// update track
|
|
|
|
console.log("Updating tracks at: " + now);
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
var plane = PlanesOrdered[i];
|
|
|
|
plane.updateTrack((now - last) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
last = now;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Final pass to update all planes to their latest state
|
|
|
|
console.log("Final history cleanup pass");
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
var plane = PlanesOrdered[i];
|
|
|
|
plane.updateTick(now);
|
|
|
|
}
|
2015-02-11 01:15:48 +01:00
|
|
|
|
|
|
|
LastReceiverTimestamp = last;
|
2015-01-15 22:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PositionHistoryBuffer = null;
|
|
|
|
|
|
|
|
console.log("Completing init");
|
|
|
|
|
|
|
|
refreshTableInfo();
|
|
|
|
refreshSelected();
|
|
|
|
reaper();
|
|
|
|
|
|
|
|
// Setup our timer to poll from the server.
|
|
|
|
window.setInterval(fetchData, RefreshInterval);
|
|
|
|
window.setInterval(reaper, 60000);
|
|
|
|
|
2015-02-11 01:15:21 +01:00
|
|
|
// And kick off one refresh immediately.
|
|
|
|
fetchData();
|
|
|
|
|
2014-12-10 18:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initalizes the map and starts up our timers to call various functions
|
2015-01-15 22:01:14 +01:00
|
|
|
function initialize_map() {
|
2015-01-08 00:54:54 +01:00
|
|
|
// Load stored map settings if present
|
|
|
|
CenterLat = Number(localStorage['CenterLat']) || DefaultCenterLat;
|
|
|
|
CenterLon = Number(localStorage['CenterLon']) || DefaultCenterLon;
|
|
|
|
ZoomLvl = Number(localStorage['ZoomLvl']) || DefaultZoomLvl;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-08 00:54:54 +01:00
|
|
|
// Set SitePosition, initialize sorting
|
2015-01-06 21:15:25 +01:00
|
|
|
if (SiteShow && (typeof SiteLat !== 'undefined') && (typeof SiteLon !== 'undefined')) {
|
|
|
|
SitePosition = new google.maps.LatLng(SiteLat, SiteLon);
|
|
|
|
sortByDistance();
|
|
|
|
} else {
|
|
|
|
SitePosition = null;
|
2015-08-30 18:16:40 +02:00
|
|
|
PlaneRowTemplate.cells[6].style.display = 'none'; // hide distance column
|
2015-01-07 02:19:05 +01:00
|
|
|
document.getElementById("distance").style.display = 'none'; // hide distance header
|
2015-01-06 21:15:25 +01:00
|
|
|
sortByAltitude();
|
|
|
|
}
|
|
|
|
|
2013-05-21 22:28:16 +02:00
|
|
|
// Make a list of all the available map IDs
|
|
|
|
var mapTypeIds = [];
|
|
|
|
for(var type in google.maps.MapTypeId) {
|
|
|
|
mapTypeIds.push(google.maps.MapTypeId[type]);
|
|
|
|
}
|
|
|
|
// Push OSM on to the end
|
|
|
|
mapTypeIds.push("OSM");
|
|
|
|
mapTypeIds.push("dark_map");
|
|
|
|
|
|
|
|
// Styled Map to outline airports and highways
|
|
|
|
var styles = [
|
|
|
|
{
|
2013-05-22 05:26:40 +02:00
|
|
|
"featureType": "administrative",
|
2013-05-21 22:28:16 +02:00
|
|
|
"stylers": [
|
2013-05-22 05:26:40 +02:00
|
|
|
{ "visibility": "off" }
|
|
|
|
]
|
|
|
|
},{
|
|
|
|
"featureType": "landscape",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "off" }
|
|
|
|
]
|
|
|
|
},{
|
|
|
|
"featureType": "poi",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "off" }
|
2013-05-21 22:28:16 +02:00
|
|
|
]
|
|
|
|
},{
|
|
|
|
"featureType": "road",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "off" }
|
|
|
|
]
|
|
|
|
},{
|
|
|
|
"featureType": "transit",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "off" }
|
|
|
|
]
|
2013-05-22 05:26:40 +02:00
|
|
|
},{
|
|
|
|
"featureType": "landscape",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "on" },
|
|
|
|
{ "weight": 8 },
|
|
|
|
{ "color": "#000000" }
|
|
|
|
]
|
|
|
|
},{
|
|
|
|
"featureType": "water",
|
|
|
|
"stylers": [
|
|
|
|
{ "lightness": -74 }
|
|
|
|
]
|
2013-05-21 22:28:16 +02:00
|
|
|
},{
|
|
|
|
"featureType": "transit.station.airport",
|
|
|
|
"stylers": [
|
|
|
|
{ "visibility": "on" },
|
2013-05-22 05:26:40 +02:00
|
|
|
{ "weight": 8 },
|
2013-05-21 22:28:16 +02:00
|
|
|
{ "invert_lightness": true },
|
2013-05-22 05:26:40 +02:00
|
|
|
{ "lightness": 27 }
|
2013-05-21 22:28:16 +02:00
|
|
|
]
|
|
|
|
},{
|
2013-05-22 05:26:40 +02:00
|
|
|
"featureType": "road.highway",
|
2013-05-21 22:28:16 +02:00
|
|
|
"stylers": [
|
2013-05-22 05:26:40 +02:00
|
|
|
{ "visibility": "simplified" },
|
|
|
|
{ "invert_lightness": true },
|
|
|
|
{ "gamma": 0.3 }
|
2013-05-21 22:28:16 +02:00
|
|
|
]
|
|
|
|
},{
|
2013-05-22 05:26:40 +02:00
|
|
|
"featureType": "road",
|
|
|
|
"elementType": "labels",
|
2013-05-21 22:28:16 +02:00
|
|
|
"stylers": [
|
2013-05-22 05:26:40 +02:00
|
|
|
{ "visibility": "off" }
|
2013-05-21 22:28:16 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
// Add our styled map
|
|
|
|
var styledMap = new google.maps.StyledMapType(styles, {name: "Dark Map"});
|
|
|
|
|
|
|
|
// Define the Google Map
|
|
|
|
var mapOptions = {
|
|
|
|
center: new google.maps.LatLng(CenterLat, CenterLon),
|
|
|
|
zoom: ZoomLvl,
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
2014-08-07 04:31:05 +02:00
|
|
|
mapTypeControl: true,
|
|
|
|
streetViewControl: false,
|
2013-05-21 22:28:16 +02:00
|
|
|
mapTypeControlOptions: {
|
2014-08-07 04:31:05 +02:00
|
|
|
mapTypeIds: mapTypeIds,
|
|
|
|
position: google.maps.ControlPosition.TOP_LEFT,
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
|
2013-05-21 22:28:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
GoogleMap = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
|
|
|
|
|
|
|
//Define OSM map type pointing at the OpenStreetMap tile server
|
|
|
|
GoogleMap.mapTypes.set("OSM", new google.maps.ImageMapType({
|
|
|
|
getTileUrl: function(coord, zoom) {
|
|
|
|
return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
|
|
|
},
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
name: "OpenStreetMap",
|
|
|
|
maxZoom: 18
|
|
|
|
}));
|
|
|
|
|
|
|
|
GoogleMap.mapTypes.set("dark_map", styledMap);
|
2013-05-26 22:34:38 +02:00
|
|
|
|
2013-05-31 09:04:11 +02:00
|
|
|
// Listeners for newly created Map
|
2015-01-22 15:17:12 +01:00
|
|
|
google.maps.event.addListener(GoogleMap, 'center_changed', function() {
|
|
|
|
localStorage['CenterLat'] = GoogleMap.getCenter().lat();
|
|
|
|
localStorage['CenterLon'] = GoogleMap.getCenter().lng();
|
|
|
|
if (FollowSelected) {
|
|
|
|
// On manual navigation, disable follow
|
|
|
|
var selected = Planes[SelectedPlane];
|
|
|
|
if (Math.abs(GoogleMap.getCenter().lat() - selected.position.lat()) > 0.0001 &&
|
|
|
|
Math.abs(GoogleMap.getCenter().lng() - selected.position.lng()) > 0.0001) {
|
|
|
|
FollowSelected = false;
|
2015-01-22 22:31:02 +01:00
|
|
|
refreshSelected();
|
2015-01-22 15:17:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-05-31 09:04:11 +02:00
|
|
|
|
2015-01-22 15:17:12 +01:00
|
|
|
google.maps.event.addListener(GoogleMap, 'zoom_changed', function() {
|
|
|
|
localStorage['ZoomLvl'] = GoogleMap.getZoom();
|
|
|
|
});
|
2013-05-31 09:04:11 +02:00
|
|
|
|
2013-05-26 22:34:38 +02:00
|
|
|
// Add home marker if requested
|
2015-01-06 21:15:25 +01:00
|
|
|
if (SitePosition) {
|
2013-05-30 11:22:52 +02:00
|
|
|
var markerImage = new google.maps.MarkerImage(
|
|
|
|
'http://maps.google.com/mapfiles/kml/pal4/icon57.png',
|
2013-05-26 22:34:38 +02:00
|
|
|
new google.maps.Size(32, 32), // Image size
|
|
|
|
new google.maps.Point(0, 0), // Origin point of image
|
|
|
|
new google.maps.Point(16, 16)); // Position where marker should point
|
|
|
|
var marker = new google.maps.Marker({
|
2015-01-06 21:15:25 +01:00
|
|
|
position: SitePosition,
|
2013-05-26 22:34:38 +02:00
|
|
|
map: GoogleMap,
|
|
|
|
icon: markerImage,
|
2015-01-22 15:33:42 +01:00
|
|
|
title: SiteName,
|
2013-06-02 19:49:45 +02:00
|
|
|
zIndex: -99999
|
2013-05-30 11:22:52 +02:00
|
|
|
});
|
2015-08-30 18:16:40 +02:00
|
|
|
|
|
|
|
if (SiteCircles) {
|
2013-05-30 11:22:52 +02:00
|
|
|
for (var i=0;i<SiteCirclesDistances.length;i++) {
|
|
|
|
drawCircle(marker, SiteCirclesDistances[i]); // in meters
|
|
|
|
}
|
2015-08-30 18:16:40 +02:00
|
|
|
}
|
2013-05-26 22:34:38 +02:00
|
|
|
}
|
2013-05-09 16:59:26 +02:00
|
|
|
}
|
|
|
|
|
2013-05-21 22:28:16 +02:00
|
|
|
// This looks for planes to reap out of the master Planes variable
|
|
|
|
function reaper() {
|
2015-01-07 02:19:05 +01:00
|
|
|
//console.log("Reaping started..");
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-07 02:19:05 +01:00
|
|
|
// Look for planes where we have seen no messages for >300 seconds
|
2015-01-06 21:15:25 +01:00
|
|
|
var newPlanes = [];
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
var plane = PlanesOrdered[i];
|
2015-01-07 02:19:05 +01:00
|
|
|
if (plane.seen > 300) {
|
2015-01-06 21:15:25 +01:00
|
|
|
// Reap it.
|
2015-01-07 02:19:05 +01:00
|
|
|
//console.log("Reaping " + plane.icao);
|
|
|
|
//console.log("parent " + plane.tr.parentNode);
|
|
|
|
plane.tr.parentNode.removeChild(plane.tr);
|
|
|
|
plane.tr = null;
|
2015-01-06 21:15:25 +01:00
|
|
|
delete Planes[plane.icao];
|
2015-01-07 02:19:05 +01:00
|
|
|
plane.destroy();
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
|
|
|
// Keep it.
|
|
|
|
newPlanes.push(plane);
|
2013-05-21 22:28:16 +02:00
|
|
|
}
|
|
|
|
};
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
PlanesOrdered = newPlanes;
|
|
|
|
refreshTableInfo();
|
|
|
|
refreshSelected();
|
2015-01-07 18:18:33 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 11:42:29 +01:00
|
|
|
// Page Title update function
|
|
|
|
function refreshPageTitle() {
|
2015-02-22 12:51:58 +01:00
|
|
|
if (!PlaneCountInTitle && !MessageRateInTitle)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var subtitle = "";
|
|
|
|
|
|
|
|
if (PlaneCountInTitle) {
|
|
|
|
subtitle += TrackedAircraftPositions + '/' + TrackedAircraft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MessageRateInTitle) {
|
|
|
|
if (subtitle) subtitle += ' | ';
|
|
|
|
subtitle += MessageRate.toFixed(1) + '/s';
|
|
|
|
}
|
|
|
|
|
|
|
|
document.title = PageName + ' - ' + subtitle;
|
2015-02-20 11:42:29 +01:00
|
|
|
}
|
|
|
|
|
2013-05-21 22:28:16 +02:00
|
|
|
// Refresh the detail window about the plane
|
|
|
|
function refreshSelected() {
|
2015-02-22 12:51:58 +01:00
|
|
|
if (MessageCountHistory.length > 1) {
|
|
|
|
var message_time_delta = MessageCountHistory[MessageCountHistory.length-1].time - MessageCountHistory[0].time;
|
|
|
|
var message_count_delta = MessageCountHistory[MessageCountHistory.length-1].messages - MessageCountHistory[0].messages;
|
|
|
|
if (message_time_delta > 0)
|
|
|
|
MessageRate = message_count_delta / message_time_delta;
|
|
|
|
} else {
|
|
|
|
MessageRate = null;
|
|
|
|
}
|
|
|
|
|
2015-02-20 11:42:29 +01:00
|
|
|
refreshPageTitle();
|
|
|
|
|
2015-02-22 12:51:58 +01:00
|
|
|
var selected = false;
|
2013-05-26 14:19:38 +02:00
|
|
|
if (typeof SelectedPlane !== 'undefined' && SelectedPlane != "ICAO" && SelectedPlane != null) {
|
2015-01-06 21:15:25 +01:00
|
|
|
selected = Planes[SelectedPlane];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!selected) {
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#selected_infoblock').css('display','none');
|
|
|
|
$('#dump1090_infoblock').css('display','block');
|
2015-01-06 21:15:25 +01:00
|
|
|
$('#dump1090_version').text(Dump1090Version);
|
|
|
|
$('#dump1090_total_ac').text(TrackedAircraft);
|
|
|
|
$('#dump1090_total_ac_positions').text(TrackedAircraftPositions);
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#dump1090_total_history').text(TrackedHistorySize);
|
2015-01-13 20:10:55 +01:00
|
|
|
|
2015-02-22 12:51:58 +01:00
|
|
|
if (MessageRate !== null) {
|
|
|
|
$('#dump1090_message_rate').text(MessageRate.toFixed(1));
|
|
|
|
} else {
|
2015-01-13 20:10:55 +01:00
|
|
|
$('#dump1090_message_rate').text("n/a");
|
2015-02-22 12:51:58 +01:00
|
|
|
}
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#dump1090_infoblock').css('display','none');
|
|
|
|
$('#selected_infoblock').css('display','block');
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
if (selected.flight !== null && selected.flight !== "") {
|
|
|
|
$('#selected_callsign').text(selected.flight);
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#selected_links').css('display','inline');
|
2015-01-06 21:15:25 +01:00
|
|
|
$('#selected_fr24_link').attr('href','http://fr24.com/'+selected.flight);
|
|
|
|
$('#selected_flightstats_link').attr('href','http://www.flightstats.com/go/FlightStatus/flightStatusByFlight.do?flightNumber='+selected.flight);
|
|
|
|
$('#selected_flightaware_link').attr('href','http://flightaware.com/live/flight/'+selected.flight);
|
2013-05-28 11:15:18 +02:00
|
|
|
} else {
|
2015-01-22 18:35:20 +01:00
|
|
|
$('#selected_callsign').text('n/a');
|
2015-01-07 02:19:05 +01:00
|
|
|
$('#selected_links').css('display','none');
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
2015-02-24 22:51:30 +01:00
|
|
|
|
|
|
|
if (selected.registration !== null) {
|
|
|
|
$('#selected_registration').text(selected.registration);
|
|
|
|
} else {
|
|
|
|
$('#selected_registration').text("");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selected.icaotype !== null) {
|
|
|
|
$('#selected_icaotype').text(selected.icaotype);
|
|
|
|
} else {
|
|
|
|
$('#selected_icaotype').text("");
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
var emerg = document.getElementById('selected_emergency');
|
2015-01-07 17:32:58 +01:00
|
|
|
if (selected.squawk in SpecialSquawks) {
|
|
|
|
emerg.className = SpecialSquawks[selected.squawk].cssClass;
|
2015-01-11 13:02:25 +01:00
|
|
|
emerg.textContent = NBSP + 'Squawking: ' + SpecialSquawks[selected.squawk].text + NBSP ;
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
|
|
|
emerg.className = 'hidden';
|
|
|
|
}
|
|
|
|
|
2015-01-22 17:09:19 +01:00
|
|
|
$("#selected_altitude").text(format_altitude_long(selected.altitude, selected.vert_rate));
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
if (selected.squawk === null || selected.squawk === '0000') {
|
|
|
|
$('#selected_squawk').text('n/a');
|
|
|
|
} else {
|
|
|
|
$('#selected_squawk').text(selected.squawk);
|
2013-05-28 11:15:18 +02:00
|
|
|
}
|
2013-05-26 14:19:38 +02:00
|
|
|
|
2015-01-07 18:18:33 +01:00
|
|
|
$('#selected_speed').text(format_speed_long(selected.speed));
|
2015-01-22 16:31:35 +01:00
|
|
|
$('#selected_icao').text(selected.icao.toUpperCase());
|
2015-01-23 20:17:07 +01:00
|
|
|
$('#airframes_post_icao').attr('value',selected.icao);
|
2015-01-07 18:18:33 +01:00
|
|
|
$('#selected_track').text(format_track_long(selected.track));
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
if (selected.seen <= 1) {
|
|
|
|
$('#selected_seen').text('now');
|
|
|
|
} else {
|
2015-02-10 22:49:37 +01:00
|
|
|
$('#selected_seen').text(selected.seen.toFixed(1) + 's');
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
|
|
|
|
2015-08-30 18:19:53 +02:00
|
|
|
|
2015-08-30 18:16:40 +02:00
|
|
|
// add the country and flag
|
2015-08-20 06:00:57 +02:00
|
|
|
$('#selected_country').text(selected.Country);
|
2015-08-30 18:16:40 +02:00
|
|
|
if (selected.Flag !== null) {
|
|
|
|
$('#selected_flag').html(selected.Flag);
|
|
|
|
} else {
|
|
|
|
$('#selected_flag').text('Unrecognized');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-07 18:18:33 +01:00
|
|
|
if (selected.position === null) {
|
2015-01-06 21:15:25 +01:00
|
|
|
$('#selected_position').text('n/a');
|
2015-01-22 15:17:12 +01:00
|
|
|
$('#selected_follow').addClass('hidden');
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
2015-06-29 15:04:52 +02:00
|
|
|
var mlat_bit = (selected.position_from_mlat ? "MLAT: " : "");
|
2015-01-06 21:15:25 +01:00
|
|
|
if (selected.seen_pos > 1) {
|
2015-06-29 15:04:52 +02:00
|
|
|
$('#selected_position').text(mlat_bit + format_latlng(selected.position) + " (" + selected.seen_pos.toFixed(1) + "s)");
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
2015-06-29 15:04:52 +02:00
|
|
|
$('#selected_position').text(mlat_bit + format_latlng(selected.position));
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
2015-01-22 15:17:12 +01:00
|
|
|
$('#selected_follow').removeClass('hidden');
|
2015-01-22 22:31:02 +01:00
|
|
|
if (FollowSelected) {
|
|
|
|
$('#selected_follow').css('font-weight', 'bold');
|
2015-01-22 15:17:12 +01:00
|
|
|
GoogleMap.panTo(selected.position);
|
2015-01-22 22:31:02 +01:00
|
|
|
} else {
|
|
|
|
$('#selected_follow').css('font-weight', 'normal');
|
|
|
|
}
|
2013-05-21 22:28:16 +02:00
|
|
|
}
|
2015-01-07 18:18:33 +01:00
|
|
|
|
|
|
|
$('#selected_sitedist').text(format_distance_long(selected.sitedist));
|
2015-01-22 16:31:35 +01:00
|
|
|
$('#selected_rssi').text(selected.rssi.toFixed(1) + ' dBFS');
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-07 18:18:33 +01:00
|
|
|
// Refreshes the larger table of all the planes
|
2015-01-06 21:15:25 +01:00
|
|
|
function refreshTableInfo() {
|
|
|
|
var show_squawk_warning = false;
|
|
|
|
|
|
|
|
TrackedAircraft = 0
|
|
|
|
TrackedAircraftPositions = 0
|
2015-01-07 02:19:05 +01:00
|
|
|
TrackedHistorySize = 0
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
var tableplane = PlanesOrdered[i];
|
2015-01-07 17:32:58 +01:00
|
|
|
TrackedHistorySize += tableplane.history_size;
|
2015-01-07 02:19:05 +01:00
|
|
|
if (!tableplane.visible) {
|
|
|
|
tableplane.tr.className = "plane_table_row hidden";
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
|
|
|
TrackedAircraft++;
|
|
|
|
var classes = "plane_table_row";
|
2015-06-29 11:47:29 +02:00
|
|
|
|
2015-07-15 18:07:28 +02:00
|
|
|
if (tableplane.position !== null && tableplane.seen_pos < 60) {
|
|
|
|
++TrackedAircraftPositions;
|
|
|
|
if (tableplane.position_from_mlat)
|
|
|
|
classes += " mlat";
|
|
|
|
else
|
|
|
|
classes += " vPosition";
|
|
|
|
}
|
2015-01-06 21:15:25 +01:00
|
|
|
if (tableplane.icao == SelectedPlane)
|
2015-01-07 02:19:05 +01:00
|
|
|
classes += " selected";
|
2015-01-06 00:20:03 +01:00
|
|
|
|
2015-01-07 17:32:58 +01:00
|
|
|
if (tableplane.squawk in SpecialSquawks) {
|
|
|
|
classes = classes + " " + SpecialSquawks[tableplane.squawk].cssClass;
|
2015-01-06 21:15:25 +01:00
|
|
|
show_squawk_warning = true;
|
2015-01-07 02:19:05 +01:00
|
|
|
}
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
// ICAO doesn't change
|
2015-08-22 02:38:38 +02:00
|
|
|
tableplane.tr.cells[2].textContent = (tableplane.flight !== null ? tableplane.flight : "");
|
2015-08-30 18:16:40 +02:00
|
|
|
tableplane.tr.cells[3].textContent = (tableplane.squawk !== null ? tableplane.squawk : "");
|
2015-08-22 02:38:38 +02:00
|
|
|
tableplane.tr.cells[4].textContent = format_altitude_brief(tableplane.altitude, tableplane.vert_rate);
|
|
|
|
tableplane.tr.cells[5].textContent = format_speed_brief(tableplane.speed);
|
2015-08-30 18:16:40 +02:00
|
|
|
tableplane.tr.cells[6].textContent = format_distance_brief(tableplane.sitedist);
|
2015-08-22 02:38:38 +02:00
|
|
|
tableplane.tr.cells[7].textContent = format_track_brief(tableplane.track);
|
|
|
|
tableplane.tr.cells[8].textContent = tableplane.messages;
|
|
|
|
tableplane.tr.cells[9].textContent = tableplane.seen.toFixed(0);
|
2015-01-07 02:19:05 +01:00
|
|
|
tableplane.tr.className = classes;
|
|
|
|
|
2013-05-18 23:54:59 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
if (show_squawk_warning) {
|
2015-01-07 02:19:05 +01:00
|
|
|
$("#SpecialSquawkWarning").css('display','block');
|
2015-01-06 00:20:03 +01:00
|
|
|
} else {
|
2015-01-07 02:19:05 +01:00
|
|
|
$("#SpecialSquawkWarning").css('display','none');
|
2015-01-06 00:20:03 +01:00
|
|
|
}
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
resortTable();
|
2013-05-18 23:54:59 +02:00
|
|
|
}
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
//
|
|
|
|
// ---- table sorting ----
|
|
|
|
//
|
|
|
|
|
2015-01-07 23:16:49 +01:00
|
|
|
function compareAlpha(xa,ya) {
|
2015-01-06 21:15:25 +01:00
|
|
|
if (xa === ya)
|
2015-01-07 23:16:49 +01:00
|
|
|
return 0;
|
2015-01-06 21:15:25 +01:00
|
|
|
if (xa < ya)
|
|
|
|
return -1;
|
|
|
|
return 1;
|
|
|
|
}
|
2015-01-06 00:20:03 +01:00
|
|
|
|
2015-01-07 23:16:49 +01:00
|
|
|
function compareNumeric(xf,yf) {
|
2015-01-06 21:15:25 +01:00
|
|
|
if (Math.abs(xf - yf) < 1e-9)
|
2015-01-07 23:16:49 +01:00
|
|
|
return 0;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
return xf - yf;
|
2013-05-18 23:54:59 +02:00
|
|
|
}
|
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
function sortByICAO() { sortBy('icao', compareAlpha, function(x) { return x.icao; }); }
|
|
|
|
function sortByFlight() { sortBy('flight', compareAlpha, function(x) { return x.flight; }); }
|
|
|
|
function sortBySquawk() { sortBy('squawk', compareAlpha, function(x) { return x.squawk; }); }
|
|
|
|
function sortByAltitude() { sortBy('altitude',compareNumeric, function(x) { return (x.altitude == "ground" ? -1e9 : x.altitude); }); }
|
|
|
|
function sortBySpeed() { sortBy('speed', compareNumeric, function(x) { return x.speed; }); }
|
|
|
|
function sortByDistance() { sortBy('sitedist',compareNumeric, function(x) { return x.sitedist; }); }
|
|
|
|
function sortByTrack() { sortBy('track', compareNumeric, function(x) { return x.track; }); }
|
|
|
|
function sortByMsgs() { sortBy('msgs', compareNumeric, function(x) { return x.messages; }); }
|
|
|
|
function sortBySeen() { sortBy('seen', compareNumeric, function(x) { return x.seen; }); }
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
var sortId = '';
|
|
|
|
var sortCompare = null;
|
|
|
|
var sortExtract = null;
|
|
|
|
var sortAscending = true;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
function sortFunction(x,y) {
|
|
|
|
var xv = x._sort_value;
|
|
|
|
var yv = y._sort_value;
|
2013-05-18 23:54:59 +02:00
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
// always sort missing values at the end, regardless of
|
|
|
|
// ascending/descending sort
|
2015-01-20 00:28:04 +01:00
|
|
|
if (xv == null && yv == null) return x._sort_pos - y._sort_pos;
|
2015-01-17 13:27:13 +01:00
|
|
|
if (xv == null) return 1;
|
|
|
|
if (yv == null) return -1;
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
var c = sortAscending ? sortCompare(xv,yv) : sortCompare(yv,xv);
|
|
|
|
if (c !== 0) return c;
|
|
|
|
|
|
|
|
return x._sort_pos - y._sort_pos;
|
|
|
|
}
|
2015-01-06 21:15:25 +01:00
|
|
|
|
|
|
|
function resortTable() {
|
2015-01-07 23:16:49 +01:00
|
|
|
// number the existing rows so we can do a stable sort
|
|
|
|
// regardless of whether sort() is stable or not.
|
2015-01-17 13:27:13 +01:00
|
|
|
// Also extract the sort comparison value.
|
2015-01-06 21:15:25 +01:00
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
2015-01-07 23:16:49 +01:00
|
|
|
PlanesOrdered[i]._sort_pos = i;
|
2015-01-17 13:27:13 +01:00
|
|
|
PlanesOrdered[i]._sort_value = sortExtract(PlanesOrdered[i]);
|
2015-01-06 21:15:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
PlanesOrdered.sort(sortFunction);
|
2015-01-06 00:20:03 +01:00
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
var tbody = document.getElementById('tableinfo').tBodies[0];
|
|
|
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
|
|
|
tbody.appendChild(PlanesOrdered[i].tr);
|
|
|
|
}
|
|
|
|
}
|
2013-05-18 23:54:59 +02:00
|
|
|
|
2015-01-17 13:27:13 +01:00
|
|
|
function sortBy(id,sc,se) {
|
2015-01-06 21:15:25 +01:00
|
|
|
if (id === sortId) {
|
|
|
|
sortAscending = !sortAscending;
|
2015-01-07 23:16:49 +01:00
|
|
|
PlanesOrdered.reverse(); // this correctly flips the order of rows that compare equal
|
2015-01-06 21:15:25 +01:00
|
|
|
} else {
|
|
|
|
sortAscending = true;
|
|
|
|
}
|
2013-05-12 14:15:18 +02:00
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
sortId = id;
|
2015-01-17 13:27:13 +01:00
|
|
|
sortCompare = sc;
|
|
|
|
sortExtract = se;
|
|
|
|
|
2015-01-06 21:15:25 +01:00
|
|
|
resortTable();
|
2013-05-11 12:15:09 +02:00
|
|
|
}
|
|
|
|
|
2015-01-22 22:28:35 +01:00
|
|
|
function selectPlaneByHex(hex,autofollow) {
|
2015-01-06 21:15:25 +01:00
|
|
|
//console.log("select: " + hex);
|
2013-05-24 04:15:37 +02:00
|
|
|
// If SelectedPlane has something in it, clear out the selected
|
2013-05-22 19:09:12 +02:00
|
|
|
if (SelectedPlane != null) {
|
2015-01-07 18:32:20 +01:00
|
|
|
Planes[SelectedPlane].selected = false;
|
2015-01-07 02:19:05 +01:00
|
|
|
Planes[SelectedPlane].clearLines();
|
|
|
|
Planes[SelectedPlane].updateMarker();
|
|
|
|
$(Planes[SelectedPlane].tr).removeClass("selected");
|
2013-05-22 19:09:12 +02:00
|
|
|
}
|
2013-05-22 05:26:40 +02:00
|
|
|
|
2013-05-24 04:15:37 +02:00
|
|
|
// If we are clicking the same plane, we are deselected it.
|
2015-01-07 02:19:05 +01:00
|
|
|
if (SelectedPlane === hex) {
|
|
|
|
hex = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hex !== null) {
|
2013-05-24 04:15:37 +02:00
|
|
|
// Assign the new selected
|
|
|
|
SelectedPlane = hex;
|
2015-01-07 18:32:20 +01:00
|
|
|
Planes[SelectedPlane].selected = true;
|
2015-01-07 02:19:05 +01:00
|
|
|
Planes[SelectedPlane].updateLines();
|
|
|
|
Planes[SelectedPlane].updateMarker();
|
|
|
|
$(Planes[SelectedPlane].tr).addClass("selected");
|
2013-05-25 17:53:56 +02:00
|
|
|
} else {
|
2013-05-25 22:57:10 +02:00
|
|
|
SelectedPlane = null;
|
2013-05-24 04:15:37 +02:00
|
|
|
}
|
2015-01-06 21:15:25 +01:00
|
|
|
|
2015-01-23 00:12:41 +01:00
|
|
|
if (SelectedPlane !== null && autofollow) {
|
|
|
|
FollowSelected = true;
|
|
|
|
if (GoogleMap.getZoom() < 8)
|
|
|
|
GoogleMap.setZoom(8);
|
|
|
|
} else {
|
|
|
|
FollowSelected = false;
|
|
|
|
}
|
|
|
|
|
2015-01-22 15:17:12 +01:00
|
|
|
refreshSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleFollowSelected() {
|
|
|
|
FollowSelected = !FollowSelected;
|
2015-01-22 17:14:32 +01:00
|
|
|
if (FollowSelected && GoogleMap.getZoom() < 8)
|
|
|
|
GoogleMap.setZoom(8);
|
2015-01-23 00:12:41 +01:00
|
|
|
refreshSelected();
|
2013-05-09 16:59:26 +02:00
|
|
|
}
|
2013-05-30 19:32:36 +02:00
|
|
|
|
|
|
|
function resetMap() {
|
2015-01-08 00:54:54 +01:00
|
|
|
// Reset localStorage values and map settings
|
|
|
|
localStorage['CenterLat'] = CenterLat = DefaultCenterLat;
|
|
|
|
localStorage['CenterLon'] = CenterLon = DefaultCenterLon;
|
|
|
|
localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl;
|
|
|
|
|
|
|
|
// Set and refresh
|
|
|
|
GoogleMap.setZoom(ZoomLvl);
|
|
|
|
GoogleMap.setCenter(new google.maps.LatLng(CenterLat, CenterLon));
|
2013-05-31 09:29:51 +02:00
|
|
|
|
2015-01-22 22:35:59 +01:00
|
|
|
selectPlaneByHex(null,false);
|
2013-05-30 19:32:36 +02:00
|
|
|
}
|
|
|
|
|
2013-05-30 11:22:52 +02:00
|
|
|
function drawCircle(marker, distance) {
|
|
|
|
if (typeof distance === 'undefined') {
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(!isNaN(parseFloat(distance)) && isFinite(distance)) || distance < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
distance *= 1000.0;
|
2015-02-22 02:22:05 +01:00
|
|
|
if (!Metric) {
|
2013-05-30 11:22:52 +02:00
|
|
|
distance *= 1.852;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add circle overlay and bind to marker
|
|
|
|
var circle = new google.maps.Circle({
|
|
|
|
map: GoogleMap,
|
|
|
|
radius: distance, // In meters
|
|
|
|
fillOpacity: 0.0,
|
|
|
|
strokeWeight: 1,
|
|
|
|
strokeOpacity: 0.3
|
|
|
|
});
|
|
|
|
circle.bindTo('center', marker, 'position');
|
|
|
|
}
|