From 923ee0d25379d6556dc9b48f3df6762eee92516f Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 16 May 2013 20:46:21 +0000 Subject: feature 2885: Add geoip info in the stats / history page - fixes and add a location map image git-svn-id: http://piwigo.org/svn/trunk@22703 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/js/jquery.geoip.js | 9 +++++---- admin/themes/default/template/history.tpl | 11 ++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'admin/themes') diff --git a/admin/themes/default/js/jquery.geoip.js b/admin/themes/default/js/jquery.geoip.js index eb4a58b4d..cba374ba5 100644 --- a/admin/themes/default/js/jquery.geoip.js +++ b/admin/themes/default/js/jquery.geoip.js @@ -9,10 +9,10 @@ GeoIp = { var cache = localStorage.getItem("freegeoip"); if (cache) { cache = JSON.parse(cache); - for (var ip in cache) { - var data = cache[ip]; + for (var key in cache) { + var data = cache[key]; if ( (new Date()).getTime() - data.reqTime > 36 * 3600000) - delete cache[ip]; + delete cache[key]; } GeoIp.cache = cache; } @@ -31,6 +31,7 @@ GeoIp = { url: "http://freegeoip.net/json/" + ip, dataType: "jsonp", cache: true, + timeout: 5000, success: function(data) { data.reqTime = (new Date()).getTime(); var res=[]; @@ -47,7 +48,7 @@ GeoIp = { }, error: function() { - var data = {ip:ip, fullName:"", reqTime: (new Date()).getTime()}; + var data = {ip:ip, reqTime: (new Date()).getTime()}; GeoIp.cache[ip] = data; var callbacks = GeoIp.pending[ip]; diff --git a/admin/themes/default/template/history.tpl b/admin/themes/default/template/history.tpl index 5c4d1a1a7..cd2b786eb 100644 --- a/admin/themes/default/template/history.tpl +++ b/admin/themes/default/template/history.tpl @@ -138,6 +138,7 @@ {combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'} {footer_script}{literal} +jQuery(document).ready( function(){ jQuery(".IP").one( "mouseenter", function(){ var that = $(this); that @@ -147,11 +148,19 @@ jQuery(".IP").one( "mouseenter", function(){ }); GeoIp.get( that.text(), function(data) { if (!data.fullName) return; + var content = data.fullName; + if (data.latitude && data.region_name) { + content += "
"; + } that.tipTip( { - content: data.fullName + content: content, + maxWidth: 320 } ); if (that.data("isOver")) that.trigger("mouseenter"); }); } ); +}); {/literal}{/footer_script} \ No newline at end of file -- cgit v1.2.3