// load Library Thing scripts
loadScriptLTFL();
// retrieve policies
getPolicies();
// wait for document to be ready then
jQuery(document).ready(function () {
// call functions based on what page is displayed
var pageURL = jQuery(location).attr('href');
// kids catalog
if (pageURL.indexOf("/client/school/") >= 0) {
kidscatalog(pageURL);
}
// login page or box
if (pageURL.indexOf("patronlogin") >= 0) {
patronLogin();
// my account pages
} else if (pageURL.indexOf("search/account") >= 0) {
myAccount();
// reserves results page
} else if (pageURL.indexOf("results/results") >= 0) {
setTimeout("reservesResults();", 500);
// reserves detail page
} else if (pageURL.indexOf("federateddetailnonmodal") >= 0) {
reservesDetail();
// search results page
} else if (pageURL.indexOf("results") >= 0) {
searchResults();
// my lists page
} else if (pageURL.indexOf("mylists") >= 0) {
searchResults();
// detail display page
} else if (pageURL.indexOf("search/detailnonmodal") >= 0) {
detailDisplay();
}
});
function patronLogin() {
// insert PIN info and contact link based on profile
var theProfile = jQuery(location).attr('href').split('/')[4];
var theLabel = 'What\'s my PIN?';
var theURL = '';
if (theProfile == 'testy') {
theURL = 'http://consortiumlibrary.org/services/library_account.php';
} else if (theProfile == 'apl') {
theURL = 'http://libguides.anchoragelibrary.org/MyAccount';
} else if (theProfile == 'uaa') {
theURL = 'http://consortiumlibrary.org/services/library_account.php';
}
if (theURL != '') {
jQuery('input.loginButton').after('
' + theLabel + ' ');
}
}
function myAccount() {
// replace the bad title links on the page
jQuery('a.detailLink').each(function () {
var theLabel = jQuery(this).text();
var theURL = jQuery(this).attr('href');
theURL = theURL.replace(/account\.checkouts\.checkoutslist\.detaillink\.detailclick\/\d+/g, 'detailnonmodal');
theURL = theURL.replace(/account\.fines\.personal\.detaillink\.detailclick\/\d+/g, 'detailnonmodal');
theURL = theURL.replace(/account\.holds\.holdslist\.detaillink\.detailclick\/\d+/g, 'detailnonmodal');
jQuery(this).after('' + theLabel + '');
jQuery(this).text('');
});
}
function reservesResults() {
//Change title links so they open in new window
jQuery('div.federatedDetailLink .displayElementText a').each(function () {
jQuery(this).attr("target", "_blank");
});
}
function reservesDetail() {
// find first item number
var itemBarcode = jQuery('table.detailItemTable td:first').text();
// use item barcode to retieve catkey because enterpise is to stupid to give it to us by default
jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/standard/lookupTitleInfo?clientID=DS_CLIENT&itemID=' + itemBarcode + '&includeItemInfo=true&json=true&callback=?', function (data) {
var catKey = data.TitleInfo[0].titleID;
//if there is a catkey, open new window to detail display
if (catKey) {
var theURL = jQuery(location).attr('href').split('federateddetailnonmodal/')[0] + 'results?qu=%22' + catKey + '%22';
jQuery('div#nm_federated_detail_wrapper').text('Redirecting...');
window.location.replace(theURL);
} else {
jQuery('div#nm_federated_detail_wrapper').text('This record is shadowed and cannot be displayed in the library catalog.');
}
});
}
function searchResults() {
//var availTitle = jQuery('#onlyAvailableForm .button').attr('title');
//jQuery('#onlyAvailableForm .button').attr('value', '');
//if (availTitle.indexOf("only") >= 0) {
//} else {
//jQuery('#onlyAvailableForm .button').css('background-image', 'url(http://consortiumlibrary.org/assets/images/buttons/on.jpg)');
//}
// loop through dom for each item in results
jQuery('div.cell_wrapper').each(function () {
thisResult = jQuery(this);
// cleanup citations
cleanupResults(thisResult);
// display holdings
showHoldingsResults(thisResult);
});
// cleanup the 856 field
cleanup856();
}
function detailDisplay() {
// cleanup citations
cleanupDetail();
// format 856 field
cleanup856();
// display marc bib fields
getMarcBiblio();
// display holdings
showHoldingsDetail();
}
function showHoldingsResults(thisResult) {
// get the profile name
var theProfile = getProfile();
// get the url to the detail display
var detailURL = jQuery(thisResult).find('.displayDetailLink a').attr('href');
// get the catKey from the detail url
var catKey = detailURL.split('SD_ILS:')[1].split('/')[0];
// insert a detail display link on search results as default in case json call fails
jQuery(thisResult).find('div.results_bio').append('
DUMP
'+thisDump); // loop through copyInfo array returned by json jQuery.each(copyInfo, function (i, value) { // get library description var LibraryDesc = ''; if (this.libraryID && (LibraryList != "")) { LibraryDesc = getDescription(this.libraryID, LibraryList); } else if (this.libraryID) { LibraryDesc = this.libraryID; } // get call number var callInfo = ''; if (this.callNumber) { callInfo = this.callNumber; } if (this.ItemInfo) { // loop through itemInfo array returned by json jQuery.each(value.ItemInfo, function () { // get home location var HomeLocDesc = ''; if (this.homeLocationID && (LocationList != "")) { HomeLocDesc = getDescription(this.homeLocationID, LocationList); } else if (this.homeLocationID) { HomeLocDesc = this.homeLocationID; } // get current location var CurrentLocDesc = ''; if (this.currentLocationID && (LocationList != "")) { CurrentLocDesc = getDescription(this.currentLocationID, LocationList); } else if (this.currentLocationID) { CurrentLocDesc = this.currentLocationID; } // get item type var ItemTypeDesc = ''; if (this.itemTypeID && (ItemTypeList != "")) { ItemTypeDesc = getDescription(this.itemTypeID, ItemTypeList); } else if (this.itemTypeID) { ItemTypeDesc = this.itemTypeID; } // replace some annoying labels from Symphony policies with Enterprise friendly ones LibraryDesc = cleanupLibraryDesc(HomeLocDesc, LibraryDesc); HomeLocDesc = cleanupLocDesc(HomeLocDesc); ItemTypeDesc = cleanupItemTypeDesc(ItemTypeDesc); CurrentLocDesc = cleanupLocDesc(CurrentLocDesc); // get public note if it exists var itemNote = ''; if (this.publicNote) { itemNote = ' (' + this.publicNote + ')'; } // create status if current and home location are not equal // if current location is reserves make status blank var itemStatus = ''; if (CurrentLocDesc != HomeLocDesc) { itemStatus = '--' + CurrentLocDesc; } if (CurrentLocDesc.indexOf("Reserve") >= 0) { itemStatus = ''; } // for APL libraries, make general collection location blank if ((HomeLocDesc.indexOf("General Collection") >= 0) && (LibraryDesc.indexOf("APL") >= 0)) { HomeLocDesc = ''; } // get due date and add to status, format date differently if reserves (not yet implemented) if ((this.dueDate) && (HomeLocDesc.indexOf("Reserve") >= 0)) { var date = new Date(this.dueDate); itemStatus = '--Due ' + (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() + ', ' + date.getHours() + ':' + date.getMinutes(); } else if ((this.dueDate) && (CurrentLocDesc.indexOf("Reserve") >= 0)) { var date = new Date(this.dueDate); itemStatus = '--Due ' + (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear() + ', ' + date.getHours() + ':' + date.getMinutes(); } else if (this.dueDate) { var date = new Date(this.dueDate); itemStatus = '--Due ' + (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); } //check for local holds if (holdableCopies.indexOf("yes") < 0) { if (ItemTypeDesc.indexOf("local hold only") >= 0) { if (LibraryDesc.indexOf(theProfile) >= 0) { holdableCopies = "yes local"; } else { holdableCopies = "no local"; } } else { holdableCopies = "yes"; } } // build line of item holdings info // the span element will be hidden in css but is there so later we can sort lines by location even though they will begin with call number in display var thisLine = 'Online access
'); } else { jQuery('.856_' + catKey).parent().hide(); } // if there are copies if ((itemsArrayTop.length != 0) || (itemsArray.length != 0)) { // convert arrays to string output var itemsOutput = itemsArrayTop.join("\n"); itemsOutput += itemsArray.join("\n"); var pageURL = jQuery(location).attr('href'); // if on detail display if (pageURL.indexOf("search/detailnonmodal") > 0) { // if this is a bound to copy just add row to existing copy table if (boundTo != "no") { jQuery('#table_' + boundTo).append(itemsOutput); // otherwise build a normal copy table } else { itemsOutput = 'Call # | Location | Material |
---|
Call # | Location | Material |
---|
Holdable: '+holdableCopies+'
'); if (holdableCopies.indexOf("no") >= 0) { jQuery('#holdSpan' + catKey).remove(); jQuery('.detailActions .holdButton').remove(); } // end ajax call }); } function getMarcHoldings(catKey, theProfile) { jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/standard/lookupTitleInfo?clientID=DS_CLIENT&titleID=' + catKey + '&includeMarcHoldings=true&marcEntryFilter=full&json=true&callback=?', function (data) { // create list for holdings var holdingsArray = []; // list for holdings at local library or group of libraries (based on profile) var holdingsArrayTop = []; // jump to holdings array returned by json holdingsInfo = data.TitleInfo[0].MarcHoldingsInfo; // loop through copyInfo array returned by json jQuery.each(holdingsInfo, function (i, value) { // get library description var LibraryDesc = getDescription(this.holdingLibraryID, LibraryList); LibraryDesc = cleanupLibraryDesc('Null', LibraryDesc); var thisLine = 'Serial holdings
' + holdingsOutput); jQuery('#checklink_' + catKey).remove(); // hide default holdings display jQuery('h3.ui-accordion-header').not('h3.orders_header').hide(); jQuery('div.detailItems').hide(); jQuery('div#detailAvailableDiv0').css("border", "none"); jQuery('div#detailAvailableDiv0').css("float", "left"); // otherwise on search results } else { // remove Less... link to hide item copies // insert & hide the Less.. link to hide serial holdigns jQuery('#lesslink_' + catKey).remove(); jQuery('#copies_' + catKey).append(''); jQuery('#lesslink_' + catKey).hide(); // insert serial holdings jQuery('#copies_' + catKey).append('Serial holdings
' + holdingsOutput); jQuery('#checklink_' + catKey).remove(); // move item table below serials and hide item table jQuery('#table_' + catKey).appendTo('#copies_' + catKey); jQuery('#table_' + catKey).addClass("hideholdings"); // insert More... link jQuery('#morelink_' + catKey).remove(); jQuery('#copies_' + catKey).append(''); // Hide additional serial holdings after first jQuery('#copies_' + catKey + ' div.holdings:not(:first)').addClass("hideholdings"); jQuery('#copies_' + catKey + ' div.nest').addClass("hideholdings"); } } // end ajax call }); } function moreCopies(catKey) { // executed when you click on the More Copies link // show the hidden copies // insert a Hide copies link // the style overflow visible part is to fix css problem in ie8 jQuery('#copies_' + catKey + ' div').removeClass("hideholdings"); jQuery('#copies_' + catKey + ' table').removeClass("hideholdings"); jQuery('#copies_' + catKey + ' tr').removeClass("hideholdings"); jQuery('#lesslink_' + catKey).show(); jQuery('#morelink_' + catKey).hide(); jQuery('div.cell_wrapper').attr("style", "overflow:visible/0;"); return false; } function hideCopies(catKey) { // executed when you click on the Hide Copies link // hide the additional copies // insert a More ... link // the style overflow visible part is to fix css problem in ie8 jQuery('#copies_' + catKey + ' tr:nth-child(n+3)').addClass("hideholdings"); jQuery('#morelink_' + catKey).show(); jQuery('#lesslink_' + catKey).hide(); jQuery('div.cell_wrapper').attr("style", "overflow:auto/0;"); return false; } function hideHoldings(catKey) { //executed when you click on the Hide Holdings link // hide all item copies & hide additional serial holdings // insert a More ... link // the style overflow visible part is to fix css problem in ie8 jQuery('#copies_' + catKey + ' table').addClass("hideholdings"); jQuery('#copies_' + catKey + ' div.holdings:not(:first)').addClass("hideholdings"); jQuery('#copies_' + catKey + ' div.nest').addClass("hideholdings"); jQuery('#morelink_' + catKey).show(); jQuery('#lesslink_' + catKey).hide(); jQuery('div.cell_wrapper').attr("style", "overflow:auto/0;"); return false; } function getMarcBiblio() { var pageURL = jQuery(location).attr('href'); var catKey = pageURL.split('SD_ILS:')[1].split('/')[0]; // json call to web services api and loop through results jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/standard/lookupTitleInfo?clientID=DS_CLIENT&titleID=' + catKey + '&includeOPACInfo=false&marcEntryFilter=all&json=true&callback=?', function (data) { // jump to biblio info array returned by json bibInfo = data.TitleInfo[0].BibliographicInfo.MarcEntryInfo; holdingsInfo = data.TitleInfo[0].MarcHoldingsInfo; var thisOutput = ''; thisOutput += 'MARC
'+marcOutput); alert(marcOutput); }); } function getPolicies() { // json calls to to retrieve location, library and item type policies LocationList = ""; LibraryList = ""; ItemTypeList = ""; jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/admin/lookupLocationPolicyList?clientID=DS_CLIENT&json=true&callback=?', function (data) { LocationList = data.policyInfo; }); jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/admin/lookupLibraryPolicyList?clientID=DS_CLIENT&json=true&callback=?', function (data) { LibraryList = data.policyInfo; }); jQuery.getJSON('http://jlc-web.uaa.alaska.edu:8080/symws/rest/admin/lookupItemTypePolicyList?clientID=DS_CLIENT&json=true&callback=?', function (data) { ItemTypeList = data.policyInfo; }); } function getDescription(thisID, thisPolicy) { // routine to retrieve descriptive labels from policy var thisDescription = ''; for (var i = 0; i < thisPolicy.length; i++) { if (thisPolicy[i].policyID == thisID) { return thisPolicy[i].policyDescription; break; } } return thisID; } function cleanupHoldingsDesc(thisHoldings) { // replace some annoying labels from Symphony policies with Enterprise friendly ones thisHoldings = thisHoldings.replace(/\