Free covers for your library, from Google
On Wednesday we added integration with Google Book Search, and talked about it on the main blog. We did it together with a number of cool libraries.
My thoughts are still percolating, but I wanted to throw out a piece of my ham-handed JavaScript code. The code gives your library covers, something libraries usually pay for.
This basic grabs cover images from Google. You feed it an ISBN and it gets the cover. It doesn't link to them. Would they mind? Maybe.
If this saves your library money, consider getting LibraryThing for Libraries. We're clever all over.
My thoughts are still percolating, but I wanted to throw out a piece of my ham-handed JavaScript code. The code gives your library covers, something libraries usually pay for.
This basic grabs cover images from Google. You feed it an ISBN and it gets the cover. It doesn't link to them. Would they mind? Maybe.
<div id="gbsthumbnail"></div>Here's a version that links to them, but only if they have a full version. Surely they wouldn't mind this.
<script type="text/javascript">
/* GBS Cover Script by Tim Spalding/LibraryThing */
function addTheCover(booksInfo)
{
for (i in booksInfo)
{
var book = booksInfo[i];
if (book.thumbnail_url != undefined)
{
document.getElementById('gbsthumbnail').innerHTML =
'<img src="' + book.thumbnail_url + '"/>';
}
}
}
</script>
<script src="http://books.google.com/books?jscmd=viewapi&bibkeys=ISBN:0670880728&callback=addTheCover"></script>
<div id="gbsthumbnail"></div>So, book covers for the price of an occasional link to Google. Sounds like a good deal to me!
<div id="gbslink"></div>
<script type="text/javascript">
/* GBS Cover Script by Tim Spalding/LibraryThing */
function addTheCover(booksInfo)
{
var gbsnameA = new Array("No information", "Book info", "Partial view", "Full view");
for (i in booksInfo)
{
var book = booksInfo[i];
var quality = 0;
if(book.preview == "noview") { quality = 1; }
if(book.preview == "partial") { quality = 2; }
if(book.preview == "full") { quality = 3; }
if (book.thumbnail_url != undefined)
{
document.getElementById('gbsthumbnail').innerHTML =
'<img src="' + book.thumbnail_url + '">';
}
if (quality > 3)
{
document.getElementById('gbslink').innerHTML =
"<a href=\'" + book.preview_url + "\'>" + "Google Books: " + gbsnameA[quality] + "</a>";
}
}
}
</script>
<script src="http://books.google.com/books?jscmd=viewapi&bibkeys=ISBN:0670880728&callback=addTheCover"></script>
If this saves your library money, consider getting LibraryThing for Libraries. We're clever all over.
Labels: code, gbs, google book search, javascript
2 Comments:
You mean "quality > 2" (i.e. 3) not "quality > 3"
Even if the people at Google do mind, I think you're allowed to do it anyway.
Post a Comment
<< Home