Show mode A/C data in aircraft table

This commit is contained in:
Carlos Salaverria 2016-09-07 14:20:42 -05:00
parent 15c66a379a
commit 5b4ad4d8d9

View file

@ -8,6 +8,7 @@ var SiteCircleFeatures = new ol.Collection();
var PlaneIconFeatures = new ol.Collection(); var PlaneIconFeatures = new ol.Collection();
var PlaneTrailFeatures = new ol.Collection(); var PlaneTrailFeatures = new ol.Collection();
var Planes = {}; var Planes = {};
var PlanesModeAc = {};
var PlanesOrdered = []; var PlanesOrdered = [];
var PlaneFilter = {}; var PlaneFilter = {};
var SelectedPlane = null; var SelectedPlane = null;
@ -65,13 +66,16 @@ function processReceiverUpdate(data) {
for (var j=0; j < acs.length; j++) { for (var j=0; j < acs.length; j++) {
var ac = acs[j]; var ac = acs[j];
var hex = ac.hex; var hex = ac.hex;
var squawk = ac.squawk;
var plane = null; var plane = null;
// Do we already have this plane object in Planes? // Do we already have this plane object in Planes?
// If not make it. // If not make it.
if (Planes[hex]) { if (hex !== "000000" && Planes[hex]) {
plane = Planes[hex]; plane = Planes[hex];
} else if (hex === "000000" && PlanesModeAc[squawk]) {
plane = PlanesModeAc[squawk];
} else { } else {
plane = new PlaneObject(hex); plane = new PlaneObject(hex);
plane.filter = PlaneFilter; plane.filter = PlaneFilter;
@ -93,6 +97,7 @@ function processReceiverUpdate(data) {
$('img', plane.tr.cells[1]).css('display', 'none'); $('img', plane.tr.cells[1]).css('display', 'none');
} }
if (hex !== "000000") {
plane.tr.addEventListener('click', function(h, evt) { plane.tr.addEventListener('click', function(h, evt) {
if (evt.srcElement instanceof HTMLAnchorElement) { if (evt.srcElement instanceof HTMLAnchorElement) {
evt.stopPropagation(); evt.stopPropagation();
@ -117,6 +122,9 @@ function processReceiverUpdate(data) {
}.bind(undefined, hex)); }.bind(undefined, hex));
Planes[hex] = plane; Planes[hex] = plane;
} else {
PlanesModeAc[squawk] = plane;
}
PlanesOrdered.push(plane); PlanesOrdered.push(plane);
} }
@ -665,11 +673,13 @@ function reaper() {
var plane = PlanesOrdered[i]; var plane = PlanesOrdered[i];
if (plane.seen > 300) { if (plane.seen > 300) {
// Reap it. // Reap it.
//console.log("Reaping " + plane.icao);
//console.log("parent " + plane.tr.parentNode);
plane.tr.parentNode.removeChild(plane.tr); plane.tr.parentNode.removeChild(plane.tr);
plane.tr = null; plane.tr = null;
if (plane.icao === "000000") {
delete PlanesModeAc[plane.squawk];
} else {
delete Planes[plane.icao]; delete Planes[plane.icao];
}
plane.destroy(); plane.destroy();
} else { } else {
// Keep it. // Keep it.
@ -1336,7 +1346,7 @@ function getFlightAwareIdentLink(ident, linkText) {
} }
function getFlightAwareModeSLink(code, linkText) { function getFlightAwareModeSLink(code, linkText) {
if (code !== null && code.length > 0 && code[0] !== '~') { if (code !== null && code.length > 0 && code[0] !== '~' && code !== "000000") {
if (!linkText) { if (!linkText) {
linkText = "FlightAware: " + code.toUpperCase(); linkText = "FlightAware: " + code.toUpperCase();
} }
@ -1355,7 +1365,7 @@ function getFlightAwarePhotoLink(registration) {
} }
function getAirframesModeSLink(code) { function getAirframesModeSLink(code) {
if (code !== null && code.length > 0 && code[0] !== '~') { if (code !== null && code.length > 0 && code[0] !== '~' && code !== "000000") {
return "<a href=\"http://www.airframes.org/\" onclick=\"$('#airframes_post_icao').attr('value','" + code + "'); document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;\">Airframes.org: " + code.toUpperCase() + "</a>"; return "<a href=\"http://www.airframes.org/\" onclick=\"$('#airframes_post_icao').attr('value','" + code + "'); document.getElementById('horrible_hack').submit.call(document.getElementById('airframes_post')); return false;\">Airframes.org: " + code.toUpperCase() + "</a>";
} }