Completed
Push — master ( 536398...4468a8 )
by Yannick
06:51 queued 47s
created
js/map.js.php 1 patch
Braces   +128 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,8 +6,11 @@  discard block
 block discarded – undo
6 6
 //$_COOKIE['MapFormat'] = '2d';
7 7
 
8 8
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
9
+if (!isset($globalJsonCompress)) {
10
+	$compress = true;
11
+} else {
12
+	$compress = $globalJsonCompress;
13
+}
11 14
 ?>
12 15
 <?php
13 16
 	if (isset($_GET['archive'])) {
@@ -19,8 +22,11 @@  discard block
 block discarded – undo
19 22
 		//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
20 23
 		//$lastupd = 20;
21 24
 		$lastupd = $_GET['archivespeed']*$archiveupdatetime;
22
-		if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
23
-		else $enddate = time();
25
+		if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
26
+			$enddate = $_GET['enddate'];
27
+		} else {
28
+			$enddate = time();
29
+		}
24 30
 		setcookie("archive_begin",$begindate);
25 31
 		setcookie("archive_end",$enddate);
26 32
 		setcookie("archive_update",$lastupd);
@@ -127,7 +133,17 @@  discard block
 block discarded – undo
127 133
 	}
128 134
 
129 135
 	//create the map
130
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
136
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
137
+	print $latitude;
138
+} else {
139
+	print $globalCenterLatitude;
140
+}
141
+?>,<?php if (isset($longitude)) {
142
+	print $longitude;
143
+} else {
144
+	print $globalCenterLongitude;
145
+}
146
+?>], zoom);
131 147
 <?php
132 148
 	} else {
133 149
 ?>
@@ -140,9 +156,19 @@  discard block
 block discarded – undo
140 156
 	     || navigator.userAgent.match(/BlackBerry/i)
141 157
 	     || navigator.userAgent.match(/Windows Phone/i))
142 158
 	{
143
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
159
+		var zoom = <?php if (isset($globalLiveZoom)) {
160
+	print $globalLiveZoom-1;
161
+} else {
162
+	print '8';
163
+}
164
+?>;
144 165
 	} else {
145
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
166
+		var zoom = <?php if (isset($globalLiveZoom)) {
167
+	print $globalLiveZoom;
168
+} else {
169
+	print '9';
170
+}
171
+?>;
146 172
 	}
147 173
 
148 174
 	//create the map
@@ -167,16 +193,27 @@  discard block
 block discarded – undo
167 193
 	bounds = L.latLngBounds(southWest,northEast);
168 194
 	//a few title layers
169 195
 <?php
170
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
171
-	else $MapType = $globalMapProvider;
196
+	if (isset($_COOKIE['MapType'])) {
197
+		$MapType = $_COOKIE['MapType'];
198
+	} else {
199
+		$MapType = $globalMapProvider;
200
+	}
172 201
 
173 202
 	if ($MapType == 'Mapbox') {
174
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
175
-		else $MapBoxId = $_COOKIE['MapTypeId'];
176
-?>
203
+		if ($_COOKIE['MapTypeId'] == 'default') {
204
+			$MapBoxId = $globalMapboxId;
205
+		} else {
206
+			$MapBoxId = $_COOKIE['MapTypeId'];
207
+		}
208
+		?>
177 209
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
178 210
 	    maxZoom: 18,
179
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
211
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
212
+	print 'false';
213
+} else {
214
+	print 'true';
215
+}
216
+?>,
180 217
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
181 218
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
182 219
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -188,7 +225,12 @@  discard block
 block discarded – undo
188 225
 ?>
189 226
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
190 227
 	    maxZoom: 18,
191
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
228
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
229
+	print 'false';
230
+} else {
231
+	print 'true';
232
+}
233
+?>,
192 234
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
193 235
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
194 236
 	}).addTo(map);
@@ -234,20 +276,26 @@  discard block
 block discarded – undo
234 276
 	map.addLayer(yandexLayer);
235 277
 <?php
236 278
 	} elseif ($MapType == 'Bing-Aerial') {
237
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
238
-?>
279
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
280
+			setcookie('MapType','OpenStreetMap');
281
+		}
282
+		?>
239 283
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
240 284
 	map.addLayer(bingLayer);
241 285
 <?php
242 286
 	} elseif ($MapType == 'Bing-Hybrid') {
243
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
244
-?>
287
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
288
+			setcookie('MapType','OpenStreetMap');
289
+		}
290
+		?>
245 291
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
246 292
 	map.addLayer(bingLayer);
247 293
 <?php
248 294
 	} elseif ($MapType == 'Bing-Road') {
249
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
250
-?>
295
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
296
+			setcookie('MapType','OpenStreetMap');
297
+		}
298
+		?>
251 299
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
252 300
 	map.addLayer(bingLayer);
253 301
 <?php
@@ -295,7 +343,12 @@  discard block
 block discarded – undo
295 343
 		}
296 344
 	} elseif ($globalBounding == 'circle') {
297 345
 ?>
298
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
346
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
347
+	print $globalBoundingCircleSize;
348
+} else {
349
+	print '70000';
350
+}
351
+?>,{
299 352
 	    color: '#92C7D1',
300 353
 	    fillColor: '#92C7D1',
301 354
 	    fillOpacity: 0.3,
@@ -354,8 +407,11 @@  discard block
 block discarded – undo
354 407
 
355 408
 	function update_airportsLayer() {
356 409
 	    <?php
357
-		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
358
-		else $getZoom = '7';
410
+		if (isset($_COOKIE['AirportZoom'])) {
411
+			$getZoom = $_COOKIE['AirportZoom'];
412
+		} else {
413
+			$getZoom = '7';
414
+		}
359 415
 	    ?>
360 416
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
361 417
 		if (typeof airportsLayer != 'undefined') {
@@ -689,9 +745,13 @@  discard block
 block discarded – undo
689 745
 		    if (callsign != ""){ markerLabel += callsign; }
690 746
 		    if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
691 747
 <?php
692
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
693
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
694
-	else $IconColor = '1a3151';
748
+	if (isset($_COOKIE['IconColor'])) {
749
+		$IconColor = $_COOKIE['IconColor'];
750
+	} elseif (isset($globalAircraftIconColor)) {
751
+		$IconColor = $globalAircraftIconColor;
752
+	} else {
753
+		$IconColor = '1a3151';
754
+	}
695 755
 	if (!isset($ident) && !isset($flightaware_id)) {
696 756
 ?>
697 757
 		    info_update(feature.properties.fc);
@@ -739,7 +799,12 @@  discard block
 block discarded – undo
739 799
 <?php
740 800
 		} else {
741 801
 ?>
742
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
802
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
803
+	print $archiveupdatetime*1000;
804
+} else {
805
+	print $globalMapRefresh*1000+20000;
806
+}
807
+?>+feature.properties.sqt*1000);
743 808
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
744 809
 <?php
745 810
 		}
@@ -786,7 +851,12 @@  discard block
 block discarded – undo
786 851
 <?php
787 852
 		} else {
788 853
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
854
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
855
+	print $archiveupdatetime*1000;
856
+} else {
857
+	print $globalMapRefresh*1000+20000;
858
+}
859
+?>+feature.properties.sqt*1000);
790 860
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 861
 <?php
792 862
 		}
@@ -832,7 +902,12 @@  discard block
 block discarded – undo
832 902
 <?php
833 903
 		} else {
834 904
 ?>
835
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
905
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
906
+	print $archiveupdatetime*1000;
907
+} else {
908
+	print $globalMapRefresh*1000+20000;
909
+}
910
+?>+feature.properties.sqt*1000);
836 911
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
837 912
 <?php
838 913
 		}
@@ -1173,14 +1248,24 @@  discard block
 block discarded – undo
1173 1248
 	if (isset($_GET['archive'])) {
1174 1249
 ?>
1175 1250
 //then load it again every 30 seconds
1176
-//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
1251
+//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1252
+	print ($globalMapRefresh*1000)/2;
1253
+} else {
1254
+	print '15000';
1255
+}
1256
+?>);
1177 1257
 reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
1178 1258
 <?php
1179 1259
 	} else {
1180 1260
 ?>
1181 1261
 //then load it again every 30 seconds
1182 1262
 reloadPage = setInterval(
1183
-    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
1263
+    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1264
+	print $globalMapRefresh*1000;
1265
+} else {
1266
+	print '30000';
1267
+}
1268
+?>);
1184 1269
 var currentdate = new Date(Date.UTC());
1185 1270
 var currentyear = new Date().getFullYear();
1186 1271
 var begindate = new Date(Date.UTC(currentyear,12,24,2,0,0,0));
@@ -1192,7 +1277,12 @@  discard block
 block discarded – undo
1192 1277
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
1193 1278
 ?>
1194 1279
 update_polarLayer();
1195
-setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1280
+setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
1281
+	print $globalMapRefresh*1000*2;
1282
+} else {
1283
+	print '60000';
1284
+}
1285
+?>);
1196 1286
 <?php
1197 1287
 		}
1198 1288
 ?>
@@ -1208,7 +1298,12 @@  discard block
 block discarded – undo
1208 1298
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
1209 1299
 ?>
1210 1300
 update_atcLayer();
1211
-setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1301
+setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
1302
+	print $globalMapRefresh*1000*2;
1303
+} else {
1304
+	print '60000';
1305
+}
1306
+?>);
1212 1307
 <?php
1213 1308
 	}
1214 1309
 ?>
Please login to merge, or discard this patch.