From 14d988b0b4158e3feca4b57c1fb63ae2dafe8289 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 16:16:01 +0000 Subject: [PATCH] Merge. --- www/events.js | 9 +++------ www/map.js | 23 ++++++++++++++++++----- www/misc.js | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/www/events.js b/www/events.js index a632b48..a0e9023 100644 --- a/www/events.js +++ b/www/events.js @@ -87,12 +87,9 @@ function ajaxLoadEvents(stime, etime) { var location // try to 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 = geolocationTable[id] ) ? null : location = getGeolocation(id, lat, lng); + ( location ) ? null : location = getLocation(lat, lng)[0]; + ( location ) ? null : $(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'] ) { // general event info (1st line) diff --git a/www/map.js b/www/map.js index c8ef474..d3371fd 100644 --- a/www/map.js +++ b/www/map.js @@ -106,6 +106,7 @@ $(document).ready(function() { // create a map in the "map" div, set the view to a given place and zoom map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); new L.Control.Zoom({ position: 'topright' }).addTo(map); + new L.control.scale({position: 'bottomright', imperial: false}).addTo(map); // add MapQuestOSM tile layer // L.tileLayer.grayscale('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', @@ -135,12 +136,24 @@ $(document).ready(function() { map.on('popupopen', function() { // convert date/time to localtime $("div.leaflet-popup span.utctime").each(function(){$(this).addClass("localtime").removeClass("utctime");$.localtime.formatObject($(this), "dd.MM.yyyy - HH:mm")}); - var eventid = $("div.leaflet-popup h3").attr("eventid"); - if ( eventid ) { - // highlight event in table - highlightEvent(eventid); + openMarkerID = $("div.leaflet-popup h3").attr("eventid"); + if ( openMarkerID ) { // update city in popup - $("div.leaflet-popup h3").text(geolocationTable[eventid]); + $("div.leaflet-popup h3").text(geolocationTable[openMarkerID]); + // highlight event in table and show details + // highlightEvent(eventid); + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); }; }); + map.on('popupclose', function() { + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); + }); }); diff --git a/www/misc.js b/www/misc.js index a8efb38..b727fa9 100644 --- a/www/misc.js +++ b/www/misc.js @@ -73,6 +73,7 @@ $( window ).resize(function() { /* create global vars */ var map; +var openMarkerID; var eventTable = {}; var eventDetails = {}; var stationTable = {};