1 if (typeof KOHA == "undefined" || !KOHA) {
6 * A namespace for Google related functions.
13 * <div title="biblionumber" id="isbn" class="gbs-thumbnail"></div>
15 * <div title="biblionumber" id="isbn" class="gbs-thumbnail-preview"></div>
16 * and run a search with all collected isbns to Google Book Search.
17 * The result is asynchronously returned by Google and catched by
20 GetCoverFromIsbn: function(newWindow) {
22 $("[id^=gbs-thumbnail]").each(function(i) {
23 bibkeys.push($(this).attr("class")); // id=isbn
25 bibkeys = bibkeys.join(',');
26 var scriptElement = document.createElement("script");
27 this.openInNewWindow=newWindow;
28 scriptElement.setAttribute("id", "jsonScript");
29 scriptElement.setAttribute("src",
30 "https://books.google.com/books?bibkeys=" + escape(bibkeys) +
31 "&jscmd=viewapi&callback=KOHA.Google.gbsCallBack");
32 scriptElement.setAttribute("type", "text/javascript");
33 document.documentElement.firstChild.appendChild(scriptElement);
38 * Add cover pages <div
39 * and link to preview if div id is gbs-thumbnail-preview
41 gbsCallBack: function(booksInfo) {
43 if (this.openInNewWindow) {
44 target = 'target="_blank" rel="noreferrer" ';
46 for (id in booksInfo) {
47 var book = booksInfo[id];
48 $("[id^=gbs-thumbnail]."+book.bib_key).each(function() {
49 var a = document.createElement("a");
50 a.href = book.info_url;
51 if (typeof(book.thumbnail_url) != "undefined") {
52 var img = document.createElement("img");
53 img.src = book.thumbnail_url;
54 $(this).empty().append(img);
55 var re = /^gbs-thumbnail-preview/;
56 if ( re.exec($(this).attr("id")) ) {
58 '<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' +
59 '<a '+target+'href="' +
62 'https://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
67 var message = document.createElement("span");
68 $(message).attr("class","no-image");
69 $(message).html(NO_GOOGLE_JACKET);
70 $(this).empty().append(message);