Skip to content

Instantly share code, notes, and snippets.

@judell
Created June 18, 2015 23:39
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 judell/61ddc4670487c542a368 to your computer and use it in GitHub Desktop.
Save judell/61ddc4670487c542a368 to your computer and use it in GitHub Desktop.
CORS Sample
<html>
<head>
<title>urls recently annotated with hypothesis</title>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
<style>
body { margin-left: .5in; margin-top:.25in; font-family:verdana; word-break:break-word; font-size:11pt }
a { color: gray }
#widget { width: 50%; padding:8px; border-width:thin; border-style:solid }
</style>
</head>
<body>
<div id="widget">
<h1>urls recently annotated with hypothesis</h1>
</div>
<script>
function load() {
$.get( "https://hypothes.is/api/search", function( data )
{ process(data['rows']);});
}
function process(rows) {
var o = new Object();
for ( i=0; i < rows.length; i++ ) {
row = rows[i];
uri = row['uri'];
if ( uri in o )
o[uri] += 1;
else
o[uri] = 1;
}
for (key in o) {
$('#widget').append('<p><a href="https://via.hypothes.is/' + key + '">' + key + '</a> (' + o[key] + ')</p>');
}
}
load();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment