Skip to content

Instantly share code, notes, and snippets.

@jmhobbs
Created June 11, 2012 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmhobbs/2909305 to your computer and use it in GitHub Desktop.
Save jmhobbs/2909305 to your computer and use it in GitHub Desktop.
Toy Using GoSquared API
<!doctype html>
<html>
<head>
<title>GoSquared!</title>
</head>
<body>
<script src="jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
var API_KEY = 'demo',
INTERVAL = 60 * 5;
function refresh () {
$('div.site').each(function ( i, $site ) {
$.getJSON(
'http://api.gosquared.com/concurrents.json?callback=?',
{ api_key: API_KEY, site_token: $site.data('token') },
function ( data ) { $site.find('div').text(data.concurrents); }
);
});
}
$.getJSON(
'http://api.gosquared.com/list_sites.json?callback=?',
{ api_key:API_KEY },
function ( data ) {
$.each( data, function ( i, site ) {
$('body').append(
$('<div/>').addClass('site')
.text(site.name)
.data('token', site.token)
.append($('<div/>'))
);
setInterval( refresh, INTERVAL );
} );
}
);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment