From a8768bfd51920482cd471e2806830e0ebd49b760 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sat, 17 Jul 2021 13:31:46 +0200 Subject: [PATCH] start work on filter stuff, make table more consistent for aircraft that are timing out --- html/early.js | 32 ++++++++++++++++++++++++++++++++ html/index.html | 2 +- html/planeObject.js | 2 +- html/script.js | 28 +++++++++++++++++++++------- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/html/early.js b/html/early.js index e68b067..af498b1 100644 --- a/html/early.js +++ b/html/early.js @@ -660,3 +660,35 @@ if (!Object.entries) { return resArray; }; } + +const filters = {}; + +function Filter(arg) { + this.key = arg.key; + this.name = arg.name || arg.key; + + this.id = 'filters_' + this.key; + + filters[this.key] = this; + + this.init(); +} + +Filter.prototype.reset = function() { + jQuery('#' + this.id).val(""); + jQuery('#' + this.id).blur(); + this.update(); +} + +Filter.prototype.init = function() { + jQuery(this.container).append(( + '
' + + '
Filter by '+ this.name +':
' + + '' + + '' + + '' + + '
' + )); + jQuery('#' + this.id).on('submit', this.update); + jQuery('#' + this.id).on('reset', this.reset); +} diff --git a/html/index.html b/html/index.html index 229369f..48fd4ed 100644 --- a/html/index.html +++ b/html/index.html @@ -842,7 +842,7 @@
- +
diff --git a/html/planeObject.js b/html/planeObject.js index 77df50a..d81d22f 100644 --- a/html/planeObject.js +++ b/html/planeObject.js @@ -2399,7 +2399,7 @@ PlaneObject.prototype.cross180 = function(on_ground, is_leg) { }; PlaneObject.prototype.dataChanged = function() { - this.refreshTR = true; + this.refreshTR = 0; } PlaneObject.prototype.isNonIcao = function() { diff --git a/html/script.js b/html/script.js index 98f8c63..4e3d9f2 100644 --- a/html/script.js +++ b/html/script.js @@ -1217,6 +1217,18 @@ function initFlagFilter(colors) { }); } +function initFilters() { + new Filter({ + key: 'callsign', + name: 'Callsign', + container: "#filterTable", + }); + + initSourceFilter(tableColors.unselected); + initFlagFilter(tableColors.unselected); +} + + function push_history() { jQuery("#loader_progress").attr('max',nHistoryItems*2); for (let i = 0; i < nHistoryItems; i++) { @@ -2023,14 +2035,16 @@ function initMap() { if (loadFinished) { TAR.planeMan.redraw(); refreshFilter(); + initLegend(tableColors.unselected); + initSourceFilter(tableColors.unselected); + initFlagFilter(tableColors.unselected); } - - initLegend(tableColors.unselected); - initSourceFilter(tableColors.unselected); - initFlagFilter(tableColors.unselected); } }); + initLegend(tableColors.unselected); + + initFilters(); new Toggle({ key: "MapDim", @@ -3113,11 +3127,11 @@ function refreshFeatures() { if (plane.tr == null) { plane.makeTR(planeRowTemplate.cloneNode(true)); plane.tr.id = plane.icao; - plane.refreshTR = true; + plane.refreshTR = 0; } - if (plane.refreshTR || plane.selected != plane.selectCache) { - plane.refreshTR = false; + if (now - plane.refreshTR > 5 || plane.selected != plane.selectCache) { + plane.refreshTR = now; let colors = tableColors.unselected; let bgColor = "#F8F8F8"