Drupal.behaviors.roblib_search_evergreen = {
attach: function(context, settings) {
url = settings.roblib_search_evergreen.search_url;
jQuery.getJSON(url, function(data) {
var items = [];
var numberOfDocs = 0;
try {
numberOfDocs = data.numberOfRecords;
} catch (err) {
// do nothing leave docLength at 0
}
if(numberOfDocs < 1){
jQuery('#' + 'roblib-search-content-evergreen').empty().append('No Results');
jQuery('.pane-roblib-search-evergreen-roblib-search-evergreen-results').hide();
} else {
jQuery.each(data, function(key, val) {
items.push('
');
items.push('
');
if (typeof val.sor !== 'undefined') {
items.push('
' + val.sor +'
');
}
if (typeof val.date !== 'undefined') {
items.push('
' + val.date + '
')
}
if(typeof val.holdings !== 'undefined'){
items.push('
');
jQuery.each(val.holdings, function(key2, val2){
roblibEvergreenAddHoldings(val2, items);
})
items.push('
')
}
if(typeof val.electronic_holdings !== 'undefined'){
items.push('
');
jQuery.each(val.electronic_holdings, function(key2, val2){
roblibEvergreenAddElectronicHoldings(val2, items);
})
items.push('
')
}
items.push('
');
});
}
jQuery('#roblib-search-content-evergreen').empty().append(items.join(''));
jQuery('#roblib-search-evergreen-more').empty().append('See all ' + data.numberOfRecords + ' results');
});
}
}
function roblibEvergreenAddHoldings(holdings, items){
items.push('' + holdings.call_number + ' - ' + holdings.location +' (' + holdings.availability + ')
');
}
function roblibEvergreenAddElectronicHoldings(holdings, items){
items.push('');
}