JQuery Library - OPAC
Jump to navigation
Jump to search
Main page | Staff Interface | OPAC
Category
Enhanced content
Export formats
Add direct export to RefWorks link to OPAC
- Developer: Jared Camins-Esakov, ByWater Solutions
- Purpose: Add a link to directly export a citation to RefWorks
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 3.2+
function getParameterByName( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
$(document).ready(function(){
$("<div id='refworks'><a href='http://www.refworks.com/express/expressimport.asp?vendor=Koha&filter=RIS%20Format&encoding=65001&url=http%3A%2F%2F" + location.host + "%2Fcgi-bin%2Fkoha%2Fopac-export.pl%3Fop%3Dexport%26format%3Dris%26bib%3D" + getParameterByName('biblionumber') + "' target='RefWorksMain'>Export to RefWorks</a></div>").appendTo("#export");
$("#userbasket #toolbar .download").parent().after("<li><a class='download' href='http://www.refworks.com/express/expressimport.asp?vendor=Koha&filter=RIS%20Format&encoding=65001&url=http%3A%2F%2F" + location.host + "%2Fcgi-bin%2Fkoha%2Fopac-downloadcart.pl%3Fformat%3Dris%26bib_list%3D" + encodeURIComponent(getParameterByName('bib_list')) + "' target='RefWorksMain'>Export to RefWorks</a></li>")
$("#usershelves #toolbar .download").after("<span id='refworks'><a class='download tag_hides' href='http://www.refworks.com/express/expressimport.asp?vendor=Koha&filter=RIS%20Format&encoding=65001&url=http%3A%2F%2F" + location.host + "%2Fcgi-bin%2Fkoha%2Fopac-downloadshelf.pl%3Fformat%3Dris%26shelfid%3D" + encodeURIComponent(getParameterByName('viewshelf')) + "' target='RefWorksMain'>Export to RefWorks</a></span>");
});
External database highlight
Add database placards in search results based on keywords (v18.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds a placard link advertising a database in OPAC results based on preset keywords
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 18.x
- Notes: Fill kw_keywords with as many keywords as needed. Place in single quotes and separate with commas. Replace [LINK TO DATABASE], [LINK TO IMAGE] and [DESCRIPTION OF DATABASE].
//Placards
var kw_keywords = ['keyword1','keyword2'];
var kw_count = 0;
while (kw_count < kw_keywords.length) {
if ( $('#results a').is(':contains(Results):contains(kw):contains('+kw_keywords[kw_count]+')') ) {
$('div.searchresults tbody tr').eq(1).after('<tr><td colspan="3" style="background-color: lightyellow; border: 1px solid black;"><div class="db-placard"><a href="[LINK TO DATABASE]" target="_blank"><img src="[LINK TO IMAGE]" width="150" style="float: left; padding-right: 20px;"><h2><p>Looks like you are searching for [DESCRIPTION OF DATABASE].</p><p>Click here to go to the database.</h2></a></div></td></tr>');
kw_count = kw_keywords.length;
} else {
kw_count++;
}
}
//End Placards
Add database placards in search results based on keywords (v19.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds a placard link advertising a database in OPAC results based on preset keywords
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 19.x
- Notes: This version addresses changes made to the structure of the breadcrumbs that is searched for the keywords in 19.05. Fill kw_keywords with as many keywords as needed. Place in single quotes and separate with commas. Replace [LINK TO DATABASE], [LINK TO IMAGE] and [DESCRIPTION OF DATABASE].
//Placards
var kw_keywords = ['keyword1','keyword2'];
var kw_count = 0;
while (kw_count < kw_keywords.length) {
if ( $('#results a').is(':contains(Results):contains('+kw_keywords[kw_count]+')') && ($('#results a[title*="kw"]').length) ) {
$('div.searchresults tbody tr').eq(1).after('<tr><td colspan="3" style="background-color: lightyellow; border: 1px solid black;"><div class="db-placard"><a href="[LINK TO DATABASE]" target="_blank"><img src="[LINK TO IMAGE]" width="150" style="float: left; padding-right: 20px;"><h2><p>Looks like you are searching for [DESCRIPTION OF DATABASE].</p><p>Click here to go to the database.</h2></a></div></td></tr>');
kw_count = kw_keywords.length;
} else {
kw_count++;
}
}
//End Placards
Add database placards in search results based on keywords (v20.x)
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Adds a placard link advertising a database in OPAC results based on preset keywords
- Status: Completed
- Creation Date: 2021-04-01
- Staff interface or OPAC?: OPAC
- Version: 20.x
- Notes: This version is not necessarily changed because of coding changes in 20.x. It might work in 19.x, but I have not tested it. Most of the changes are cosmetic and incorporating CSS adjustments and clearer instructions. Fill kw_keywords with as many keywords as needed. Place in single quotes and separate with commas. Replace LINK_TO_DATABASE, LINK_TO_IMAGE and DESCRIPTION_OF_CONTENT. Note that you can easily define which row the placard appears on with the placard_row variable. And there is a new placard_second_row variable for a second appearance.
/*Placards*/
.placard-cell {
background-color: transparent!important;
}
.placard {
position: relative;
background-color: lightyellow;
border: 1px solid black!important;
border-radius: 7px;
min-height: 150px;
padding: 5px;
}
.placard-left {
float: left;
padding-right: 10px;
}
.placard-img {
max-height: 150px;
}
//Placards to show in results on opac-search.pl
//This will create a new expression (iContains) that will be a case-insensitive version of Contains.
jQuery.expr[':'].iContains = function(a, i, m) {
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};
var placard_row = 2; //Use 0 to disable
var placard_second_row = 12; //Use 0 to disable - must be at least 2 rows more than placard_row.
var placard_count = 0;
//Define each placard [[keywords],image path,content],...
//Entire placard variable should be in the pattern of [[keywords for 1st placard],image path, description of content],[keywords for 2nd placard],image path, description of content],etc.]
var placards = [
[['keyword1','keyword2','keyword3','keyword4','keyword5'],'LINK_TO_IMAGE','<h2><a href="LINK_TO_DATABASE">DESCRIPTION_OF_CONTENT</a></h2>']];
//Placard logic and placement
if (placard_row > 0) {
while (placard_count < placards.length) {
var kw_count = 0;
while (kw_count < placards[placard_count][0].length) {
if ($('ul.breadcrumb a').is(':contains(Results):iContains('+placards[placard_count][0][kw_count]+')') && ($('ul.breadcrumb a[title*="You searched"]').length) ) {
$('div.searchresults tbody tr').eq(placard_row - 1).before('<tr><td class="placard-cell" colspan="3"><div class="placard"><div class="placard-left"><img src="'+placards[placard_count][1]+'"></div><div class="placard-right">'+placards[placard_count][2]+'</div></div></td></tr>');
if (($('div.searchresults tbody tr').length > placard_second_row) && (placard_second_row > 0) && (placard_second_row > placard_row+1)) {
$('div.searchresults tbody tr').eq(placard_second_row - 1).before('<tr><td class="placard-cell" colspan="3"><div class="placard"><div class="placard-left"><img src="'+placards[placard_count][1]+'"></div><div class="placard-right">'+placards[placard_count][2]+'</div></div></td></tr>');
}
kw_count = placards[placard_count][0].length;
} else {
kw_count++;
}
}
placard_count++;
}
}
//END Placards to show in results on opac-search.pl
HathiTrust
Add link to HathiTrust on results and details page if isbn or oclc number found and content in public domain
- Developer: Nick Clemens
- Purpose: Adds a link to free materials available from hathi trust
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 17.05
- Note: This could certainly be simplified, but this works :-)
$(document).ready(function(){
//add hathi to results
if ($("#results").length) {
$("input[name='biblionumber']").each(function(){
var bnum = $(this).val();
$.getJSON("/cgi-bin/koha/svc/report?id=400&sql_params=" + bnum, function(data) {
$.each(data, function(index, value) {
if( value[0] ){
$.getJSON("https://catalog.hathitrust.org/api/volumes/brief/isbn/" + value[0] + ".json", function(data) {
if( Object.keys(data.records).length ){
var h_url = data.records[Object.keys(data.records)[0]].recordURL;
var p_d = data.items[Object.keys(data.items)[0]].rightsCode;
if( h_url.length > 0 && p_d == 'pd' ){
console.log($("#bib"+bnum).parent('tr').find('.results_summary.availability'));
$("#bib"+bnum).closest('tr').find('.results_summary.availability').append('<span class="results_summary online_resources"><a href="'+h_url+'">Access on HathiTrust</a>');
}
}
});
} else {
$.getJSON("/cgi-bin/koha/svc/report?id=398&sql_params=" + bnum, function(data) {
$.each(data, function(index, value) {
if( value[0] ){
oclc_num = value[0].replace(/\D/g,'');
$.getJSON("https://catalog.hathitrust.org/api/volumes/brief/oclc/" + oclc_num + ".json", function(data) {
if( Object.keys(data.records).length ){
var h_url = data.records[Object.keys(data.records)[0]].recordURL;
var p_d = data.items[Object.keys(data.items)[0]].rightsCode;
if( h_url.length > 0 && p_d == 'pd' ){
$(".record").append('<span class="results_summary online_resources"><a href="'+h_url+'">Access on HathiTrust</a>');
}
}
});
}
});
});
}
});
});
});
}
//add hathi link to details page
if ($("#opac-detail").length) {
var bnum = $("input[name='bib']").val();
$.getJSON("/cgi-bin/koha/svc/report?id=400&sql_params=" + bnum, function(data) {
$.each(data, function(index, value) {
if( value[0] ){
$.getJSON("https://catalog.hathitrust.org/api/volumes/brief/isbn/" + value[0] + ".json", function(data) {
var h_url = data.records[Object.keys(data.records)[0]].recordURL;
var p_d = data.items[Object.keys(data.items)[0]].rightsCode;
if( h_url.length > 0 && p_d == 'pd' ){
$(".record").append('<span class="results_summary online_resources"><a href="'+h_url+'">Access on HathiTrust</a>');
}
});
} else {
$.getJSON("/cgi-bin/koha/svc/report?id=398&sql_params=" + bnum, function(data) {
$.each(data, function(index, value) {
if( value[0] ){
oclc_num = value[0].replace(/\D/g,'');
$.getJSON("https://catalog.hathitrust.org/api/volumes/brief/oclc/" + oclc_num + ".json", function(data) {
var h_url = data.records[Object.keys(data.records)[0]].recordURL;
var p_d = data.items[Object.keys(data.items)[0]].rightsCode;
if( h_url.length > 0 && p_d == 'pd' ){
$(".record").append('<span class="results_summary online_resources"><a href="'+h_url+'">Access on HathiTrust</a>');
}
});
}
});
});
}
});
});
}
});
Hoopla
Enhance results from the Hoopla Plug-in
- Developer: George Williams (Northease Kansas Library System / Next Search Catalog) - modifys code created by Christopher Brannon
- Purpose: Turns the Hoopla results data into a placard to draw more attention to this resource
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 20.05
- Notes: Change the URL in #hoopla-banner to match the location of the banner you'd like to display
//Enhance Hoopla results
jQuery(document).ready(checkContainer);
function checkContainer() {
if ($('#hoopla_results').is(':visible')) {
$('#hoopla_results').css('padding-top', '20px').wrap('<div id="hoopla-banner" style="padding-top: 20px;"><table width="100%" style="border: 1px solid black;"><tr><td style="background-color: lightyellow;"></td></tr></table></div>');
$('#hoopla-banner td').prepend('<img src="https://www.idaho.gov/assets/business-74595c3f85cf8df2cfe25d62642662d5cecc67ddc505a845d1175d289992bbb9.jpg" style="float: left; padding-right: 20px; max-width: 400px; height: auto;">');
$('#numresults').clone().appendTo('#userresults');
$('#hoopla_results a').each(function() {
var text = $(this).text();
$(this).text(text.replace('results in Hoopla', 'results in Hoopla for this search'));
});
} else {
setTimeout(checkContainer, 50); //wait 50 ms, then try again
}
}
iDreamBooks.com (no longer active)
Add iDreamBooks.com Readometer to OPAC
- Developer: C & P Bibliography Services
- Purpose: Add a "Readometer" from iDreamBooks.com to the OPAC to show aggregated information about reviews of the book by professional critics.
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 3.6+ with XSLT enabled for the OPAC details page
- Note: This is an updated version that offers better web browser compatibility. Anyone using the iFrame version originally posted should switch.
var isbn = $(".isbn:last").text().split(" ")[1];
if (isbn) {
isbn = isbn.replace(/\W*$/, '');
if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) {
// Use Microsoft XDR for IE version 8 or above
var xdr = new XDomainRequest();
xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e");
xdr.onload = function() {
if (! typeof(json) == 'undefined') {
json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... };
eval(json); // json is now a regular JSON object
$(".title").append('<a href="'+json.book.detail_link+'" id="idreambooksreadometer"><img src="http://idreambooks.com/remotereadometer/'+isbn+'.jpg" alt="'+json.book.title+' by '+json.book.author+'" title="Rating based on reviews of '+json.book.title+'"></a>');
}
}
xdr.send();
} else {
$.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){
if (! typeof(json) == 'undefined') {
$(".title").append('<a href="'+json.book.detail_link+'" id="idreambooksreadometer"><img src="http://idreambooks.com/remotereadometer/'+isbn+'.jpg" alt="'+json.book.title+' by '+json.book.author+'" title="Rating based on reviews of '+json.book.title+'"></a>');
}
});
}
}
You will also need the following line of CSS in your OPACUserCSS:
#idreambooksreadometer {
float: right;
}
Add iDreamBooks.com reviews tab to OPAC (3.6-3.8)
- Developer: C & P Bibliography Services
- Purpose: Add a tab with snippets of reviews from iDreamBooks.com to the OPAC
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 3.6-3.8 with XSLT enabled for the OPAC details page (3.10 script below)
var isbn = $(".isbn:last").text().split(" ")[1];
if (isbn) {
isbn = isbn.replace(/\W*$/, '');
if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) {
// Use Microsoft XDR for IE version 8 or above
var xdr = new XDomainRequest();
xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e");
xdr.onload = function() {
json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... };
eval(json); // json is now a regular JSON object
parseIDBJSON(json); // parse using same function as for jQuery's success event
}
xdr.send();
} else {
$.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){
parseIDBJSON(json);
});
}
}
// NOTE THAT THE CODE BELOW SHOULD NOT GO IN $(document).ready.
function parseIDBJSON( json ) {
if(json.total_results > 0 && json.book.rating > 0){
var isbn = $(".isbn:last").text().split(" ")[1];
//build new tab for critic reviews
$("#bibliodescriptions").append('<div id="idb_critic_reviews"><div id="idb_review_snippets"></div><span><a id="seemoreidb">More book reviews at iDreamBooks.com</a></span></div>');
$("#bibliodescriptions ul").tabs('add', '#idb_critic_reviews', 'Book reviews by critics ( '+json.book.review_count+' )');
//append happy-sad cloud review
$("#catalogue_detail_biblio").append("<span class='idreambookssummary results_summary'><a href='"+json.book.detail_link+"'><img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%</a> <a href='http://www.idreambooks.com/'>rating based on reviews at iDreamBooks.com</a></span>");
//insert data into Book reviews tab
$.each(json.book.critic_reviews, function(){
$("#idb_review_snippets").append("<div class='review'><div><a href='"+this.review_link+"'>"+this.source+"</a></div><div>\"..."+this.snippet+"...\"</div><div>Review date: "+this.review_date+"</div><div><a class='reviewlink' href='"+json.book.detail_link+"'>Review result: "+this.pos_or_neg+" <img src='"+this.smiley_or_sad_small+"' alt='iDreamBooks.com rating' title='"+this.pos_or_neg+"' /></a></div></div>");
});
$("#seemoreidb").attr('href', json.book.detail_link);
}
}
You will also need the following CSS added to your OPACUserCSS syspref:
.review {
margin-bottom: 20px;
}
a.idreambooksrating {
font-size: 30px;
color: #29ADE4;
padding-left: 85px;
line-height: 30px;
text-decoration: none;
}
.idreambookslegend {
font-size: small;
}
a.reviewlink,a.reviewlink:visited {
text-decoration: none;
color: black;
font-weight: normal;
}
.idreambookssummary a {
color: #707070;
text-decoration: none;
}
.idreambookssummary img, .idbresult img {
vertical-align: middle;
}
.idbresult {
color: #29ADE4;
text-align: center;
margin: 0.5em;
padding: 0.5em;
}
.idbresult a, .idbresult a:visited {
text-decoration: none;
color: #29ADE4;
}
.idbresult img {
padding-right: 6px;
}
Add iDreamBooks.com reviews tab to OPAC (3.10+)
- Developer: C & P Bibliography Services
- Purpose: Add a tab with snippets of reviews from iDreamBooks.com to the OPAC
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 3.10+ with XSLT enabled for the OPAC details page (3.6-3.8 script above)
var isbn = $(".isbn:last").text().split(" ")[1];
if (isbn) {
isbn = isbn.replace(/\W*$/, '');
if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) {
// Use Microsoft XDR for IE version 8 or above
var xdr = new XDomainRequest();
xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e");
xdr.onload = function() {
json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... };
eval(json); // json is now a regular JSON object
parseIDBJSON(json); // parse using same function as for jQuery's success event
}
xdr.send();
} else {
$.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){
parseIDBJSON(json);
});
}
}
function parseIDBJSON( json ) {
if(json.total_results > 0 && json.book.rating > 0){
var isbn = $(".isbn:last").text().split(" ")[1];
//build new tab for critic reviews
$("#bibliodescriptions").append('<div id="idb_critic_reviews"><div id="idb_review_snippets"></div><span><a id="seemoreidb">More book reviews at iDreamBooks.com</a></span></div>');
$("#bibliodescriptions").tabs('add', '#idb_critic_reviews', 'Book reviews by critics ( '+json.book.review_count+' )');
//append happy-sad cloud review
$("#catalogue_detail_biblio").append("<span class='idreambookssummary results_summary'><a href='"+json.book.detail_link+"'><img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%</a> <a href='http://www.idreambooks.com/'>rating based on reviews at iDreamBooks.com</a></span>");
//insert data into Book reviews tab
$.each(json.book.critic_reviews, function(){
$("#idb_review_snippets").append("<div class='review'><div><a href='"+this.review_link+"'>"+this.source+"</a></div><div>\"..."+this.snippet+"...\"</div><div>Review date: "+this.review_date+"</div><div><a class='reviewlink' href='"+json.book.detail_link+"'>Review result: "+this.pos_or_neg+" <img src='"+this.smiley_or_sad_small+"' alt='iDreamBooks.com rating' title='"+this.pos_or_neg+"' /></a></div></div>");
});
$("#seemoreidb").attr('href', json.book.detail_link);
$("#tab_idb_critic_reviews").show();
}
}
You will also need the following CSS added to your OPACUserCSS syspref:
.review {
margin-bottom: 20px;
}
a.idreambooksrating {
font-size: 30px;
color: #29ADE4;
padding-left: 85px;
line-height: 30px;
text-decoration: none;
}
.idreambookslegend {
font-size: small;
}
a.reviewlink,a.reviewlink:visited {
text-decoration: none;
color: black;
font-weight: normal;
}
.idreambookssummary a {
color: #707070;
text-decoration: none;
}
.idreambookssummary img, .idbresult img {
vertical-align: middle;
}
.idbresult {
color: #29ADE4;
text-align: center;
margin: 0.5em;
padding: 0.5em;
}
.idbresult a, .idbresult a:visited {
text-decoration: none;
color: #29ADE4;
}
.idbresult img {
padding-right: 6px;
}
Maps
Add a link to map the publisher's location
- Developer: Jared Camins-Esakov, C & P Bibliography Services
- Purpose: Add a link to map the publisher's location.
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: All
- Note: This particular implementation is for MARC21, and retrieves the location from an authority-controlled 751. In order to identify the correct 751, it looks for the relator code 'pup' (place of publication).
$.get("/cgi-bin/koha/opac-export.pl",
{ bib: $("input[name='bib']").val(), format: "marcxml" },
function(data){
$(".publisher > span[class='label']:first").append("<a target='_blank' href='http://maps.google.com/maps?q=" + $(data).find("datafield[tag='751'] > subfield[code='4']:contains('pup')").parent().find("subfield[code='a']").text() + "'><img src='/opac-tmpl/prog/famfamfam/MP.png' alt='Show publisher on map' title='Show publisher on map' /></a>");
}
);
- Note: This particular implementation is for MARC21, and retrieves the location from the 260$a, then removes any trailing punctuation. For all but the most recent of books, this is likely to result in an inaccurate (or useless) map.
$.get("/cgi-bin/koha/opac-export.pl",
{ bib: $("input[name='bib']").val(), format: "marcxml" },
function(data){
$(".publisher > span[class='label']:first").append("<a target='_blank' href='http://maps.google.com/maps?q=" + $(data).find("datafield[tag='260'] > subfield[code='a']").text().replace(/\W+$/, '') + "'><img src='/opac-tmpl/prog/famfamfam/MP.png' alt='Show publisher on map' title='Show publisher on map' /></a>");
}
);
Novelist
Duplicate Novelist readalikes into the right sidebar on opac-detail.pl
- Developer: Jason Robb (SEKLS)
- Purpose: Creates a brief preview of Novelist content on the right sidebar in opac-detail.pl to lure patrons down the page for full content.
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 3.22 (Requires Novelist Select subscription)
- Note: I could only get this to work with two separate document.ready clauses. You can see the intended result in my OPAC.
//Wrap this in the first $(document).ready()
$("#NovelistSelect").clone().prop({ id: "NovSidebar"}).appendTo("#ulactioncontainer"); //Duplicates Novelist content and adds it to the right side of the page
//Wrap this in the second $(document).ready()
$(window).load(function() {
if ($(".NovSimilarTitles").length) {
$("#NovSidebar h3").text("You might also like...");
$("#NovSidebar").append("<a href='#NovelistSelect' name='#NovelistSelect' id='MoreBelow'>See more recommendations</a>");
$('#MoreBelow').click(function(){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
return false;
});
} else {
$("#NovSidebar h3").hide();
$("#NovelistSelect h3").hide();
}
});
I adjusted some styles for a cleaner look. It hides much of the cloned content and formats what's left. The styles are somewhat specific to my OPAC so they'll likely need tweaked. This goes in the OPACUserCSS syspref.
#NovSidebar .NovSeriesInfo, #NovSidebar .NovSimilarSeries, #NovSidebar .NovSimilarAuthors, #NovSidebar .NovAppeals, #NovSidebar .NovGoodReads, #NovSidebar .NovLibraryAwareNewsletter, #NovSidebar .NoveResourceRecommendation, #NovSidebar .NovRelatedFeatures, #NovSidebar .NovLexileInfo, #NovSidebar em, .NovSimilarTitles > .NovSectionHeader, .NovSimilarTitles > .NovSectionBody > div {
display: none;
}
#NovSidebar > div {
margin-bottom: -75px;
}
#NovSidebar .NovSimilarTitles {
margin-top: -30px;
margin-bottom: 25px;
overflow-y: hidden;
padding-bottom: 0px;
}
#MoreBelow {
background: #fcb03f;
color: white;
display: block;
float: right;
font-size: medium;
font-variant: unicase;
font-weight: bolder;
margin-right: -208px;
margin-top: -145px;
padding: 10px 0 10px 46px;
transform: rotate(-90deg);
width: 290px;
transition: margin-top 0.5s ease;
}
#MoreBelow:hover {
margin-top: -135px;
}
OverDrive
Enhance OverDrive or similar resource counts on OPAC results
- Developer: Christopher Brannon (Coeur d'Alene Public Library / Cooperative Information Network)
- Purpose: Turns the OverDrive (or other resource) counts on the results page into a placard to draw more attention to this resource
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: 18.05
- Notes: The line with the DOMSubtreeModified reference was added to wait for the search to end before enhancing, in case there were no results.
//Enhance OverDrive results
$("body").on('DOMSubtreeModified', "#overdrive-results", function() {
$('#overdrive-results').css('padding-top','20px').wrap('<div id="overdrive-banner" style="padding-top: 20px;"><table width="100%" style="border: 1px solid black;"><tr><td style="background-color: lightyellow;"></td></tr></table></div>');
$('#overdrive-banner td').prepend('<img src="[LINK TO IMAGE]" width="150" style="float: left; padding-right: 20px;">');
});
//End OverDrive
Wikipedia
Add links out to Wikipedia for authors
- Developer: Stefano Bargioni (Pontificia Università della Santa Croce)
- Creation Date: 2014-02-14
- Purpose: Add a link for each author to bring the user to a Wikipedia search
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: all (tested in 3.12)
var names = $('h5.author a').not('.authlink');
for (var i=0; i < names.length; i++) {
var name_string = $(names[i]).text(); // mostly surname, name
var fs = (name_string+', ').split(', ');
var H = new Array;
H.push(' <span title="Search for this person in Wikipedia">');
H.push('<a target="_blank" href="https://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=');
H.push(encodeURIComponent(fs[1]+' '+fs[0]));
H.push('"><img src="https://upload.wikimedia.org/wikipedia/commons/b/b0/Wikipedia-favicon.png"/></a>');
H.push('</span>');
$(names[i]).after(H.join(''));
};
- Developer: Jared Camins-Esakov, C & P Bibliography Services
- Purpose: Add a link for each author to bring the user to a Wikipedia search [obsolete]
- Status: Completed
- Staff interface or OPAC?: OPAC
- Version: before 3.12
$("h5.author > a").each(function() {
$("<a href='http://en.wikipedia.org/wiki/Special:Search?search=" + encodeURI($(this).text().replace(/\[.*\]/g, '').replace(/[\W\d]+$/, '')) + "' title='Search for this person in Wikipedia'><img src='http://upload.wikimedia.org/wikipedia/commons/b/b0/Wikipedia-favicon.png'/></a>").insertAfter($(this));
});