diff --git a/www/events.js b/www/events.js index 1cfee10..a4f3659 100644 --- a/www/events.js +++ b/www/events.js @@ -22,6 +22,22 @@ $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] ) { @@ -50,17 +66,16 @@ function getGeolocation(id, lat, lng) { }; /* Load events using ajax */ -function ajaxLoadEvents(stime, etime, id) { +function ajaxLoadEvents(stime, etime, id, target) { var mapBounds = map.getBounds(); var request_data = {}; + if ( stime == '' || !stime ) { + stime = new Date(); + stime.setDate(stime.getDate()-config['map']['timespan']); + }; if ( id ) { - if ( id == 'bug2014jptq' ) console.log('Loading special event '+id); request_data = { eventid: id }; } else { - if ( !stime ) { - stime = new Date(); - stime.setDate(stime.getDate()-config['map']['timespan']); - }; request_data = { starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), orderby: 'time-asc', @@ -74,6 +89,7 @@ function ajaxLoadEvents(stime, etime, id) { 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'], @@ -97,7 +113,6 @@ function ajaxLoadEvents(stime, etime, id) { location = ( geolocationTable[id] || getGeolocation(id, lat, lng) ); // create table row: Date, Time, Mag, Location if ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] )+1 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) { - if ( id == 'bug2014jptq' ) console.log('Adding row for special event '+id); // general event info (1st line) var row = '
Ereignis: %s', id) + sprintf('Type: %s', type) diff --git a/www/index.html.de b/www/index.html.de index 078bd3b..580e3c8 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -40,6 +40,7 @@ + diff --git a/www/map.js b/www/map.js index 19f578c..4473cfc 100644 --- a/www/map.js +++ b/www/map.js @@ -41,11 +41,9 @@ function addStationMarker(id, lat, lng, station) { }; /* add event marker */ -function addEventMarker(id, lat, lng, mag) { - if ( id == 'bug2014jptq' ) console.log('Adding marker for special event '+id); +function addEventMarker(id, lat, lng, mag, type) { if ( eventTable[id] ) { return eventTable[id]; - console.log('Marker allready exists ID: '+id); } else { var markerOptions = { gradient: true, @@ -58,7 +56,19 @@ function addEventMarker(id, lat, lng, mag) { className: id+' eventMarker', radius: mag2radius(mag) }; - var marker = L.circleMarker(L.latLng(lat, lng), markerOptions); + var marker; + switch ( type ) { + case 'earthquake': + marker = L.starMarker(L.latLng(lat, lng), markerOptions); + break; + case 'quarry blast': + markerOptions['numberOfPoints'] = 7; + markerOptions['innerRadius'] = 0.3*markerOptions['radius']; + marker = L.starMarker(L.latLng(lat, lng), markerOptions); + break; + default: + marker = L.circleMarker(L.latLng(lat, lng), markerOptions); + }; eventLayer.addLayer(marker); eventTable[id] = marker; return marker; @@ -169,8 +179,9 @@ $(document).ready(function() { // load events ajaxLoadEvents(); - //ajaxLoadEvents([], [], ['bug2014jptq', 'gfz2013yvko']); - ajaxLoadEvents([], [], 'bug2014jptq'); + specialEvents.map(function(id) { + ajaxLoadEvents('', '', id) + }); toggleFilteredMarkers(); // bind popupopen event diff --git a/www/specialevents.js b/www/specialevents.js new file mode 100644 index 0000000..91352d2 --- /dev/null +++ b/www/specialevents.js @@ -0,0 +1,2 @@ +/* $Id$ */ +var specialEvents = ['bug2014jptq', 'gfz2013yvko'];