aboutsummaryrefslogtreecommitdiffstats
path: root/admin/themes
diff options
context:
space:
mode:
Diffstat (limited to 'admin/themes')
-rw-r--r--admin/themes/default/js/jquery.geoip.js23
-rw-r--r--admin/themes/default/template/history.tpl26
2 files changed, 36 insertions, 13 deletions
diff --git a/admin/themes/default/js/jquery.geoip.js b/admin/themes/default/js/jquery.geoip.js
index fae389190..eb4a58b4d 100644
--- a/admin/themes/default/js/jquery.geoip.js
+++ b/admin/themes/default/js/jquery.geoip.js
@@ -4,6 +4,23 @@ GeoIp = {
pending: {},
get: function(ip, callback){
+ if (!GeoIp.storageInit && window.localStorage) {
+ GeoIp.storageInit = true;
+ var cache = localStorage.getItem("freegeoip");
+ if (cache) {
+ cache = JSON.parse(cache);
+ for (var ip in cache) {
+ var data = cache[ip];
+ if ( (new Date()).getTime() - data.reqTime > 36 * 3600000)
+ delete cache[ip];
+ }
+ GeoIp.cache = cache;
+ }
+ jQuery(window).on("unload", function() {
+ localStorage.setItem("freegeoip", JSON.stringify(GeoIp.cache) );
+ } );
+ }
+
if (GeoIp.cache.hasOwnProperty(ip))
callback(GeoIp.cache[ip]);
else if (GeoIp.pending[ip])
@@ -12,8 +29,10 @@ GeoIp = {
GeoIp.pending[ip] = [callback];
jQuery.ajax( {
url: "http://freegeoip.net/json/" + ip,
- dataType: "json",
+ dataType: "jsonp",
+ cache: true,
success: function(data) {
+ data.reqTime = (new Date()).getTime();
var res=[];
if (data.city) res.push(data.city);
if (data.region_name) res.push(data.region_name);
@@ -28,7 +47,7 @@ GeoIp = {
},
error: function() {
- var data = {ip:ip, fullName:""};
+ var data = {ip:ip, fullName:"", 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 fa0f49e1d..5c4d1a1a7 100644
--- a/admin/themes/default/template/history.tpl
+++ b/admin/themes/default/template/history.tpl
@@ -136,18 +136,22 @@
{if !empty($navbar) }{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
{combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'}
-{combine_script id='jquery.ui.tooltip' load='footer'}
{footer_script}{literal}
-jQuery(".IP").tooltip( {
- items: "*",
- /*show: {delay:0, effect:"show"},
- hide: {delay:50, effect:"hide"},*/
- content: function(response) {
- var that = $(this);
- GeoIp.get( that.text(), function(data) {
- response( data.fullName );
+jQuery(".IP").one( "mouseenter", function(){
+ var that = $(this);
+ that
+ .data("isOver", true)
+ .one("mouseleave", function() {
+ that.removeData("isOver");
});
- }
-});
+ GeoIp.get( that.text(), function(data) {
+ if (!data.fullName) return;
+ that.tipTip( {
+ content: data.fullName
+ } );
+ if (that.data("isOver"))
+ that.trigger("mouseenter");
+ });
+} );
{/literal}{/footer_script} \ No newline at end of file