Skip to content

Commit

Permalink
Add rate limit info, update copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
fiorix committed Mar 15, 2016
1 parent 0be4ae8 commit 2947702
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/freegeoip/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$scope.record = {};
$scope.searching = false;
$scope.lastUpdated = '';
$scope.rateLimit = {remaining: 0, expires: 0};
$scope.search = function(q) {
$scope.searching = true;
$http.get("json/" + (q || '')).
Expand All @@ -56,10 +57,14 @@
}
$scope.record = data;
$scope.lastUpdated = headers('X-Database-Date');
var n = headers('X-RateLimit-Remaining');
reset = parseInt(headers('X-RateLimit-Reset'), 10);
$scope.rateLimit = {remaining: n, expires: Math.floor(reset/60) + ' minutes'};
$scope.searching = false;
})
.error(function(data, status) {
$scope.lastUpdated = '';
$scope.rateLimit = {remaining: 0, expires: 0};
$scope.error = 'HTTP ' + status + ': ' + data;
$scope.searching = false;
});
Expand Down Expand Up @@ -117,7 +122,8 @@ <h4>About</h4>
<br/>
<p ng-show="searching">Searching, please wait...</p>
<p ng-show="error" class="label label-danger">Server returned {{error}}</p>
<small ng-show="lastUpdated&&!searching">IP database date:<br/>{{lastUpdated}}</small>
<small ng-show="lastUpdated&&!searching">IP database date: {{lastUpdated}}</small><br>
<small ng-show="rateLimit.expires&&!searching">{{rateLimit.remaining}} calls remaining, resets in {{rateLimit.expires}}</small><br>
<table ng-hide="error||searching" class="table">
<tr ng-show="record.ip != q">
<td>IP</td>
Expand Down Expand Up @@ -240,7 +246,7 @@ <h5>JSON</h5>
This service includes GeoLite2 data created by MaxMind, available
from <a href="http://www.maxmind.com">maxmind.com</a>.
<br/>
&copy; 2009-2015 freegeoip.net
&copy; 2009-2016 freegeoip.net
</small>
</footer>
</div><!-- /.container -->
Expand Down

0 comments on commit 2947702

Please sign in to comment.