Moving configuration parameters to new array config.
This commit is contained in:
		
							parent
							
								
									4b6fb951b2
								
							
						
					
					
						commit
						8886ea4abb
					
				
				
				Notes:
				
					subgit
				
				2018-03-07 17:58:47 +01:00 
			
			r613 www/trunk
@ -74,7 +74,7 @@ function ajaxLoadEvents(stime, etime) {
 | 
				
			|||||||
		maxlat: N+d,
 | 
							maxlat: N+d,
 | 
				
			||||||
		minlon: W-d,
 | 
							minlon: W-d,
 | 
				
			||||||
		maxlon: E+d,
 | 
							maxlon: E+d,
 | 
				
			||||||
		minmag: minMag-0.1,
 | 
							minmag: config['event']['minMag']-0.1,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	$.ajax({
 | 
						$.ajax({
 | 
				
			||||||
		type: "GET",
 | 
							type: "GET",
 | 
				
			||||||
@ -92,10 +92,17 @@ function ajaxLoadEvents(stime, etime) {
 | 
				
			|||||||
				var evaluationMode = $(this).find('evaluationMode').text();
 | 
									var evaluationMode = $(this).find('evaluationMode').text();
 | 
				
			||||||
				var evaluationStatus = $(this).find('evaluationStatus').text();
 | 
									var evaluationStatus = $(this).find('evaluationStatus').text();
 | 
				
			||||||
				var type = $(this).find('type').last().text();
 | 
									var type = $(this).find('type').last().text();
 | 
				
			||||||
				var location = getLocation(Number(lat), Number(lng))[0];
 | 
									var location
 | 
				
			||||||
 | 
									// try use location with reverse geolocation lookup (nominatim), check cache first
 | 
				
			||||||
 | 
									// use getLocation if it fails or description -> text if it also fails
 | 
				
			||||||
 | 
									if ( geolocationTable[id] ) {
 | 
				
			||||||
 | 
										location = geolocationTable[id];
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										location = getGeolocation(id, lat, lng);
 | 
				
			||||||
					( location ) ? null : location = $(this).find('description > text').text();
 | 
										( location ) ? null : location = $(this).find('description > text').text();
 | 
				
			||||||
 | 
									};
 | 
				
			||||||
				// create table row: Date, Time, Mag, Location
 | 
									// create table row: Date, Time, Mag, Location
 | 
				
			||||||
				if ( !eventTable[id] && ( type == 'earthquake' || type == 'induced or triggered event' || type == 'outside of network interest') && evaluationMode != 'automatic' && evaluationStatus != 'preliminary' && Number(mag)+0.05 >= minMag ) {
 | 
									if ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] )+1 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) {
 | 
				
			||||||
					var row = '<tr class="tablesorter-hasChildRow">'
 | 
										var row = '<tr class="tablesorter-hasChildRow">'
 | 
				
			||||||
							+ '<td class="utctime-date">'+otime.split('.')[0]+'Z</td>'
 | 
												+ '<td class="utctime-date">'+otime.split('.')[0]+'Z</td>'
 | 
				
			||||||
							+ '<td class="utctime-time">'+otime.split('.')[0]+'Z</td>'
 | 
												+ '<td class="utctime-time">'+otime.split('.')[0]+'Z</td>'
 | 
				
			||||||
@ -123,8 +130,6 @@ function ajaxLoadEvents(stime, etime) {
 | 
				
			|||||||
							+ sprintf('Ort: %.4f °N, %.4f °O </br>', Number(lat), Number(lng))
 | 
												+ sprintf('Ort: %.4f °N, %.4f °O </br>', Number(lat), Number(lng))
 | 
				
			||||||
							+ sprintf('Zeit: <span class="utctime">%sZ</span></p>', otime.split('.')[0], otime.split('.')[0]);
 | 
												+ sprintf('Zeit: <span class="utctime">%sZ</span></p>', otime.split('.')[0], otime.split('.')[0]);
 | 
				
			||||||
					marker.bindPopup(text);
 | 
										marker.bindPopup(text);
 | 
				
			||||||
					// try to get better location with reverse geolocation lookup (nominatim), check cache first
 | 
					 | 
				
			||||||
					( geolocationTable[id] ) ? $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]) : getGeolocation(id, lat, lng);
 | 
					 | 
				
			||||||
				};
 | 
									};
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@ -198,7 +203,7 @@ function toggleFilteredMarkers() {
 | 
				
			|||||||
	// show all shown events in map
 | 
						// show all shown events in map
 | 
				
			||||||
	$("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() {
 | 
						$("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() {
 | 
				
			||||||
		if ( $(this).attr("eventid") ) {
 | 
							if ( $(this).attr("eventid") ) {
 | 
				
			||||||
			eventTable[$(this).attr("eventid")].setStyle({opacity: 1, strokeOpacity: 1, fillOpacity: eventMarkerOpacity});
 | 
								eventTable[$(this).attr("eventid")].setStyle({opacity: 1, strokeOpacity: 1, fillOpacity: config['event']['markerOpacity']});
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								www/map.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								www/map.js
									
									
									
									
									
								
							@ -34,7 +34,7 @@ function addStationMarker(id, lat, lng) {
 | 
				
			|||||||
			color: "#1C771C",
 | 
								color: "#1C771C",
 | 
				
			||||||
			weight: 1,
 | 
								weight: 1,
 | 
				
			||||||
			opacity: 1,
 | 
								opacity: 1,
 | 
				
			||||||
			fillOpacity: stationMarkerOpacity,
 | 
								fillOpacity: config['station']['markerOpacity'],
 | 
				
			||||||
			className: id+' stationMarker',
 | 
								className: id+' stationMarker',
 | 
				
			||||||
		}).addTo(stationLayer);
 | 
							}).addTo(stationLayer);
 | 
				
			||||||
	stationTable[id] = marker;
 | 
						stationTable[id] = marker;
 | 
				
			||||||
@ -47,7 +47,7 @@ function addEventMarker(id, lat, lng, mag) {
 | 
				
			|||||||
		color: "#FFF500",
 | 
							color: "#FFF500",
 | 
				
			||||||
		weight: 1,
 | 
							weight: 1,
 | 
				
			||||||
		opacity: 1,
 | 
							opacity: 1,
 | 
				
			||||||
		fillOpacity: eventMarkerOpacity,
 | 
							fillOpacity: config['event']['markerOpacity'],
 | 
				
			||||||
		className: id+' eventMarker',
 | 
							className: id+' eventMarker',
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	var marker = L.circle(L.latLng(lat, lng), mag2radius(mag), markerOptions).addTo(eventLayer);
 | 
						var marker = L.circle(L.latLng(lat, lng), mag2radius(mag), markerOptions).addTo(eventLayer);
 | 
				
			||||||
@ -84,14 +84,14 @@ function initMapLink() {
 | 
				
			|||||||
				$(this).removeClass('selected');
 | 
									$(this).removeClass('selected');
 | 
				
			||||||
				$(this).text('Karte');
 | 
									$(this).text('Karte');
 | 
				
			||||||
				eventTable[$(this).attr('eventid')].setStyle(normalStyle);
 | 
									eventTable[$(this).attr('eventid')].setStyle(normalStyle);
 | 
				
			||||||
				map.setView(mapCentreDefault, zoomDefault);
 | 
									map.setView(config['map']['centerDefault'], config['map']['zoomDefault']);
 | 
				
			||||||
				highlightFirstEvent();
 | 
									highlightFirstEvent();
 | 
				
			||||||
			// unselected -> selected
 | 
								// unselected -> selected
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				$(this).addClass('selected');
 | 
									$(this).addClass('selected');
 | 
				
			||||||
				$(this).text('im Fokus (rot)');
 | 
									$(this).text('im Fokus (rot)');
 | 
				
			||||||
				eventTable[$(this).attr('eventid')].setStyle(highlightStyle);
 | 
									eventTable[$(this).attr('eventid')].setStyle(highlightStyle);
 | 
				
			||||||
				map.setView(eventTable[$(this).attr('eventid')].getLatLng(), zoomFocus);
 | 
									map.setView(eventTable[$(this).attr('eventid')].getLatLng(), config['map']['zoomFocus']);
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
@ -104,7 +104,7 @@ function initMapLink() {
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// create a map in the "map" div, set the view to a given place and zoom
 | 
						// create a map in the "map" div, set the view to a given place and zoom
 | 
				
			||||||
	map = L.map('map', { zoomControl: false }).setView(mapCentreDefault, zoomDefault);
 | 
						map = L.map('map', { zoomControl: false }).setView(config['map']['centerDefault'], config['map']['zoomDefault']);
 | 
				
			||||||
	new L.Control.Zoom({ position: 'topright' }).addTo(map);
 | 
						new L.Control.Zoom({ position: 'topright' }).addTo(map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// add MapQuestOSM tile layer
 | 
						// add MapQuestOSM tile layer
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								www/misc.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								www/misc.js
									
									
									
									
									
								
							@ -84,16 +84,26 @@ $( window ).resize(function() {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* create global vars */
 | 
					/* create global vars */
 | 
				
			||||||
var map
 | 
					var map;
 | 
				
			||||||
var eventTable = {};
 | 
					var eventTable = {};
 | 
				
			||||||
var eventDetails = {};
 | 
					var eventDetails = {};
 | 
				
			||||||
var stationTable = {};
 | 
					var stationTable = {};
 | 
				
			||||||
var eventMarkerOpacity = 0.3;
 | 
					var config = {
 | 
				
			||||||
var stationMarkerOpacity = 0.5;
 | 
						event: {
 | 
				
			||||||
var zoomFocus = 12;
 | 
							evaluationBlacklist: ['automatic', 'preliminary'],
 | 
				
			||||||
var zoomDefault = 9;
 | 
							markerOpacity: 0.3,
 | 
				
			||||||
var mapCentreDefault = [51.85, 7.0];
 | 
							minMag: 1.2,
 | 
				
			||||||
var minMag = 1.2;
 | 
							typeWhitelist: ['earthquake', 'induced or triggered event'],
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						map: {
 | 
				
			||||||
 | 
							zoomDefault: 9,
 | 
				
			||||||
 | 
							zoomFocus: 12,
 | 
				
			||||||
 | 
							centerDefault: [51.85, 7.0],
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						station: {
 | 
				
			||||||
 | 
							markerOpacity: 0.5,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					/**********************************************************************
 | 
				
			||||||
 * document ready                                                     *
 | 
					 * document ready                                                     *
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user