1 if (KOHA === undefined || !KOHA) { var KOHA = {}; }
5 * A namespace for Coce cover images cache
11 * <div title="biblionumber" id="isbn" class="coce-thumbnail"></div>
13 * <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div>
14 * and run a search with all collected isbns to coce cover service.
15 * The result is asynchronously returned, and used to append <img>.
17 getURL: function(host, provider) {
19 $("[id^=coce-thumbnail]").each(function() {
20 var id = $(this).attr("class"); // id=isbn
21 if (id !== '') { ids.push(id); }
23 if (ids.length == 0) { this.done = 1; return; }
25 var coceURL = host + '/cover?id=' + ids + '&provider=' + provider;
29 success: function(urlPerID) {
30 for (var id in urlPerID) {
31 var url = urlPerID[id];
32 $("[id^=coce-thumbnail]." + id).each(function() {
33 var img = document.createElement("img");
35 img.alt = "Cover image";
36 img.onload = function() {
37 // image dimensions can't be known until image has loaded
38 if (img.height == 1 && img.width == 1) {
39 $(this).closest(".coce-coverimg").remove();
42 $(this).attr('href', url);