File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,23 @@ $(function () {
4
4
} ) ;
5
5
6
6
function get_ip ( ) {
7
- $ . getJSON ( "/api/v1/ip/view?limit=10 &offset=" + page . page * 10 , function ( result ) {
7
+ $ . getJSON ( "/api/v1/ip/view?limit=25 &offset=" + page . page * 25 , function ( result ) {
8
8
if ( result . data . length < 10 ) {
9
9
$ ( "#next" ) . attr ( { "disabled" : "disabled" } ) ;
10
10
}
11
-
11
+ var ip_unique , ip_list = [ ] ;
12
12
for ( var i = 0 ; i < result . data . length ; i ++ ) {
13
13
var data = JSON . parse ( result . data [ i ] ) ;
14
14
data . timestamp = moment . utc ( data . timestamp ) . local ( ) . format ( ) ;
15
15
var html = template ( "tpl-ip" , data ) ;
16
16
$ ( "tbody" ) . append ( html ) ;
17
- result . data [ i ] = data ;
17
+ ip_list . push ( data . ip )
18
18
}
19
19
20
- for ( var i = 0 ; i < result . data . length ; i ++ ) {
21
- $ . getJSON ( "//www.freegeoip.net/json/" + result . data [ i ] . ip , function ( res ) {
20
+ ip_unique = ip_list . filter ( function ( element , index , self ) { return self . indexOf ( element ) === index ; } ) ;
21
+
22
+ for ( var i = 0 ; i < ip_unique . length ; i ++ ) {
23
+ $ . getJSON ( "//www.freegeoip.net/json/" + ip_unique [ i ] , function ( res ) {
22
24
$ ( ".region[data-ip='" + res . ip + "']" ) . text ( res . region_name ) ;
23
25
$ ( ".country[data-ip='" + res . ip + "']" ) . text ( res . country_name ) ;
24
26
} )
You can’t perform that action at this time.
0 commit comments