@@ -666,6 +666,32 @@ function load() {
666
666
667
667
L . control . periodcontrol ( { position : 'topleft' } ) . addTo ( map ) ;
668
668
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
+
669
695
// update current position if we geolocation is available
670
696
if ( currentPosition ) updateCurrentPosition ( currentPosition . lat , currentPosition . lon ) ;
671
697
@@ -866,10 +892,29 @@ function panTo(vcallsign) {
866
892
}
867
893
}
868
894
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
+
869
914
function sidebar_update ( ) {
870
915
if ( offline . get ( 'opt_selective_sidebar' ) ) {
871
916
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 ) ) {
873
918
$ ( "#main .vehicle" + vehicles [ serial ] . uuid ) . show ( ) ;
874
919
} else {
875
920
if ( ! ( $ ( "#main .vehicle" + vehicles [ serial ] . uuid ) . hasClass ( "follow" ) ) ) {
@@ -879,7 +924,11 @@ function sidebar_update() {
879
924
}
880
925
} else {
881
926
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
+ }
883
932
}
884
933
}
885
934
}
@@ -1460,7 +1509,6 @@ function updateVehicleInfo(vcallsign, newPosition) {
1460
1509
}
1461
1510
1462
1511
var receiver_list_sorted = Object . keys ( vehicle . receiver_info ) . sort ( ) ;
1463
- console . log ( receiver_list_sorted ) ;
1464
1512
1465
1513
for ( var receiver_idx in receiver_list_sorted ) {
1466
1514
var receiver = receiver_list_sorted [ receiver_idx ] ;
@@ -1630,6 +1678,8 @@ function updateVehicleInfo(vcallsign, newPosition) {
1630
1678
// mark vehicles as redrawn
1631
1679
vehicle . updated = false ;
1632
1680
1681
+ sidebar_update ( )
1682
+
1633
1683
return true ;
1634
1684
}
1635
1685
0 commit comments