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 if (typeof(book.thumbnail_url) != "undefined") {
50 if ( $(this).data('use-data-link') ) {
51 var a = document.createElement("a");
52 a.href = book.thumbnail_url;
53 var img = document.createElement("img");
54 img.src = book.thumbnail_url;
55 img.setAttribute('data-link', book.info_url);
57 $(this).empty().append(a);
59 var img = document.createElement("img");
60 img.src = book.thumbnail_url;
61 $(this).empty().append(img);
62 var re = /^gbs-thumbnail-preview/;
63 if ( re.exec($(this).attr("id")) ) {
65 '<div class="google-books-preview">' +
66 '<a '+target+'href="' +
69 'https://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' +
75 var message = document.createElement("span");
76 $(message).attr("class","no-image");
77 $(message).html(NO_GOOGLE_JACKET);
78 $(this).empty().append(message);