1717// ************************************************************************** //
1818
1919function toggleBlips ( ) {
20- console . _log ( "showing local blips" ) ;
21- if ( _showBlips ) {
22-
23- for ( var spriteId in _blips ) {
24- var blipArray = _blips [ spriteId ] ;
25- //console._log("Disabled (" + spriteId + ")? " + _disabledBlips.includes(spriteId));
26-
27- if ( _disabledBlips . indexOf ( spriteId ) != - 1 ) {
28- if ( _SETTINGS_debug ) {
29- console . _log ( "Blip " + spriteId + "'s are disabled.." ) ;
30- }
31- // If disabled, don't make a marker for it
32- continue ;
33- }
3420
35- for ( var i in blipArray ) {
36- var blip = blipArray [ i ] ;
21+ clearAllMarkers ( ) ;
22+ if ( ! _showBlips ) {
23+ return ;
24+ }
3725
38- var obj = new MarkerObject ( blip . name , new Coordinates ( blip . pos . x , blip . pos . y , blip . pos . z ) , MarkerTypes [ blip . type ] , blip . description , "" , "" ) ;
39- blip . markerId = createMarker ( false , false , obj , "" ) - 1 ;
40- }
26+ for ( var spriteId in _blips ) {
27+ var blipArray = _blips [ spriteId ] ;
28+ console . _log ( "Disabled (" + spriteId + ")? " + _disabledBlips . includes ( spriteId ) ) ;
29+
30+ if ( _disabledBlips . indexOf ( spriteId ) != - 1 ) {
31+ console . _log ( "Blip " + spriteId + "'s are disabled.." ) ;
32+ // If disabled, don't make a marker for it
33+ continue ;
4134 }
4235
43- } else {
44- clearAllMarkers ( ) ;
36+ for ( var i in blipArray ) {
37+ var blip = blipArray [ i ] ;
38+
39+ var obj = new MarkerObject ( blip . name , new Coordinates ( blip . pos . x , blip . pos . y , blip . pos . z ) , MarkerTypes [ blip . type ] , blip . description , "" , "" ) ;
40+ blip . markerId = createMarker ( false , false , obj , "" ) - 1 ;
41+ }
4542 }
43+
4644}
4745
4846$ ( document ) . ready ( function ( ) {
4947 globalInit ( ) ;
5048
49+ // Toggle blip
50+ $ ( "#showBlips" ) . click ( function ( e ) {
51+ e . preventDefault ( ) ;
52+
53+ _showBlips = ! _showBlips ;
54+
55+ //webSocket.send("getBlips");
56+ toggleBlips ( ) ;
57+
58+ $ ( "#blips_enabled" ) . removeClass ( "badge-success" ) . removeClass ( "badge-danger" )
59+ . addClass ( _showBlips ? "badge-success" : "badge-danger" )
60+ . text ( _showBlips ? "on" : "off" ) ;
61+ } ) ;
62+
63+
5164 $ ( "#playerSelect" ) . on ( "change" , function ( ) {
5265 if ( this . value == "" ) {
5366 _trackPlayer = null ;
@@ -60,30 +73,16 @@ $(document).ready(function(){
6073
6174 $ ( "#refreshBlips" ) . click ( function ( e ) {
6275 e . preventDefault ( ) ;
63- if ( _showBlips ) {
64- clearAllMarkers ( ) ;
65- initBlips ( ) ;
66- }
76+
77+ clearAllMarkers ( ) ;
78+ initBlips ( connectedTo . getBlipUrl ( ) ) ;
6779 } ) ;
6880
6981 $ ( "#server_menu" ) . on ( "click" , ".serverMenuItem" , function ( e ) {
7082 console . _log ( $ ( this ) . text ( ) ) ;
7183 changeServer ( $ ( this ) . text ( ) ) ;
7284 } ) ;
7385
74- $ ( "#showBlips" ) . click ( function ( e ) {
75- e . preventDefault ( ) ;
76-
77- _showBlips = ! _showBlips ;
78-
79- //webSocket.send("getBlips");
80- toggleBlips ( ) ;
81-
82- $ ( "#blips_enabled" ) . removeClass ( "badge-success" ) . removeClass ( "badge-danger" )
83- . addClass ( _showBlips ? "badge-success" : "badge-danger" )
84- . text ( _showBlips ? "on" : "off" ) ;
85- } ) ;
86-
8786 $ ( "#reconnect" ) . click ( function ( e ) {
8887 e . preventDefault ( ) ;
8988
@@ -97,25 +96,26 @@ $(document).ready(function(){
9796 } ) ;
9897
9998 $ ( "#toggle-all-blips" ) . on ( "click" , function ( ) {
99+ _blipControlToggleAll = ! _blipControlToggleAll ;
100+ console . _log ( _blipControlToggleAll + " showing blips?" ) ;
100101 // Toggle the classes and add/remove the blipIds from the array
102+
101103 $ ( "#blip-control-container" ) . find ( "a" ) . each ( function ( index , ele ) {
102104 var ele = $ ( ele ) ;
103- var blipId = ele . data ( "blipNumber " ) . toString ( ) ;
105+ var blipId = ele . data ( "blip-number " ) . toString ( ) ;
104106
105- // Toggle blip
106- if ( _disabledBlips . includes ( blipId ) ) {
107- // Already disabled, enable it
107+ if ( _blipControlToggleAll ) {
108+ // Showing them
108109 _disabledBlips . splice ( _disabledBlips . indexOf ( blipId ) , 1 ) ;
109110 ele . removeClass ( "blip-disabled" ) . addClass ( "blip-enabled" ) ;
110111 } else {
111- // Enabled, disable it
112+ // Hiding them all
112113 _disabledBlips . push ( blipId ) ;
113114 ele . removeClass ( "blip-enabled" ) . addClass ( "blip-disabled" ) ;
114115 }
115116 } ) ;
116117
117118 // Now we can refresh the markers
118- clearAllMarkers ( ) ;
119119 toggleBlips ( ) ;
120120 } ) ;
121121} ) ;
@@ -159,15 +159,6 @@ function initControls(Map, PlayerMarkers){
159159 Map . fitBounds ( mapBounds ) ;
160160 CurrentLayer = e . layer ;
161161
162- Map . removeLayer ( PlayerMarkers ) ; // Remove the cluster layer
163- window . PlayerMarkers = L . markerClusterGroup ( { // Re-make it fresh
164- maxClusterRadius : 20 ,
165- spiderfyOnMaxZoom : false ,
166- showCoverageOnHover : false ,
167- zoomToBoundsOnClick : false
168- } ) ;
169- Map . addLayer ( PlayerMarkers ) ; // Add it back. The clearAllMarkers() will ensure player markers are added to the new cluster layer
170-
171162 clearAllMarkers ( ) ;
172163 toggleBlips ( ) ;
173164 } ) ;
0 commit comments