Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to filter by data source #91

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,17 @@
<button class="formButton" type="submit">Filter</button>
<button class="formButton" id="icao_filter_reset_button">Reset</button>
</form>

<form id="source_filter_form">
<div class="infoBlockTitleText">Filter by source:</div>
<ol id="sourceFilter"></ol>
<button class="formButton" type="submit">Filter</button>
<button class="formButton" id="source_filter_reset_button">Reset</button>
<br />
<br />
<br />
<br />
</form>
</div>
<div id="tab-columns">
<div id="settingsLeft" class="settingsColumn">
Expand Down
4 changes: 4 additions & 0 deletions html/planeObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ PlaneObject.prototype.isFiltered = function() {
if (!filterTracks && altFiltered(this.altitude))
return true;

if (PlaneFilter.sources && PlaneFilter.sources.length > 0 && !PlaneFilter.sources.includes(this.dataSource)) {
return true;
}

if (PlaneFilter.icao && !this.icao.match(PlaneFilter.icao) ) {
return true;
}
Expand Down
88 changes: 73 additions & 15 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ let debugCounter = 0;
let selectedPhotoCache = null;
let pathName = null;
let icaoFilter = null;
let sourcesFilter = null;
let sources = ['adsb', 'uat', 'mlat', 'tisb', 'unknown'];
let showTrace = false;
let showTraceExit = false;
let showTraceWasIsolation = false;
Expand Down Expand Up @@ -736,6 +738,7 @@ function initPage() {
$("#type_filter_form").submit(updateTypeFilter);
$("#description_filter_form").submit(updateDescriptionFilter);
$("#icao_filter_form").submit(updateIcaoFilter);
$("#source_filter_form").submit(updateSourceFilter);

$("#search_form").submit(onSearch);
$("#jump_form").submit(onJump);
Expand All @@ -752,6 +755,7 @@ function initPage() {
$("#type_filter_reset_button").click(onResetTypeFilter);
$("#description_filter_reset_button").click(onResetDescriptionFilter);
$("#icao_filter_reset_button").click(onResetIcaoFilter);
$("#source_filter_reset_button").click(onResetSourceFilter);

$('#settingsCog').on('click', function() {
$('#settings_infoblock').toggle();
Expand Down Expand Up @@ -927,22 +931,9 @@ function initPage() {
if (loadFinished) {
refreshFilter();
}
let legend = document.getElementById('legend');
let colors = tableColors.unselected;
let html = '';
html += '<div class="legendTitle" style="background-color:' + colors['adsb'] + ';">ADS-B</div>';
if (!globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['uat'] + ';">UAT / ADS-R</div>';
if (globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['uat'] + ';">ADS-C/R / UAT</div>';
html += '<div class="legendTitle" style="background-color:' + colors['mlat'] + ';">MLAT</div>';
html += '<div class="legendTitle" style="background-color:' + colors['tisb'] + ';">TIS-B</div>';
if (!globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['other'] + ';">Mode-S</div>';
if (globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['unknown'] + ';">Unknown</div>';

legend.innerHTML = html;
initLegend(tableColors.unselected);
initSourceFilter(tableColors.unselected);
}
});

Expand Down Expand Up @@ -997,6 +988,55 @@ function initPage() {
}
}

function initLegend(colors) {
let html = '';
html += '<div class="legendTitle" style="background-color:' + colors['adsb'] + ';">ADS-B</div>';
if (!globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['uat'] + ';">UAT / ADS-R</div>';
if (globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['uat'] + ';">ADS-C/R / UAT</div>';
html += '<div class="legendTitle" style="background-color:' + colors['mlat'] + ';">MLAT</div>';
html += '<div class="legendTitle" style="background-color:' + colors['tisb'] + ';">TIS-B</div>';
if (!globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['other'] + ';">Mode-S</div>';
if (globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['unknown'] + ';">Unknown</div>';

document.getElementById('legend').innerHTML = html;
}

function initSourceFilter(colors) {
const createFilter = function (color, text) {
return '<li class="ui-widget-content" style="background-color:' + color + ';">' + text + '</li>';
};

let html = '';
html += createFilter(colors['adsb'], 'ADS-B');

if (!globeIndex)
html += createFilter(colors['uat'], 'UAT / ADS-R');
if (globeIndex)
html += createFilter(colors['uat'], 'ADS-C/R / UAT');
html += createFilter(colors['mlat'], 'MLAT');
html += createFilter(colors['tisb'], 'TIS-B');
if (!globeIndex)
html += createFilter(colors['other'], 'Mode-S');
if (globeIndex)
html += createFilter(colors['unknown'], 'Unknown');

document.getElementById('sourceFilter').innerHTML = html;

$("#sourceFilter").selectable({
stop: function () {
sourcesFilter = [];
$(".ui-selected", this).each(function () {
const index = $("#sourceFilter li").index(this);
sourcesFilter.push(sources[index]);
});
}
});
}

function push_history() {
$("#loader_progress").attr('max',nHistoryItems*2);
for (let i = 0; i < nHistoryItems; i++) {
Expand Down Expand Up @@ -3506,6 +3546,24 @@ function getFlightAwareIdentLink(ident, linkText) {
return "";
}

function onResetSourceFilter(e) {
$('#sourceFilter .ui-selected').removeClass('ui-selected');

sourcesFilter = null;

updateSourceFilter();
}

function updateSourceFilter(e) {
if (e)
e.preventDefault();

PlaneFilter.sources = sourcesFilter;

refreshFilter();
}


function getFlightAwareModeSLink(code, ident, linkText) {
if (code !== null && code.length > 0 && code[0] !== '~' && code !== "000000") {
if (!linkText) {
Expand Down
26 changes: 26 additions & 0 deletions html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,29 @@ table.infoTable tr td {
.ui-tabs .ui-tabs-panel {
padding: 1em 0.5em;
}

#sourceFilter .ui-selected {
border-color: orange;
}

#sourceFilter .ui-selectee {
border-width: 2px;
}

#sourceFilter {
list-style-type: none;
margin: 0;
padding: 0;
width: calc( 240px * var(--SCALE));
}

#sourceFilter li {
margin-right: 5px;
margin-bottom: 5px;
padding: 1px;
float: left;
width: calc( 85px * var(--SCALE));
color: #000000;
font-size: var(--FS2);
text-align: center;
}