View | Details | Raw Unified | Return to bug 7161
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js (-31 / +25 lines)
Lines 30-71 KOHA.OpenLibrary = { Link Here
30
            "&callback=KOHA.OpenLibrary.olCallBack&jscmd=data");
30
            "&callback=KOHA.OpenLibrary.olCallBack&jscmd=data");
31
        scriptElement.setAttribute("type", "text/javascript");
31
        scriptElement.setAttribute("type", "text/javascript");
32
        document.documentElement.firstChild.appendChild(scriptElement);
32
        document.documentElement.firstChild.appendChild(scriptElement);
33
34
    },
33
    },
35
34
36
37
38
    /**
35
    /**
39
     * Add cover pages <div
36
     * Add cover pages <div
40
     * and link to preview if div id is gbs-thumbnail-preview
37
     * and link to preview if div id is gbs-thumbnail-preview
41
     */
38
     */
42
    olCallBack: function(booksInfo) {
39
    olCallBack: function(booksInfo) {
43
    for (id in booksInfo) {
40
        for (id in booksInfo) {
44
       var book = booksInfo[id];
41
            var book = booksInfo[id];
45
       var isbn = id.substring(5);
42
            var isbn = id.substring(5);
46
       $("."+isbn).each(function() {
43
            $("."+isbn).each(function() {
47
       var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id"));
44
                var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id"));
48
           var a = document.createElement("a");
45
                var a = document.createElement("a");
49
           a.href = booksInfo.url;
46
                a.href = booksInfo.url;
50
           if (book.cover) {
47
                if (book.cover) {
51
               var img = document.createElement("img");
48
                    var img = document.createElement("img");
52
               if (is_opacdetail) {
49
                    if (is_opacdetail) {
53
        img.src = book.cover.medium;
50
                        img.src = book.cover.medium;
54
        $(this).append(img);
51
                        $(this).append(img);
55
                $(this).append(
52
                        $(this).append('<div class="results_summary">' + '<a href="' + book.url + '">Preview</a></div>');
56
                       '<div class="results_summary">' + '<a href="' + book.url + '">Preview</a></div>'
53
                    } else {
57
                   );
54
                        img.src = book.cover.small;
58
               } else {
55
                        $(this).append(img);
59
            img.src = book.cover.small;
56
                    }
60
            $(this).append(img);
57
                } else {
58
                    var message =  document.createElement("span");
59
                    $(message).attr("class","no-image");
60
                    $(message).html(NO_OL_JACKET);
61
                    $(this).append(message);
62
                }
63
            });
61
        }
64
        }
62
           } else {
65
    }
63
               var message =  document.createElement("span");
64
               $(message).attr("class","no-image");
65
               $(message).html(NO_OL_JACKET);
66
               $(this).append(message);
67
           }
68
       });
69
   }
70
 }
71
};
66
};
72
- 

Return to bug 7161