@@ -, +, @@ checked-out status detail page has big ones --- koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js | 68 ++++++++++++++----------- 1 files changed, 38 insertions(+), 30 deletions(-) --- a/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js +++ a/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js @@ -2,6 +2,13 @@ if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; } +function keys(d) { + var k = []; + for (var i in d) { + k.push(i); + } + return k; +} /** * A namespace for OpenLibrary related functions. */ @@ -27,44 +34,45 @@ KOHA.OpenLibrary = { scriptElement.setAttribute("id", "jsonScript"); scriptElement.setAttribute("src", "http://openlibrary.org/api/books?bibkeys=" + escape(bibkeys) + - "&callback=KOHA.OpenLibrary.olCallBack"); + "&callback=KOHA.OpenLibrary.olCallBack&jscmd=data"); scriptElement.setAttribute("type", "text/javascript"); document.documentElement.firstChild.appendChild(scriptElement); }, + + /** * Add cover pages
' + - 'Preview
' - ); - } - } else { - var message = document.createElement("span"); - $(message).attr("class","no-image"); - $(message).html(NO_OL_JACKET); - $(this).append(message); - } - }); - } - } + for (id in booksInfo) { + var book = booksInfo[id]; + var isbn = id.substring(5); + $("."+isbn).each(function() { + var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id")); + var a = document.createElement("a"); + a.href = booksInfo.url; + if (book.cover) { + var img = document.createElement("img"); + if (is_opacdetail) { + img.src = book.cover.medium; + $(this).append(img); + $(this).append( + '
' + 'Preview
' + ); + } else { + img.src = book.cover.small; + $(this).append(img); + } + } else { + var message = document.createElement("span"); + $(message).attr("class","no-image"); + $(message).html(NO_OL_JACKET); + $(this).append(message); + } + }); + } + } }; --