Skip to content
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
8 changes: 8 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -132,6 +136,10 @@ function load_hash(no_refresh) {
focusID = v;
gotoSite(v);
break;
case "mo":
document.getElementById("modulationfilter").value = v;
sidebar_update();
break;
}
});

Expand Down
58 changes: 55 additions & 3 deletions js/sondehub.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,34 @@ 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 = `<select name="modulationfilter" id="modulationfilter" style="width:auto !important;height:30px;" onchange="sidebar_update(this.value);lhash_update();">
<option value="all">All</option>
<option value="APRS">APRS</option>
<option value="Horus Binary">Horus Binary</option>
<option value="LoRa">LoRa</option>
<option value="RTTY">RTTY</option>
<option value="TTN">TTN</option>
<option value="Wenet">Wenet</option>
<option value="WSPR">WSPR</option>
</select>`;
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);

Expand Down Expand Up @@ -866,10 +894,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'].includes(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"))) {
Expand All @@ -879,7 +926,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();
}
}
}
}
Expand Down Expand Up @@ -1460,7 +1511,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];
Expand Down Expand Up @@ -1630,6 +1680,8 @@ function updateVehicleInfo(vcallsign, newPosition) {
// mark vehicles as redrawn
vehicle.updated = false;

sidebar_update()

return true;
}

Expand Down