-
-
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
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
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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