1 if (typeof KOHA == "undefined" || !KOHA) {
6 * A namespace for OpenLibrary related functions.
13 * <div title="biblionumber" id="isbn" class="openlibrary-thumbnail"></div>
15 * <div title="biblionumber" id="isbn" class="openlibrary-thumbnail-preview"></div>
16 * and run a search with all collected isbns to Open Library Book Search.
17 * The result is asynchronously returned by OpenLibrary and catched by
20 GetCoverFromIsbn: function() {
22 $("div [id^=openlibrary-thumbnail]").each(function(i) {
23 bibkeys.push("ISBN:" + $(this).attr("class")); // id=isbn
25 bibkeys = bibkeys.join(',');
26 var scriptElement = document.createElement("script");
27 scriptElement.setAttribute("id", "jsonScript");
28 scriptElement.setAttribute("src",
29 "http://openlibrary.org/api/books?bibkeys=" + escape(bibkeys) +
30 "&callback=KOHA.OpenLibrary.olCallBack&jscmd=data");
31 scriptElement.setAttribute("type", "text/javascript");
32 document.documentElement.firstChild.appendChild(scriptElement);
39 * Add cover pages <div
40 * and link to preview if div id is gbs-thumbnail-preview
42 olCallBack: function(booksInfo) {
43 for (id in booksInfo) {
44 var book = booksInfo[id];
45 var isbn = id.substring(5);
46 $("."+isbn).each(function() {
47 var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id"));
48 var a = document.createElement("a");
49 a.href = booksInfo.url;
51 var img = document.createElement("img");
53 img.src = book.cover.medium;
56 '<div class="results_summary">' + '<a href="' + book.url + '">Preview</a></div>'
59 img.src = book.cover.small;
63 var message = document.createElement("span");
64 $(message).attr("class","no-image");
65 $(message).html(NO_OL_JACKET);
66 $(this).append(message);