Changeset 22683
- Timestamp:
- May 16, 2013, 6:31:48 AM (12 years ago)
- Location:
- trunk/admin/themes/default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/js/jquery.geoip.js
r22664 r22683 5 5 6 6 get: function(ip, callback){ 7 if (!GeoIp.storageInit && window.localStorage) { 8 GeoIp.storageInit = true; 9 var cache = localStorage.getItem("freegeoip"); 10 if (cache) { 11 cache = JSON.parse(cache); 12 for (var ip in cache) { 13 var data = cache[ip]; 14 if ( (new Date()).getTime() - data.reqTime > 36 * 3600000) 15 delete cache[ip]; 16 } 17 GeoIp.cache = cache; 18 } 19 jQuery(window).on("unload", function() { 20 localStorage.setItem("freegeoip", JSON.stringify(GeoIp.cache) ); 21 } ); 22 } 23 7 24 if (GeoIp.cache.hasOwnProperty(ip)) 8 25 callback(GeoIp.cache[ip]); … … 13 30 jQuery.ajax( { 14 31 url: "http://freegeoip.net/json/" + ip, 15 dataType: "json", 32 dataType: "jsonp", 33 cache: true, 16 34 success: function(data) { 35 data.reqTime = (new Date()).getTime(); 17 36 var res=[]; 18 37 if (data.city) res.push(data.city); … … 29 48 30 49 error: function() { 31 var data = {ip:ip, fullName:"" };50 var data = {ip:ip, fullName:"", reqTime: (new Date()).getTime()}; 32 51 33 52 GeoIp.cache[ip] = data; -
trunk/admin/themes/default/template/history.tpl
r22664 r22683 137 137 138 138 {combine_script id='jquery.geoip' load='async' path='admin/themes/default/js/jquery.geoip.js'} 139 {combine_script id='jquery.ui.tooltip' load='footer'}140 139 141 140 {footer_script}{literal} 142 jQuery(".IP").tooltip( { 143 items: "*", 144 /*show: {delay:0, effect:"show"}, 145 hide: {delay:50, effect:"hide"},*/ 146 content: function(response) { 147 var that = $(this); 148 GeoIp.get( that.text(), function(data) { 149 response( data.fullName ); 141 jQuery(".IP").one( "mouseenter", function(){ 142 var that = $(this); 143 that 144 .data("isOver", true) 145 .one("mouseleave", function() { 146 that.removeData("isOver"); 150 147 }); 151 } 152 }); 148 GeoIp.get( that.text(), function(data) { 149 if (!data.fullName) return; 150 that.tipTip( { 151 content: data.fullName 152 } ); 153 if (that.data("isOver")) 154 that.trigger("mouseenter"); 155 }); 156 } ); 153 157 {/literal}{/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.