Add filtering on data source
This commit is contained in:
parent
e2b2ce3f63
commit
c466a4724f
|
|
@ -116,12 +116,24 @@ PlaneObject.prototype.isFiltered = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// aircraft ident filter
|
||||||
if (this.filter.aircraftIdent) {
|
if (this.filter.aircraftIdent) {
|
||||||
if (this.flight === null || (typeof this.flight === 'string' && this.flight.toUpperCase().trim() !== this.filter.aircraftIdent.toUpperCase())) {
|
if (this.flight === null || (typeof this.flight === 'string' && this.flight.toUpperCase().trim() !== this.filter.aircraftIdent.toUpperCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dataSource = this.getDataSource();
|
||||||
|
if (dataSource === 'adsb_icao') {
|
||||||
|
if (!this.filter.ADSB) return true;
|
||||||
|
} else if (dataSource === 'mlat') {
|
||||||
|
if (!this.filter.MLAT) return true;
|
||||||
|
} else if (dataSource === 'tisb_trackfile' || dataSource === 'tisb_icao' || dataSource === 'tisb_other') {
|
||||||
|
if (!this.filter.TISB) return true;
|
||||||
|
} else {
|
||||||
|
if (!this.filter.Other) return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.filter.minAltitude !== undefined && this.filter.maxAltitude !== undefined) {
|
if (this.filter.minAltitude !== undefined && this.filter.maxAltitude !== undefined) {
|
||||||
if (this.altitude === null || this.altitude === undefined) {
|
if (this.altitude === null || this.altitude === undefined) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -379,18 +379,22 @@ function initialize() {
|
||||||
|
|
||||||
$('#adsb_datasource_checkbox').on('click', function() {
|
$('#adsb_datasource_checkbox').on('click', function() {
|
||||||
toggleADSBAircraft(true);
|
toggleADSBAircraft(true);
|
||||||
|
refreshDataSourceFilters();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#mlat_datasource_checkbox').on('click', function() {
|
$('#mlat_datasource_checkbox').on('click', function() {
|
||||||
toggleMLATAircraft(true);
|
toggleMLATAircraft(true);
|
||||||
|
refreshDataSourceFilters();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#other_datasource_checkbox').on('click', function() {
|
$('#other_datasource_checkbox').on('click', function() {
|
||||||
toggleOtherAircraft(true);
|
toggleOtherAircraft(true);
|
||||||
|
refreshDataSourceFilters();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#tisb_datasource_checkbox').on('click', function() {
|
$('#tisb_datasource_checkbox').on('click', function() {
|
||||||
toggleTISBAircraft(true);
|
toggleTISBAircraft(true);
|
||||||
|
refreshDataSourceFilters();
|
||||||
})
|
})
|
||||||
|
|
||||||
// Event handlers for to column checkboxes
|
// Event handlers for to column checkboxes
|
||||||
|
|
@ -417,6 +421,7 @@ function initialize() {
|
||||||
toggleMLATAircraft(false);
|
toggleMLATAircraft(false);
|
||||||
toggleOtherAircraft(false);
|
toggleOtherAircraft(false);
|
||||||
toggleTISBAircraft(false);
|
toggleTISBAircraft(false);
|
||||||
|
refreshDataSourceFilters();
|
||||||
|
|
||||||
// Get receiver metadata, reconfigure using it, then continue
|
// Get receiver metadata, reconfigure using it, then continue
|
||||||
// with initialization
|
// with initialization
|
||||||
|
|
@ -2121,7 +2126,7 @@ function updatePlaneFilter() {
|
||||||
|
|
||||||
var aircraftTypeCode = $("#aircraft_type_filter").val().trim()
|
var aircraftTypeCode = $("#aircraft_type_filter").val().trim()
|
||||||
if (aircraftTypeCode === "") {
|
if (aircraftTypeCode === "") {
|
||||||
aircraftTypeCode = undefined
|
aircraftTypeCode = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
var aircraftIdent = $("#aircraft_ident_filter").val().trim()
|
var aircraftIdent = $("#aircraft_ident_filter").val().trim()
|
||||||
|
|
@ -2133,6 +2138,13 @@ function updatePlaneFilter() {
|
||||||
PlaneFilter.aircraftIdent = aircraftIdent;
|
PlaneFilter.aircraftIdent = aircraftIdent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshDataSourceFilters () {
|
||||||
|
PlaneFilter.ADSB = (localStorage.getItem('sourceADSBFilter') === 'selected') ? true : false;
|
||||||
|
PlaneFilter.MLAT = (localStorage.getItem('sourceMLATFilter') === 'selected') ? true : false;
|
||||||
|
PlaneFilter.Other = (localStorage.getItem('sourceOtherFilter') === 'selected') ? true : false;
|
||||||
|
PlaneFilter.TISB = (localStorage.getItem('sourceTISBFilter') === 'selected') ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
function getFlightAwareIdentLink(ident, linkText) {
|
function getFlightAwareIdentLink(ident, linkText) {
|
||||||
if (ident !== null && ident !== "") {
|
if (ident !== null && ident !== "") {
|
||||||
if (!linkText) {
|
if (!linkText) {
|
||||||
|
|
@ -2426,14 +2438,14 @@ function toggleAllColumns(switchToggle) {
|
||||||
|
|
||||||
function toggleADSBAircraft(switchFilter) {
|
function toggleADSBAircraft(switchFilter) {
|
||||||
if (typeof localStorage['sourceADSBFilter'] === 'undefined') {
|
if (typeof localStorage['sourceADSBFilter'] === 'undefined') {
|
||||||
localStorage.setItem('sourceADSBFilter','not_filtered');
|
localStorage.setItem('sourceADSBFilter','deselected');
|
||||||
}
|
}
|
||||||
|
|
||||||
var sourceADSBFilter = localStorage.getItem('sourceADSBFilter');
|
var sourceADSBFilter = localStorage.getItem('sourceADSBFilter');
|
||||||
if (switchFilter === true) {
|
if (switchFilter === true) {
|
||||||
sourceADSBFilter = (sourceADSBFilter === 'not_filtered') ? 'filtered' : 'not_filtered';
|
sourceADSBFilter = (sourceADSBFilter === 'deselected') ? 'selected' : 'deselected';
|
||||||
}
|
}
|
||||||
if (sourceADSBFilter === 'not_filtered') {
|
if (sourceADSBFilter === 'deselected') {
|
||||||
$('#adsb_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
$('#adsb_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
||||||
} else {
|
} else {
|
||||||
$('#adsb_datasource_checkbox').addClass('sourceCheckboxChecked');
|
$('#adsb_datasource_checkbox').addClass('sourceCheckboxChecked');
|
||||||
|
|
@ -2443,14 +2455,14 @@ function toggleADSBAircraft(switchFilter) {
|
||||||
|
|
||||||
function toggleMLATAircraft(switchFilter) {
|
function toggleMLATAircraft(switchFilter) {
|
||||||
if (typeof localStorage['sourceMLATFilter'] === 'undefined') {
|
if (typeof localStorage['sourceMLATFilter'] === 'undefined') {
|
||||||
localStorage.setItem('sourceMLATFilter','not_filtered');
|
localStorage.setItem('sourceMLATFilter','deselected');
|
||||||
}
|
}
|
||||||
|
|
||||||
var sourceMLATFilter = localStorage.getItem('sourceMLATFilter');
|
var sourceMLATFilter = localStorage.getItem('sourceMLATFilter');
|
||||||
if (switchFilter === true) {
|
if (switchFilter === true) {
|
||||||
sourceMLATFilter = (sourceMLATFilter === 'not_filtered') ? 'filtered' : 'not_filtered';
|
sourceMLATFilter = (sourceMLATFilter === 'deselected') ? 'selected' : 'deselected';
|
||||||
}
|
}
|
||||||
if (sourceMLATFilter === 'not_filtered') {
|
if (sourceMLATFilter === 'deselected') {
|
||||||
$('#mlat_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
$('#mlat_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
||||||
} else {
|
} else {
|
||||||
$('#mlat_datasource_checkbox').addClass('sourceCheckboxChecked');
|
$('#mlat_datasource_checkbox').addClass('sourceCheckboxChecked');
|
||||||
|
|
@ -2460,14 +2472,14 @@ function toggleMLATAircraft(switchFilter) {
|
||||||
|
|
||||||
function toggleOtherAircraft(switchFilter) {
|
function toggleOtherAircraft(switchFilter) {
|
||||||
if (typeof localStorage['sourceOtherFilter'] === 'undefined') {
|
if (typeof localStorage['sourceOtherFilter'] === 'undefined') {
|
||||||
localStorage.setItem('sourceOtherFilter','not_filtered');
|
localStorage.setItem('sourceOtherFilter','deselected');
|
||||||
}
|
}
|
||||||
|
|
||||||
var sourceOtherFilter = localStorage.getItem('sourceOtherFilter');
|
var sourceOtherFilter = localStorage.getItem('sourceOtherFilter');
|
||||||
if (switchFilter === true) {
|
if (switchFilter === true) {
|
||||||
sourceOtherFilter = (sourceOtherFilter === 'not_filtered') ? 'filtered' : 'not_filtered';
|
sourceOtherFilter = (sourceOtherFilter === 'deselected') ? 'selected' : 'deselected';
|
||||||
}
|
}
|
||||||
if (sourceOtherFilter === 'not_filtered') {
|
if (sourceOtherFilter === 'deselected') {
|
||||||
$('#other_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
$('#other_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
||||||
} else {
|
} else {
|
||||||
$('#other_datasource_checkbox').addClass('sourceCheckboxChecked');
|
$('#other_datasource_checkbox').addClass('sourceCheckboxChecked');
|
||||||
|
|
@ -2477,14 +2489,14 @@ function toggleOtherAircraft(switchFilter) {
|
||||||
|
|
||||||
function toggleTISBAircraft(switchFilter) {
|
function toggleTISBAircraft(switchFilter) {
|
||||||
if (typeof localStorage['sourceTISBFilter'] === 'undefined') {
|
if (typeof localStorage['sourceTISBFilter'] === 'undefined') {
|
||||||
localStorage.setItem('sourceTISBFilter','not_filtered');
|
localStorage.setItem('sourceTISBFilter','deselected');
|
||||||
}
|
}
|
||||||
|
|
||||||
var sourceTISBFilter = localStorage.getItem('sourceTISBFilter');
|
var sourceTISBFilter = localStorage.getItem('sourceTISBFilter');
|
||||||
if (switchFilter === true) {
|
if (switchFilter === true) {
|
||||||
sourceTISBFilter = (sourceTISBFilter === 'not_filtered') ? 'filtered' : 'not_filtered';
|
sourceTISBFilter = (sourceTISBFilter === 'deselected') ? 'selected' : 'deselected';
|
||||||
}
|
}
|
||||||
if (sourceTISBFilter === 'not_filtered') {
|
if (sourceTISBFilter === 'deselected') {
|
||||||
$('#tisb_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
$('#tisb_datasource_checkbox').removeClass('sourceCheckboxChecked');
|
||||||
} else {
|
} else {
|
||||||
$('#tisb_datasource_checkbox').addClass('sourceCheckboxChecked');
|
$('#tisb_datasource_checkbox').addClass('sourceCheckboxChecked');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue