@@ -, +, @@ - Consistent indentation - Remove variables which are declared but not used - Add missing semicolons - Add missing "var" declarations - Go to Administration -> System preferences and enable these preferences: - OPACAmazonCoverImages - BakerTaylorEnabled - GoogleJackets - OPACLocalCoverImages - OpenLibraryCovers - Go to the OPAC and confirm that covers from these services appear correctly in search results and on detail pages. --- .../opac-tmpl/bootstrap/js/amazonimages.js | 14 +- .../bootstrap/js/bakertaylorimages.js | 14 +- .../opac-tmpl/bootstrap/js/google-jackets.js | 81 +++--- .../opac-tmpl/bootstrap/js/localcovers.js | 17 +- .../opac-tmpl/bootstrap/js/openlibrary.js | 231 +++++++++--------- 5 files changed, 180 insertions(+), 177 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/amazonimages.js @@ -1,14 +1,16 @@ +/* global __ */ +/* exported verify_images */ // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html function verify_images() { - $("img").each(function(i){ - if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('syndetics.com') >=0) ) { - w = this.width; - h = this.height; + $("img").each(function(){ + if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('syndetics.com') >=0) ) { + var w = this.width; + var h = this.height; if ((w == 1) || (h == 1)) { $(this).parent().html(""+ __("No cover image available") +""); } else if ((this.complete != null) && (!this.complete)) { $(this).parent().html(""+ __("No cover image available") +""); } } - }); - } + }); +} --- a/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/bakertaylorimages.js @@ -1,11 +1,13 @@ +/* global __ */ +/* exported bt_verify_images */ // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html function bt_verify_images() { - $("img").each(function(i){ - if (this.src.indexOf('btol.com') >= 0) { - h = this.height; + $("img").each(function(){ + if (this.src.indexOf('btol.com') >= 0) { + var h = this.height; if (h == 20) { $(this).before(""+ __("No cover image available" ) +""); } - } - }); - } + } + }); +} --- a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/google-jackets.js @@ -1,3 +1,4 @@ +/* global __ */ if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; } @@ -7,7 +8,6 @@ if (typeof KOHA == "undefined" || !KOHA) { */ KOHA.Google = { - /** * Search all: *
@@ -19,7 +19,7 @@ KOHA.Google = { */ GetCoverFromIsbn: function(newWindow) { var bibkeys = []; - $("[id^=gbs-thumbnail]").each(function(i) { + $("[id^=gbs-thumbnail]").each(function() { bibkeys.push($(this).attr("class")); // id=isbn }); bibkeys = bibkeys.join(','); @@ -39,45 +39,46 @@ KOHA.Google = { * and link to preview if div id is gbs-thumbnail-preview */ gbsCallBack: function(booksInfo) { - var target = ''; - if (this.openInNewWindow) { + var target = ''; + if (this.openInNewWindow) { target = 'target="_blank" rel="noreferrer" '; - } - for (id in booksInfo) { - var book = booksInfo[id]; - $("[id^=gbs-thumbnail]."+book.bib_key).each(function() { - if (typeof(book.thumbnail_url) != "undefined") { - if ( $(this).data('use-data-link') ) { - var a = document.createElement("a"); - a.href = book.thumbnail_url; - var img = document.createElement("img"); - img.src = book.thumbnail_url; - img.setAttribute('data-link', book.info_url); - a.append(img) - $(this).empty().append(a); - } else { - var img = document.createElement("img"); - img.src = book.thumbnail_url; - $(this).empty().append(img); - var re = /^gbs-thumbnail-preview/; - if ( re.exec($(this).attr("id")) ) { - $(this).append( - '' - ); - } - } - } else { - var message = document.createElement("span"); - $(message).attr("class","no-image"); - $(message).html(__("No cover image available")); - $(this).empty().append(message); - } - }); + } + for (var id in booksInfo) { + var book = booksInfo[id]; + $("[id^=gbs-thumbnail]."+book.bib_key).each(function() { + if (typeof(book.thumbnail_url) != "undefined") { + var img; + if ( $(this).data('use-data-link') ) { + var a = document.createElement("a"); + a.href = book.thumbnail_url; + img = document.createElement("img"); + img.src = book.thumbnail_url; + img.setAttribute('data-link', book.info_url); + a.append(img); + $(this).empty().append(a); + } else { + img = document.createElement("img"); + img.src = book.thumbnail_url; + $(this).empty().append(img); + var re = /^gbs-thumbnail-preview/; + if ( re.exec($(this).attr("id")) ) { + $(this).append( + '' + ); + } + } + } else { + var message = document.createElement("span"); + $(message).attr("class","no-image"); + $(message).html(__("No cover image available")); + $(this).empty().append(message); + } + }); } this.done = 1; } --- a/koha-tmpl/opac-tmpl/bootstrap/js/localcovers.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/localcovers.js @@ -1,3 +1,4 @@ +/* global __ */ if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; } @@ -17,8 +18,8 @@ KOHA.LocalCover = { * The result is asynchronously returned by OpenLibrary and catched by * olCallBack(). */ - GetCoverFromBibnumber: function(uselink) { - $("div[id^=local-thumbnail],span[id^=local-thumbnail]").each(function(i) { + GetCoverFromBibnumber: function() { + $("div[id^=local-thumbnail],span[id^=local-thumbnail]").each(function() { var mydiv = this; var message = document.createElement("span"); $(message).attr("class","no-image"); @@ -36,16 +37,17 @@ KOHA.LocalCover = { $(mydiv).children('.no-image').remove(); } catch(err){ - }; + // Nothing + } } else if (this.width > 1) { // don't show the silly 1px "no image" img $(mydiv).empty().append(img); $(mydiv).children('.no-image').remove(); } - }) + }); }); }, GetCoverFromItemnumber: function(uselink) { - $("div[class^=local-thumbnail],span[class^=local-thumbnail]").each(function(i) { + $("div[class^=local-thumbnail],span[class^=local-thumbnail]").each(function() { var mydiv = this; var message = document.createElement("span"); var imagenumber = $(mydiv).data("imagenumber"); @@ -65,7 +67,8 @@ KOHA.LocalCover = { $(mydiv).children('.no-image').remove(); } catch(err){ - }; + // Nothing + } } else if (this.width > 1) { // don't show the silly 1px "no image" img if (uselink) { var a = $("").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?imagenumber=' + imagenumber + '&biblionumber=' + biblionumber); @@ -76,7 +79,7 @@ KOHA.LocalCover = { } $(mydiv).children('.no-image').remove(); } - }) + }); }); }, }; --- a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js @@ -1,3 +1,4 @@ +/* global __ */ if (typeof KOHA == "undefined" || !KOHA) { var KOHA = {}; } @@ -18,7 +19,7 @@ KOHA.OpenLibrary = new function() { */ this.GetCoverFromIsbn = function() { var bibkeys = []; - $("[id^=openlibrary-thumbnail]").each(function(i) { + $("[id^=openlibrary-thumbnail]").each(function() { bibkeys.push("ISBN:" + $(this).attr("class")); // id=isbn }); bibkeys = bibkeys.join(','); @@ -29,30 +30,32 @@ KOHA.OpenLibrary = new function() { "&callback=KOHA.OpenLibrary.olCallBack&jscmd=data"); scriptElement.setAttribute("type", "text/javascript"); document.documentElement.firstChild.appendChild(scriptElement); - } + }; /** * Add cover pages