diff --git a/README-query.md b/README-query.md
index aaddeb4..6223e5c 100644
--- a/README-query.md
+++ b/README-query.md
@@ -14,6 +14,15 @@
- noIsolation - show other planes and not only the ones selected by ?icao
- icaoFilter=hex1,hex2,hex3 - Only show the mentioned hex ids, no other aircraft will ever be displayed
- reg=registration - Direct link to specific aircraft registration(s). Separate multiple with commas. ?icao is preferred as this option takes longer to load.
+- filterAltMin=500 - filter minimum altitute to 500ft
+- filterAltMax=5000 - filter maximum altitute to 5000ft
+- filterCallSign=^(UAL|DAL) - filter callsign to United or Deleta
+- filterType=B738 - filter to aircraft type B738 aka 737-800
+- filterDescription=L2J - filter aircraft by description
+- filterIcao=^a - filter icao that start with a
+- filterSources=adsb,uat,adsr,mlat,tisb,modeS - filter palnes by source type.
+- filterDbFlag=military,pia,ladd - filter planes by the db flags.
+
## Troubleshooting
diff --git a/html/early.js b/html/early.js
index cb2dacb..5f6ece1 100644
--- a/html/early.js
+++ b/html/early.js
@@ -61,6 +61,14 @@ try {
if (isNaN(val)) return null;
return val;
},
+ getInt: function(s) {
+ if (!this.params.has(s.toLowerCase())) return null;
+ const param = this.params.get(s.toLowerCase());
+ if (!param) return null;
+ const val = parseInt(param, 10);
+ if (isNaN(val)) return null;
+ return val;
+ }
};
const inputParams = new URLSearchParams(window.location.search);
for (const [k, v] of inputParams) {
diff --git a/html/script.js b/html/script.js
index 8e21058..0e23550 100644
--- a/html/script.js
+++ b/html/script.js
@@ -696,6 +696,47 @@ function initPage() {
replay = replayDefaults(ts);
}
+ //Pulling filters from params
+ if (usp.has('filterAltMin')) {
+ const minAlt = usp.getInt('filterAltMin');
+ if (minAlt !== null) {
+ PlaneFilter.minAltitude = minAlt;
+ PlaneFilter.enabled = true;
+ PlaneFilter.maxAltitude = 1000000;
+ }
+ }
+ if (usp.has('filterAltMax')) {
+ const maxAlt = usp.getInt('filterAltMax');
+ if (maxAlt !== null) {
+ PlaneFilter.maxAltitude = maxAlt;
+ PlaneFilter.enabled = true;
+ if (PlaneFilter.minAltitude === undefined) {
+ PlaneFilter.minAltitude = -1000000;
+ }
+ }
+ }
+
+ if (usp.has('filterCallSign')) {
+ PlaneFilter.callsign = usp.get('filterCallSign');
+ }
+ if (usp.has('filterType')) {
+ PlaneFilter.type = usp.get('filterType');
+ }
+ if (usp.has('filterDescription')) {
+ PlaneFilter.description = usp.get('filterDescription');
+ }
+ if (usp.has('filterIcao')) {
+ PlaneFilter.icao = usp.get('filterIcao');
+ }
+
+ if (usp.has('filterSources')) {
+ PlaneFilter.sources = usp.get('filterSources').split(',');
+ }
+ if (usp.has('filterDbFlag')) {
+ PlaneFilter.flagFilter = usp.get('filterDbFlag').split(',');
+ }
+
+
if (onMobile)
enableMouseover = false;
@@ -918,6 +959,16 @@ function initPage() {
jQuery('#t20x').on('click', function() { replaySpeedChange(20); });
jQuery('#t40x').on('click', function() { replaySpeedChange(40); });
+ new Toggle({
+ key: "shareFilters",
+ display: "Include Filters In Share Link",
+ container: "#settingsLeft",
+ init: false,
+ setState: function(state) {
+ updateAddressBar();
+ }
+ });
+
new Toggle({
key: "debugTracks",
display: "Debug Tracks",
@@ -1161,24 +1212,24 @@ function initLegend(colors) {
}
function initSourceFilter(colors) {
- const createFilter = function (color, text) {
- return '
' + text + '';
+ const createFilter = function (color, text, key) {
+ return '' + text + '';
};
let html = '';
- html += createFilter(colors['adsb'], 'ADS-B');
+ html += createFilter(colors['adsb'], 'ADS-B', sources[0]);
- html += createFilter(colors['uat'], 'UAT / ADS-R');
- html += createFilter(colors['mlat'], 'MLAT');
- html += createFilter(colors['tisb'], 'TIS-B');
+ html += createFilter(colors['uat'], 'UAT / ADS-R', sources[1][0]);
+ html += createFilter(colors['mlat'], 'MLAT', sources[2]);
+ html += createFilter(colors['tisb'], 'TIS-B', sources[3]);
//if (!globeIndex)
- html += createFilter(colors['modeS'], 'Mode-S');
+ html += createFilter(colors['modeS'], 'Mode-S', sources[4]);
if (globeIndex)
- html += createFilter(colors['other'], 'Other');
+ html += createFilter(colors['other'], 'Other', sources[5]);
if (globeIndex)
- html += createFilter(colors['uat'], 'ADS-C');
+ html += createFilter(colors['uat'], 'ADS-C', sources[6]);
document.getElementById('sourceFilter').innerHTML = html;
@@ -1201,15 +1252,15 @@ function initSourceFilter(colors) {
}
function initFlagFilter(colors) {
- const createFilter = function (color, text) {
- return '' + text + '';
+ const createFilter = function (color, text, key) {
+ return '' + text + '';
};
let html = '';
- html += createFilter(colors['tisb'], 'Military');
+ html += createFilter(colors['tisb'], 'Military', flagFilterValues[0]);
//html += createFilter(colors['mlat'], 'Interesting');
- html += createFilter(colors['uat'], 'PIA');
- html += createFilter(colors['adsb'], 'LADD');
+ html += createFilter(colors['uat'], 'PIA', flagFilterValues[1]);
+ html += createFilter(colors['adsb'], 'LADD', flagFilterValues[2]);
document.getElementById('flagFilter').innerHTML = html;
@@ -1240,6 +1291,38 @@ function initFilters() {
initSourceFilter(tableColors.unselected);
initFlagFilter(tableColors.unselected);
+
+ if (PlaneFilter) {
+ if (PlaneFilter.minAltitude && PlaneFilter.minAltitude > -1000000) {
+ jQuery('#altitude_filter_min').val(PlaneFilter.minAltitude);
+ }
+ if (PlaneFilter.maxAltitude && PlaneFilter.maxAltitude < 1000000) {
+ jQuery('#altitude_filter_max').val(PlaneFilter.maxAltitude);
+ }
+
+ if (PlaneFilter.callsign) {
+ jQuery('#callsign_filter').val(PlaneFilter.callsign);
+ }
+ if (PlaneFilter.type) {
+ jQuery('#type_filter').val(PlaneFilter.type);
+ }
+ if (PlaneFilter.description) {
+ jQuery('#description_filter').val(PlaneFilter.description);
+ }
+ if (PlaneFilter.icao) {
+ jQuery('#icao_filter').val(PlaneFilter.icao);
+ }
+
+ if (PlaneFilter.sources) {
+ sourcesFilter = PlaneFilter.sources
+ sourcesFilter.map((f) => jQuery('#source-filter-' + f).addClass('ui-selected'))
+ }
+
+ if (PlaneFilter.flagFilter) {
+ flagFilter = PlaneFilter.flagFilter
+ flagFilter.map((f) => jQuery('#flag-filter-' + f).addClass('ui-selected'))
+ }
+ }
}
@@ -2644,6 +2727,12 @@ function refreshSelected() {
}
jQuery('#selected_icao').html(hex_html);
}
+ if (globeIndex || shareBaseUrl) {
+ const shareElement = jQuery('a.identSmall');
+ if (shareElement.prop('href') !== shareLink) {
+ shareElement.prop('href',shareLink);
+ }
+ }
jQuery('#selected_pf_info').updateText((selected.pfRoute ? selected.pfRoute : "") );
//+" "+ (selected.pfFlightno ? selected.pfFlightno : "")
jQuery('#airframes_post_icao').attr('value',selected.icao);
@@ -3792,6 +3881,9 @@ function refreshFilter() {
mapRefresh(true);
drawHeatmap();
+ if (toggles.shareFilters && toggles.shareFilters.state) {
+ updateAddressBar()
+ }
}
function filterGroundVehicles(switchFilter) {
@@ -4230,6 +4322,12 @@ function updateAltFilter() {
else
enabled = true;
+ if (!enabled) {
+ PlaneFilter.enabled = false;
+ PlaneFilter.minAltitude = undefined;
+ PlaneFilter.maxAltitude = undefined;
+ }
+
PlaneFilter.enabled = enabled;
if (DisplayUnits == "metric") {
@@ -5089,7 +5187,7 @@ let updateAddressBarPushed = false;
function updateAddressBar() {
if (!window.history || !window.history.replaceState)
return;
- if (heatmap || pTracks)
+ if (heatmap || pTracks || !CenterLat)
return;
let time = new Date().getTime();
if (time < lastAddressBarUpdate + 200) {
@@ -5147,7 +5245,50 @@ function updateAddressBar() {
}
}
- shareLink = (shareBaseUrl ? shareBaseUrl : pathName) + string;
+ let shareFilter = '';
+ if (toggles.shareFilters && toggles.shareFilters.state) {
+ let filterStrings = [];
+ if (string === '') {
+ shareFilter = '?';
+ } else {
+ shareFilter = '&'
+ }
+
+ if (PlaneFilter.minAltitude > -1000000) {
+ filterStrings.push('filterAltMin=' + PlaneFilter.minAltitude);
+ }
+ if (PlaneFilter.maxAltitude < 1000000) {
+ filterStrings.push('filterAltMax=' + PlaneFilter.maxAltitude);
+ }
+ if (PlaneFilter.callsign) {
+ filterStrings.push('filterCallSign=' + encodeURIComponent(PlaneFilter.callsign));
+ }
+ if (PlaneFilter.type) {
+ filterStrings.push('filterType=' + encodeURIComponent(PlaneFilter.type));
+ }
+ if (PlaneFilter.description) {
+ filterStrings.push('filterDescription=' + encodeURIComponent(PlaneFilter.description));
+ }
+ if (PlaneFilter.icao) {
+ filterStrings.push('filterIcao=' + encodeURIComponent(PlaneFilter.icao));
+ }
+
+ if (PlaneFilter.sources) {
+ filterStrings.push('filterSources=' + PlaneFilter.sources.map(f => encodeURIComponent(f)).join(','));
+ }
+ if (PlaneFilter.flagFilter) {
+ filterStrings.push('filterDbFlag=' + PlaneFilter.flagFilter.map(f => encodeURIComponent(f)).join(','));
+ }
+
+ if (filterStrings.length > 0) {
+ shareFilter = shareFilter + filterStrings.join('&');
+ } else {
+ shareFilter = '';
+ }
+ }
+
+ shareLink = (shareBaseUrl ? shareBaseUrl : pathName) + string + shareFilter;
+
if (uuid)