From 4f97eef908a72d12b434805a95f26a34385a512b Mon Sep 17 00:00:00 2001 From: xssfox Date: Sun, 20 Jul 2025 16:46:10 +1000 Subject: [PATCH 1/3] add in ability to filter by modulation type --- js/app.js | 8 ++++++++ js/sondehub.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index e9c522b..fc84224 100644 --- a/js/app.js +++ b/js/app.js @@ -40,6 +40,10 @@ function lhash_update(history_step) { hash += "&nyan=1"; } + if (document.getElementById("modulationfilter").value != "all"){ + hash += "&mo=" + document.getElementById("modulationfilter").value; + } + hash = encodeURI(hash); // set state if(history_supported) { @@ -132,6 +136,10 @@ function load_hash(no_refresh) { focusID = v; gotoSite(v); break; + case "mo": + document.getElementById("modulationfilter").value = v; + sidebar_update(); + break; } }); diff --git a/js/sondehub.js b/js/sondehub.js index 6a374e5..70fa2e5 100644 --- a/js/sondehub.js +++ b/js/sondehub.js @@ -666,6 +666,32 @@ function load() { L.control.periodcontrol({ position: 'topleft' }).addTo(map); + L.Control.ModulationFilter = L.Control.extend({ + onAdd: function(map) { + var div = L.DomUtil.create('div'); + + div.innerHTML = ``; + div.innerHTML.onload = setTimeValue(); + + return div; + }, + onRemove: function(map) { + // Nothing to do here + } + }) + + L.control.modulationcontrol = function(opts) { + return new L.Control.ModulationFilter(opts); + } + L.control.modulationcontrol({ position: 'topleft' }).addTo(map); + // update current position if we geolocation is available if(currentPosition) updateCurrentPosition(currentPosition.lat, currentPosition.lon); @@ -866,10 +892,29 @@ function panTo(vcallsign) { } } +function isVehicleFiltered(serial){ + if ( document.getElementById("modulationfilter") && document.getElementById("modulationfilter").value && document.getElementById("modulationfilter").value != "all"){ + if (vehicles[serial]['vehicle_type'] != 'balloon'){ + return false + } else { + if (vehicles[serial] && vehicles[serial]['curr_position'] && + vehicles[serial]['curr_position'] && + vehicles[serial]['curr_position']['data'] && + vehicles[serial]['curr_position']['data']['modulation'] && + vehicles[serial]['curr_position']['data']['modulation'].startsWith(document.getElementById("modulationfilter").value)) { + return false + } else { + return true + } + } + } + return false; +} + function sidebar_update() { if (offline.get('opt_selective_sidebar')) { for (let serial in vehicles) { - if (map.getBounds().contains(vehicles[serial].marker.getLatLng())) { + if (map.getBounds().contains(vehicles[serial].marker.getLatLng()) && !isVehicleFiltered(serial)) { $("#main .vehicle"+vehicles[serial].uuid).show(); } else { if (!($("#main .vehicle"+vehicles[serial].uuid).hasClass("follow"))) { @@ -879,7 +924,11 @@ function sidebar_update() { } } else { for (let serial in vehicles) { - $("#main .vehicle"+vehicles[serial].uuid).show(); + if (!isVehicleFiltered(serial)){ + $("#main .vehicle"+vehicles[serial].uuid).show(); + } else { + $("#main .vehicle"+vehicles[serial].uuid).hide(); + } } } } @@ -1460,7 +1509,6 @@ function updateVehicleInfo(vcallsign, newPosition) { } var receiver_list_sorted = Object.keys(vehicle.receiver_info).sort(); - console.log(receiver_list_sorted); for(var receiver_idx in receiver_list_sorted){ var receiver = receiver_list_sorted[receiver_idx]; @@ -1630,6 +1678,8 @@ function updateVehicleInfo(vcallsign, newPosition) { // mark vehicles as redrawn vehicle.updated = false; + sidebar_update() + return true; } From 76b2c6630943a1550f296a64586c70f9c035f263 Mon Sep 17 00:00:00 2001 From: xssfox Date: Sun, 20 Jul 2025 19:37:08 +1000 Subject: [PATCH 2/3] order list, add ttn, wenet --- js/sondehub.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/sondehub.js b/js/sondehub.js index 70fa2e5..e3e91c3 100644 --- a/js/sondehub.js +++ b/js/sondehub.js @@ -672,11 +672,13 @@ function load() { div.innerHTML = ``; div.innerHTML.onload = setTimeValue(); From deddf65a4f11a960962f6c9f4a89e0edbcb985b3 Mon Sep 17 00:00:00 2001 From: xssfox Date: Sun, 20 Jul 2025 19:48:49 +1000 Subject: [PATCH 3/3] use includes --- js/sondehub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/sondehub.js b/js/sondehub.js index e3e91c3..d33c491 100644 --- a/js/sondehub.js +++ b/js/sondehub.js @@ -903,7 +903,7 @@ function isVehicleFiltered(serial){ vehicles[serial]['curr_position'] && vehicles[serial]['curr_position']['data'] && vehicles[serial]['curr_position']['data']['modulation'] && - vehicles[serial]['curr_position']['data']['modulation'].startsWith(document.getElementById("modulationfilter").value)) { + vehicles[serial]['curr_position']['data']['modulation'].includes(document.getElementById("modulationfilter").value)) { return false } else { return true