diff --git a/www/events.js b/www/events.js index 2dfc8d0..9a55398 100644 --- a/www/events.js +++ b/www/events.js @@ -66,33 +66,44 @@ function getGeolocation(id, lat, lng) { }; /* Load events using ajax */ -function ajaxLoadEvents(stime, etime, id, target) { +function ajaxLoadEvents(stime, etime, id, 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']); - }; - if ( id ) { - request_data = { eventid: id }; + rtime = new Date(); + rtime.setDate(rtime.getDate()-config['ajax']['timespan']); } else { - request_data = { - starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), - orderby: 'time-asc', - 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()); + rtime = stime; + }; + if ( url ) { + var ajax_url = url; + request_data = {}; + } else { + if ( id ) { + request_data = { eventid: id }; + } else { + request_data = { + starttime: sprintf("%d-%02d-%02d", rtime.getFullYear(), rtime.getMonth()+1, rtime.getDate()), + orderby: 'time-asc', + 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: config['ajax']['eventURL'], + url: ajax_url, data: request_data, dataType: "xml", success: function (xml) { diff --git a/www/map.js b/www/map.js index 4473cfc..23d1516 100644 --- a/www/map.js +++ b/www/map.js @@ -178,6 +178,7 @@ $(document).ready(function() { eventLayer = new L.MarkerGroup().addTo(map); // load events + ajaxLoadEvents('', '', '', 'events.xml'); ajaxLoadEvents(); specialEvents.map(function(id) { ajaxLoadEvents('', '', id) diff --git a/www/misc.js b/www/misc.js index 9771431..f93bfaf 100644 --- a/www/misc.js +++ b/www/misc.js @@ -97,6 +97,7 @@ var config = { stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query', nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php', // nominatimURL: '//nominatim.openstreetmap.org/reverse', + timespan: 60, }, event: { evaluationBlacklist: ['automatic', 'preliminary', 'rejected'],