Lines 17-29
KOHA.Google = {
Link Here
|
17 |
* The result is asynchronously returned by Google and catched by |
17 |
* The result is asynchronously returned by Google and catched by |
18 |
* gbsCallBack(). |
18 |
* gbsCallBack(). |
19 |
*/ |
19 |
*/ |
20 |
GetCoverFromIsbn: function() { |
20 |
GetCoverFromIsbn: function(newWindow) { |
21 |
var bibkeys = []; |
21 |
var bibkeys = []; |
22 |
$("div [id^=gbs-thumbnail]").each(function(i) { |
22 |
$("div [id^=gbs-thumbnail]").each(function(i) { |
23 |
bibkeys.push($(this).attr("class")); // id=isbn |
23 |
bibkeys.push($(this).attr("class")); // id=isbn |
24 |
}); |
24 |
}); |
25 |
bibkeys = bibkeys.join(','); |
25 |
bibkeys = bibkeys.join(','); |
26 |
var scriptElement = document.createElement("script"); |
26 |
var scriptElement = document.createElement("script"); |
|
|
27 |
this.openInNewWindow=newWindow; |
27 |
scriptElement.setAttribute("id", "jsonScript"); |
28 |
scriptElement.setAttribute("id", "jsonScript"); |
28 |
scriptElement.setAttribute("src", |
29 |
scriptElement.setAttribute("src", |
29 |
"http://books.google.com/books?bibkeys=" + escape(bibkeys) + |
30 |
"http://books.google.com/books?bibkeys=" + escape(bibkeys) + |
Lines 38-70
KOHA.Google = {
Link Here
|
38 |
* and link to preview if div id is gbs-thumbnail-preview |
39 |
* and link to preview if div id is gbs-thumbnail-preview |
39 |
*/ |
40 |
*/ |
40 |
gbsCallBack: function(booksInfo) { |
41 |
gbsCallBack: function(booksInfo) { |
41 |
for (id in booksInfo) { |
42 |
var target = ''; |
42 |
var book = booksInfo[id]; |
43 |
if (this.openInNewWindow) { |
43 |
$("."+book.bib_key).each(function() { |
44 |
target = 'target="_blank" '; |
44 |
var a = document.createElement("a"); |
45 |
} |
45 |
a.href = book.info_url; |
46 |
for (id in booksInfo) { |
46 |
if (typeof(book.thumbnail_url) != "undefined") { |
47 |
var book = booksInfo[id]; |
47 |
var img = document.createElement("img"); |
48 |
$("."+book.bib_key).each(function() { |
48 |
img.src = book.thumbnail_url; |
49 |
var a = document.createElement("a"); |
49 |
$(this).append(img); |
50 |
a.href = book.info_url; |
50 |
var re = /^gbs-thumbnail-preview/; |
51 |
if (typeof(book.thumbnail_url) != "undefined") { |
51 |
if ( re.exec($(this).attr("id")) ) { |
52 |
var img = document.createElement("img"); |
52 |
$(this).append( |
53 |
img.src = book.thumbnail_url; |
53 |
'<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' + |
54 |
$(this).append(img); |
54 |
'<a href="' + |
55 |
var re = /^gbs-thumbnail-preview/; |
55 |
book.info_url + |
56 |
if ( re.exec($(this).attr("id")) ) { |
56 |
'"><img src="' + |
57 |
$(this).append( |
57 |
'http://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' + |
58 |
'<div style="margin-bottom:5px; margin-top:-5px;font-size:9px">' + |
58 |
'"></a></div>' |
59 |
'<a '+target+'href="' + |
59 |
); |
60 |
book.info_url + |
60 |
} |
61 |
'"><img src="' + |
61 |
} else { |
62 |
'http://books.google.com/intl/en/googlebooks/images/gbs_preview_sticker1.gif' + |
62 |
var message = document.createElement("span"); |
63 |
'"></a></div>' |
63 |
$(message).attr("class","no-image"); |
64 |
); |
64 |
$(message).html(NO_GOOGLE_JACKET); |
65 |
} |
65 |
$(this).append(message); |
66 |
} else { |
66 |
} |
67 |
var message = document.createElement("span"); |
67 |
}); |
68 |
$(message).attr("class","no-image"); |
68 |
} |
69 |
$(message).html(NO_GOOGLE_JACKET); |
69 |
} |
70 |
$(this).append(message); |
|
|
71 |
} |
72 |
}); |
73 |
} |
74 |
} |
70 |
}; |
75 |
}; |