This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
172 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
function compareAssociativeArrays(a, b) { | ||
function nrKeys(a) { | ||
var i = 0; | ||
for (key in a) { | ||
i++; | ||
} | ||
return i; | ||
} | ||
if (a == b) { | ||
return true; | ||
} | ||
if (nrKeys(a) != nrKeys(b)) { | ||
return false; | ||
} | ||
for (key in a) { | ||
if (a[key] != b[key]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
|
||
var previous = {}, incr = 0; // global | ||
function update() { | ||
$.getJSON(JSON_URL, function(response) { | ||
$('#lookups-total').text(response.lookups_json + response.lookups_jsonp); | ||
$('#lookups-json').text(response.lookups_json); | ||
$('#lookups-jsonp').text(response.lookups_jsonp); | ||
$('#lookups-usernames').text(response.lookups_usernames); | ||
$('#auths').text(response.auths); | ||
var change = !compareAssociativeArrays(response, previous); | ||
previous = response; | ||
|
||
var t; | ||
if (change) { | ||
t = 1; | ||
incr = 0; | ||
} else { | ||
t = Math.min(3 + incr, 10); | ||
incr += 0.1; | ||
} | ||
console.log(Math.ceil(t*1000)); | ||
setTimeout(update, Math.ceil(t * 1000)); | ||
}); | ||
} | ||
$(function() { | ||
setTimeout(update, 5 * 1000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block extra_head %} | ||
<style> | ||
th, td { background-color:#efefef; padding:12px 27px; } | ||
th { text-align:left; } | ||
td { font-size:2.5em; font-weight:bold; } | ||
</style> | ||
{% end %} | ||
|
||
|
||
{% block content %} | ||
<h1>Lookups</h1> | ||
|
||
<p>In other words, is this app being actively used?</p> | ||
|
||
<table> | ||
<tr> | ||
<th>Total number of usernames looked up:</th> | ||
<td id="lookups-usernames">{{ lookups_usernames }}</td> | ||
</tr> | ||
<tr> | ||
<th>Twitter requests total:</th> | ||
<td id="lookups-total">{{ lookups_json + lookups_jsonp }}</td> | ||
</tr> | ||
<tr> | ||
<th>Twitter requests by JSON:</th> | ||
<td id="lookups-json">{{ lookups_json }}</td> | ||
</tr> | ||
<tr> | ||
<th>Twitter requests by JSONP:</th> | ||
<td id="lookups-jsonp">{{ lookups_jsonp }}</td> | ||
</tr> | ||
<tr> | ||
<th>Authentications:</th> | ||
<td id="auths">{{ auths }}</td> | ||
</tr> | ||
</table> | ||
{% end %} | ||
|
||
{% block extra_js %} | ||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | ||
<script> | ||
var JSON_URL = '{{ reverse_url('lookups_json') }}'; | ||
</script> | ||
<script src="{{ static_url('js/lookups.js') }}"></script> | ||
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters