Skip to content

Commit

Permalink
Fix page info layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fiorix committed Mar 15, 2016
1 parent c8a411e commit 0fec4e9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/freegeoip/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$scope.record = {};
$scope.searching = false;
$scope.lastUpdated = '';
$scope.rateLimit = {remaining: 0, expires: 0};
$scope.rateLimit = {ok: false, remaining: 0, expires: 0};
$scope.search = function(q) {
$scope.searching = true;
$http.get("json/" + (q || '')).
Expand All @@ -58,13 +58,19 @@
$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'};
var reset = parseInt(headers('X-RateLimit-Reset'), 10);
if (n) {
$scope.rateLimit = {
ok: true,
remaining: n,
expires: Math.floor(reset/60) + ' minutes'
};
}
$scope.searching = false;
})
.error(function(data, status) {
$scope.lastUpdated = '';
$scope.rateLimit = {remaining: 0, expires: 0};
$scope.rateLimit = {ok: false, remaining: 0, expires: 0};
$scope.error = 'HTTP ' + status + ': ' + data;
$scope.searching = false;
});
Expand Down Expand Up @@ -122,8 +128,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: {{lastUpdated}}</small><br>
<small ng-show="rateLimit.expires&&!searching">{{rateLimit.remaining}} calls remaining, resets in {{rateLimit.expires}}</small><br>
<small ng-show="rateLimit.ok&&!searching">{{rateLimit.remaining}} calls remaining, resets in {{rateLimit.expires}}<br/></small>
<small ng-show="lastUpdated&&!searching">IP database date: {{lastUpdated}}</small><br/>
<table ng-hide="error||searching" class="table">
<tr ng-show="record.ip != q">
<td>IP</td>
Expand Down

0 comments on commit 0fec4e9

Please sign in to comment.