Bug 10856: Fix cover display in shelf browser
[koha.git] / koha-tmpl / opac-tmpl / prog / en / js / google-jackets.js
index 70b1b84..b23599f 100644 (file)
@@ -19,7 +19,7 @@ KOHA.Google = {
      */
     GetCoverFromIsbn: function(newWindow) {
         var bibkeys = [];
-        $("div [id^=gbs-thumbnail]").each(function(i) {
+        $("[id^=gbs-thumbnail]").each(function(i) {
             bibkeys.push($(this).attr("class")); // id=isbn
         });
         bibkeys = bibkeys.join(',');
@@ -45,13 +45,13 @@ KOHA.Google = {
          }
          for (id in booksInfo) {
              var book = booksInfo[id];
-             $("."+book.bib_key).each(function() {
+             $("[id^=gbs-thumbnail]."+book.bib_key).each(function() {
                  var a = document.createElement("a");
                  a.href = book.info_url;
                  if (typeof(book.thumbnail_url) != "undefined") {
                      var img = document.createElement("img");
                      img.src = book.thumbnail_url;
-                     $(this).append(img);
+                     $(this).empty().append(img);
                      var re = /^gbs-thumbnail-preview/;
                      if ( re.exec($(this).attr("id")) ) {
                          $(this).append(
@@ -67,9 +67,10 @@ KOHA.Google = {
                      var message = document.createElement("span");
                      $(message).attr("class","no-image");
                      $(message).html(NO_GOOGLE_JACKET);
-                     $(this).append(message);
+                     $(this).empty().append(message);
                  }
              });
          }
+
      }
 };