Compare commits

...

2 Commits

6 changed files with 109 additions and 97 deletions

1
.gitattributes vendored
View File

@ -2,6 +2,7 @@
scripts/mkEvents.csh -text
www/.htaccess -text
www/copyright.inc.de -text
www/eventsXML.js -text
www/external/TileLayer.Grayscale.js -text
www/external/css/dvf.css -text
www/external/css/leaflet.label.css -text

View File

@ -22,91 +22,8 @@
$Id$
*/
/* adding row(s) to a table and format date strings afterwards */
function addTableRow(row, table) {
var added = $('#'+table+' tbody').append(row);
added.find('.tablesorter-childRow td').hide();
$('#'+table).find('td.utctime-date').each(function() {
$.localtime.formatObject($(this), "dd.MM.yyyy");
$(this).removeClass('utctime-date');
$(this).addClass('localtime-date');
});
$('#'+table).find('td.utctime-time').each(function() {
$.localtime.formatObject($(this), "HH:mm");
$(this).removeClass('utctime-time');
$(this).addClass('localtime-time');
});
};
/* do reverse geolocation lookup */
function getGeolocation(id, lat, lng) {
if ( !geolocationTable[id] ) {
$.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } )
.done(function( json ) {
var city = json.address["city"];
var country = json.address["country"];
var countryCode = json.address["country_code"].toUpperCase();
geolocationTable[id] = city;
( country != "Deutschland" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null;
if ( city ) {
$("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]);
var sort = [[0,1],[1,1],[2,1]];
$("#eventstable").trigger("update", [true]);
$("#eventstable").trigger("updateCache");
$("#eventstable").trigger("sorton", [sort]);
} else {
console.log("Nominatim did not provide a city tag for "+lat+" / "+lng);
};
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});
};
};
/* Load events using ajax */
function ajaxLoadEvents(stime, etime, eventid, url, target) {
var mapBounds = map.getBounds();
var request_data = {};
var rtime;
var ajax_url = config['ajax']['eventURL'];
if ( stime == '' || !stime ) {
stime = new Date();
stime.setDate(stime.getDate()-config['map']['timespan']);
rtime = new Date();
rtime.setDate(rtime.getDate()-Math.min(config['ajax']['timespan'], config['map']['timespan']));
} else {
rtime = stime;
};
if ( url ) {
var ajax_url = url;
request_data = {};
} else {
if ( eventid ) {
request_data = { eventid: eventid };
} else {
request_data = {
starttime: sprintf("%d-%02d-%02d", rtime.getFullYear(), rtime.getMonth()+1, rtime.getDate()),
orderby: 'time',
minlat: sprintf('%.2f', mapBounds.getSouth()-config['map']['latlngDelta']),
maxlat: sprintf('%.2f', mapBounds.getNorth()+config['map']['latlngDelta']),
minlon: sprintf('%.2f', mapBounds.getWest()-config['map']['latlngDelta']),
maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']),
minmag: sprintf('%.1f', config['event']['minMag']-config['event']['minMagDelta']),
};
if ( etime ) {
request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate());
};
};
};
if ( etime == '' || !etime ) { etime = new Date(); };
$.ajax({
type: "GET",
url: ajax_url,
data: request_data,
dataType: "xml",
success: function (xml) {
/* process loaded events */
function processEvents(xml, target) {
$(xml).find('event').each(function () {
var id = $(this).attr('publicID').split('/')[2];
var mag = $(this).find('magnitude > mag > value').text();
@ -145,14 +62,14 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) {
+ sprintf('Download <a class="xml-link" target="_blank" download="%s.xml" href="%s">QuakeML</a> or <a class="mseed-link" target="_blank" download="%s.mseed" href="%s">miniSEED</a>', id, xmlurl, id, mseedurl)
+ '</td></tr>';
// add row to table
if ( stime <= oTime && etime >= oTime ) {
if ( sTime <= oTime && eTime >= oTime ) {
addTableRow(row, 'eventstable');
};
if ( target ) {
addTableRow(row, target);
}
// create marker
if ((stime <= oTime && etime >= oTime ) || ( id == eventid )) {
if ((sTime <= oTime && eTime >= oTime ) || ( id == eventid )) {
var marker = addEventMarker(id, Number(lat), Number(lng), Number(mag), type);
var text = sprintf('<h3 eventid="%s">%s</h3>', id, location)
+ sprintf('<p>Ereignis: %s</br>', id)
@ -165,7 +82,94 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) {
};
};
});
},
};
/* adding row(s) to a table and format date strings afterwards */
function addTableRow(row, table) {
var added = $('#'+table+' tbody').append(row);
added.find('.tablesorter-childRow td').hide();
$('#'+table).find('td.utctime-date').each(function() {
$.localtime.formatObject($(this), "dd.MM.yyyy");
$(this).removeClass('utctime-date');
$(this).addClass('localtime-date');
});
$('#'+table).find('td.utctime-time').each(function() {
$.localtime.formatObject($(this), "HH:mm");
$(this).removeClass('utctime-time');
$(this).addClass('localtime-time');
});
};
/* do reverse geolocation lookup */
function getGeolocation(id, lat, lng) {
if ( !geolocationTable[id] ) {
$.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } )
.done(function( json ) {
var city = json.address["city"];
var country = json.address["country"];
var countryCode = json.address["country_code"].toUpperCase();
geolocationTable[id] = city;
( country != "Deutschland" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null;
if ( city ) {
$("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]);
var sort = [[0,1],[1,1],[2,1]];
$("#eventstable").trigger("update", [true]);
$("#eventstable").trigger("updateCache");
$("#eventstable").trigger("sorton", [sort]);
};
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});
};
};
/* Load events using ajax */
function ajaxLoadEvents(startup, stime, etime, eventid, url, target) {
var mapBounds = map.getBounds();
var request_data = {};
var rtime;
var ajax_url = config['ajax']['eventURL'];
if ( stime == '' || !stime ) {
stime = new Date();
stime.setDate(stime.getDate()-config['map']['timespan']);
rtime = new Date();
rtime.setDate(rtime.getDate()-Math.min(config['ajax']['timespan'], config['map']['timespan']));
} else {
rtime = stime;
};
if ( url ) {
var ajax_url = url;
request_data = {};
} else {
if ( eventid ) {
request_data = { eventid: eventid };
} else {
request_data = {
starttime: sprintf("%d-%02d-%02d", rtime.getFullYear(), rtime.getMonth()+1, rtime.getDate()),
orderby: 'time',
minlat: sprintf('%.2f', mapBounds.getSouth()-config['map']['latlngDelta']),
maxlat: sprintf('%.2f', mapBounds.getNorth()+config['map']['latlngDelta']),
minlon: sprintf('%.2f', mapBounds.getWest()-config['map']['latlngDelta']),
maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']),
minmag: sprintf('%.1f', config['event']['minMag']-config['event']['minMagDelta']),
};
if ( etime ) {
request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate());
};
};
};
if ( etime == '' || !etime ) { etime = new Date(); };
if ( startup ) {
processEvents(eventsXML, false);
} else {
$.ajax({
type: "GET",
url: ajax_url,
data: request_data,
dataType: "xml",
success: function ( xml ) { processEvents(xml, target) },
complete: function () {
var sort = [[0,1],[1,1],[2,1]];
$("#eventstable").trigger("update", [true]);
@ -180,6 +184,7 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) {
console.log( "Request Failed: " + err );
}
});
};
// create events csv download link
request_data['format'] = 'text';
if ( eventid == '' || !eventid ) { $('#events-csv-link').attr('href', config['ajax']['eventURL']+'?'+$.param(request_data)) };
@ -281,6 +286,7 @@ function toggleFilteredMarkers() {
/* Highlight the first event of the event list on the map if no
* other event is selected */
function highlightFirstEvent() {
$('div.info').show()
var highlightStyle = {
color: config['event']['markerColorH'],
fillColor: config['event']['markerColorH'],
@ -306,6 +312,7 @@ function highlightFirstEvent() {
$(this).text('Karte (rot)');
};
});
$('div.info').hide()
};
function highlightEvent( id ) {

1
www/eventsXML.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,6 @@
<link rel="stylesheet" href="external/leaflet.css" />
<!-- link rel="stylesheet" href="external/css/dvf.css" type="text/css" media="screen" / -->
<link rel="stylesheet" href="external/css/leaflet.label.css" type="text/css" media="screen" />
<link rel="stylesheet" href="external/easyPrint.css"/>
<!-- jQuery & jQueryUI -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
@ -38,7 +37,6 @@
<script type="text/javascript" src="external/leaflet-dvf.markers.min.js"></script>
<script type="text/javascript" src="external/leaflet.label.js"></script>
<script src="external/jQuery.print.js"></script>
<script src="external/leaflet.easyPrint.js"></script>
<!-- Map, Events & Stations -->
<script type="text/javascript" src="misc.js"></script>
@ -47,6 +45,7 @@
<script type="text/javascript" src="map.js"></script>
<script type="text/javascript" src="events.js"></script>
<script type="text/javascript" src="stations.js"></script>
<script type="text/javascript" src="eventsXML.js"></script>
</head>
<body>

View File

@ -183,11 +183,12 @@ $(document).ready(function() {
eventLayer = new L.MarkerGroup().addTo(map);
// load events
ajaxLoadEvents('', '', '', 'events.xml');
ajaxLoadEvents();
specialEvents.map(function(id) {
ajaxLoadEvents('', '', id)
});
ajaxLoadEvents(true);
// ajaxLoadEvents(false, '', '', '', 'events.xml');
ajaxLoadEvents(false);
// specialEvents.map(function(id) {
// ajaxLoadEvents(false, '', '', id)
//});
toggleFilteredMarkers();
// bind popupopen event
@ -216,5 +217,5 @@ $(document).ready(function() {
});
// print icon
L.easyPrint().addTo(map);
// L.easyPrint().addTo(map);
});

View File

@ -106,12 +106,12 @@ var config = {
markerColorH: 'red',
minMag: 1.2,
minMagDelta: 0.1,
typeWhitelist: ['earthquake', 'induced or triggered event', 'quarry blast', 'explosion'],
typeWhitelist: ['earthquake', 'induced or triggered event'],
},
map: {
zoomDefault: 9,
zoomFocus: 12,
centerDefault: [51.85, 7.0],
centerDefault: [51.65, 7.2],
timespan: 180,
latlngDelta: 0.1,
},
@ -129,7 +129,7 @@ var config = {
NL_WIT: 3,
NL_WTSB: 3,
},
networkBlacklist: ['NL', 'X5'],
networkBlacklist: ['NL', 'X5', '1A'],
},
tab: {
active: 0,
@ -211,4 +211,7 @@ $(document).ready(function() {
}).bind("ajaxStop", function() {
$("#spinner").hide();
});
// hide info container
$('div.info').hide()
});