diff --git a/www/events.js b/www/events.js index 379520d..cd44da9 100644 --- a/www/events.js +++ b/www/events.js @@ -41,15 +41,12 @@ function addTableRow(row, table) { /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { if ( !geolocationTable[id] ) { - $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } ) + $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng } ) .done(function( json ) { - var city = json.address["city"]; - if ( ~city ) { city = json.address["town"]; }; - if ( ~city ) { city = json.address["village"]; }; - var country = json.address["country"]; - var countryCode = json.address["country_code"].toUpperCase(); + var city = json.features[0].properties.city; + var countryCode = json.features[0].properties.country; geolocationTable[id] = city; - ( countryCode != "DE" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; + ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; if ( city ) { $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); var sort = [[0,1],[1,1],[2,1]]; @@ -120,12 +117,10 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) { var evaluationStatus = $(this).find('origin > evaluationStatus').text(); var type = $(this).find('type').last().text(); var location - // get location, try this in order: - // regional map name, given value, cached value, or nominatim lookup - geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later - location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // 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'] ) { + geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later + location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // general event info (1st line) var row = '