Skip to content

Commit

Permalink
feature 2885: Add geoip info in the stats / history page - fixes and …
Browse files Browse the repository at this point in the history
…add a location map image

git-svn-id: http://piwigo.org/svn/trunk@22703 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed May 16, 2013
1 parent 090b2e4 commit 923ee0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions admin/themes/default/js/jquery.geoip.js
Expand Up @@ -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;
}
Expand All @@ -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=[];
Expand All @@ -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];
Expand Down
11 changes: 10 additions & 1 deletion admin/themes/default/template/history.tpl
Expand Up @@ -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
Expand All @@ -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 += "<br><img width=300 height=220 src=\"http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=300x220&zoom=6"
+ "&markers=size:tiny%7C" + data.latitude + "," + data.longitude
+ "\">";
}
that.tipTip( {
content: data.fullName
content: content,
maxWidth: 320
} );
if (that.data("isOver"))
that.trigger("mouseenter");
});
} );
});
{/literal}{/footer_script}

0 comments on commit 923ee0d

Please sign in to comment.