Skip to content

Instantly share code, notes, and snippets.

@delucis
Forked from adampolselli/readernaut.js
Created October 3, 2012 10:41
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 delucis/3826327 to your computer and use it in GitHub Desktop.
Save delucis/3826327 to your computer and use it in GitHub Desktop.
Fork of Adam Polselli’s Readernaut widget script to work with new API
function parseResponse(data) {
var bookshelf = document.getElementById("books");
for (var i=0; i<4; i++) {
var cover = data.objects[i].book_edition.cover;
var title = data.objects[i].book_edition.book.title;
var author = data.objects[i].book_edition.book.authors[0].full_name;
var permalink = data.objects[i].book_edition.short_url;
var link = document.createElement("a");
link.setAttribute("href",permalink);
var img = document.createElement("img");
img.setAttribute("src",cover);
img.setAttribute("alt",title+" by "+author);
img.setAttribute("title",title+" by "+author);
if (i % 2 == 0) {
img.setAttribute("class","odd");
}
link.appendChild(img);
bookshelf.appendChild(link);
}
}
@delucis
Copy link
Author

delucis commented Oct 3, 2012

Include the following, replacing the capitalised parts as appropriate, alongside the above script file:

<script type="text/javascript" src="http://readernaut.com/api/v1/readerbooks/readerbook/?username=YOUR_USERNAME&api_key=YOUR_API_KEY&user__username=USERNAME&callback=parseResponse"></script>

See http://adampolselli.com/2009/03/31/building-a-readernaut-widget/ for details of Adam Polselli’s original widget.
See https://gist.github.com/3470564 for new Readernaut API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment