Lines 27-70
KOHA.OpenLibrary = {
Link Here
|
27 |
scriptElement.setAttribute("id", "jsonScript"); |
27 |
scriptElement.setAttribute("id", "jsonScript"); |
28 |
scriptElement.setAttribute("src", |
28 |
scriptElement.setAttribute("src", |
29 |
"http://openlibrary.org/api/books?bibkeys=" + escape(bibkeys) + |
29 |
"http://openlibrary.org/api/books?bibkeys=" + escape(bibkeys) + |
30 |
"&callback=KOHA.OpenLibrary.olCallBack"); |
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 |
|
33 |
|
34 |
}, |
34 |
}, |
35 |
|
35 |
|
|
|
36 |
|
37 |
|
36 |
/** |
38 |
/** |
37 |
* Add cover pages <div |
39 |
* Add cover pages <div |
38 |
* and link to preview if div id is gbs-thumbnail-preview |
40 |
* and link to preview if div id is gbs-thumbnail-preview |
39 |
*/ |
41 |
*/ |
40 |
olCallBack: function(booksInfo) { |
42 |
olCallBack: function(booksInfo) { |
41 |
for (id in booksInfo) { |
43 |
for (id in booksInfo) { |
42 |
var book = booksInfo[id]; |
44 |
var book = booksInfo[id]; |
43 |
var isbn = book.bib_key.substring(5); |
45 |
var isbn = id.substring(5); |
44 |
|
46 |
$("."+isbn).each(function() { |
45 |
$("."+isbn).each(function() { |
47 |
var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id")); |
46 |
var a = document.createElement("a"); |
48 |
var a = document.createElement("a"); |
47 |
a.href = book.info_url; |
49 |
a.href = booksInfo.url; |
48 |
if (typeof(book.thumbnail_url) != "undefined") { |
50 |
if (book.cover) { |
49 |
var img = document.createElement("img"); |
51 |
var img = document.createElement("img"); |
50 |
img.src = book.thumbnail_url; |
52 |
if (is_opacdetail) { |
51 |
$(this).append(img); |
53 |
img.src = book.cover.medium; |
52 |
var re = /^openlibrary-thumbnail-preview/; |
54 |
$(this).append(img); |
53 |
if ( re.exec($(this).attr("id")) ) { |
55 |
$(this).append( |
54 |
$(this).append( |
56 |
'<div class="results_summary">' + '<a href="' + book.url + '">Preview</a></div>' |
55 |
'<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' + |
57 |
); |
56 |
'<a href="' + |
58 |
} else { |
57 |
book.info_url + |
59 |
img.src = book.cover.small; |
58 |
'">Preview</a></div>' |
60 |
$(this).append(img); |
59 |
); |
61 |
} |
60 |
} |
62 |
} else { |
61 |
} else { |
63 |
var message = document.createElement("span"); |
62 |
var message = document.createElement("span"); |
64 |
$(message).attr("class","no-image"); |
63 |
$(message).attr("class","no-image"); |
65 |
$(message).html(NO_OL_JACKET); |
64 |
$(message).html(NO_OL_JACKET); |
66 |
$(this).append(message); |
65 |
$(this).append(message); |
67 |
} |
66 |
} |
68 |
}); |
67 |
}); |
69 |
} |
68 |
} |
70 |
} |
69 |
} |
|
|
70 |
}; |
71 |
}; |
71 |
- |
|
|