Skip to content

Commit 4f97eef

Browse files
committed
add in ability to filter by modulation type
1 parent f8f11c7 commit 4f97eef

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

js/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function lhash_update(history_step) {
4040
hash += "&nyan=1";
4141
}
4242

43+
if (document.getElementById("modulationfilter").value != "all"){
44+
hash += "&mo=" + document.getElementById("modulationfilter").value;
45+
}
46+
4347
hash = encodeURI(hash);
4448
// set state
4549
if(history_supported) {
@@ -132,6 +136,10 @@ function load_hash(no_refresh) {
132136
focusID = v;
133137
gotoSite(v);
134138
break;
139+
case "mo":
140+
document.getElementById("modulationfilter").value = v;
141+
sidebar_update();
142+
break;
135143
}
136144
});
137145

js/sondehub.js

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,32 @@ function load() {
666666

667667
L.control.periodcontrol({ position: 'topleft' }).addTo(map);
668668

669+
L.Control.ModulationFilter = L.Control.extend({
670+
onAdd: function(map) {
671+
var div = L.DomUtil.create('div');
672+
673+
div.innerHTML = `<select name="modulationfilter" id="modulationfilter" style="width:auto !important;height:30px;" onchange="sidebar_update(this.value);lhash_update();">
674+
<option value="all">All</option>
675+
<option value="Horus Binary">Horus Binary</option>
676+
<option value="APRS">APRS</option>
677+
<option value="WSPR">WSPR</option>
678+
<option value="LoRa">LoRa</option>
679+
<option value="RTTY">RTTY</option>
680+
</select>`;
681+
div.innerHTML.onload = setTimeValue();
682+
683+
return div;
684+
},
685+
onRemove: function(map) {
686+
// Nothing to do here
687+
}
688+
})
689+
690+
L.control.modulationcontrol = function(opts) {
691+
return new L.Control.ModulationFilter(opts);
692+
}
693+
L.control.modulationcontrol({ position: 'topleft' }).addTo(map);
694+
669695
// update current position if we geolocation is available
670696
if(currentPosition) updateCurrentPosition(currentPosition.lat, currentPosition.lon);
671697

@@ -866,10 +892,29 @@ function panTo(vcallsign) {
866892
}
867893
}
868894

895+
function isVehicleFiltered(serial){
896+
if ( document.getElementById("modulationfilter") && document.getElementById("modulationfilter").value && document.getElementById("modulationfilter").value != "all"){
897+
if (vehicles[serial]['vehicle_type'] != 'balloon'){
898+
return false
899+
} else {
900+
if (vehicles[serial] && vehicles[serial]['curr_position'] &&
901+
vehicles[serial]['curr_position'] &&
902+
vehicles[serial]['curr_position']['data'] &&
903+
vehicles[serial]['curr_position']['data']['modulation'] &&
904+
vehicles[serial]['curr_position']['data']['modulation'].startsWith(document.getElementById("modulationfilter").value)) {
905+
return false
906+
} else {
907+
return true
908+
}
909+
}
910+
}
911+
return false;
912+
}
913+
869914
function sidebar_update() {
870915
if (offline.get('opt_selective_sidebar')) {
871916
for (let serial in vehicles) {
872-
if (map.getBounds().contains(vehicles[serial].marker.getLatLng())) {
917+
if (map.getBounds().contains(vehicles[serial].marker.getLatLng()) && !isVehicleFiltered(serial)) {
873918
$("#main .vehicle"+vehicles[serial].uuid).show();
874919
} else {
875920
if (!($("#main .vehicle"+vehicles[serial].uuid).hasClass("follow"))) {
@@ -879,7 +924,11 @@ function sidebar_update() {
879924
}
880925
} else {
881926
for (let serial in vehicles) {
882-
$("#main .vehicle"+vehicles[serial].uuid).show();
927+
if (!isVehicleFiltered(serial)){
928+
$("#main .vehicle"+vehicles[serial].uuid).show();
929+
} else {
930+
$("#main .vehicle"+vehicles[serial].uuid).hide();
931+
}
883932
}
884933
}
885934
}
@@ -1460,7 +1509,6 @@ function updateVehicleInfo(vcallsign, newPosition) {
14601509
}
14611510

14621511
var receiver_list_sorted = Object.keys(vehicle.receiver_info).sort();
1463-
console.log(receiver_list_sorted);
14641512

14651513
for(var receiver_idx in receiver_list_sorted){
14661514
var receiver = receiver_list_sorted[receiver_idx];
@@ -1630,6 +1678,8 @@ function updateVehicleInfo(vcallsign, newPosition) {
16301678
// mark vehicles as redrawn
16311679
vehicle.updated = false;
16321680

1681+
sidebar_update()
1682+
16331683
return true;
16341684
}
16351685

0 commit comments

Comments
 (0)