Drupal.behaviors.roblib_search_cufts = {
attach: function(context, settings) {
url = settings.roblib_search_cufts.search_url;
jQuery.getJSON(url, function(data) {
var items = [];
var numberOfDocs = 0;
try {
numberOfDocs = data.journals.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-cufts').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-cufts-roblib-search-cufts-results').hide();
} else {
var counter = 0;
var divs = new Array();
var content = new Array();
jQuery.each(data.journals, function(key, val) {
id = 'roblib_cufts_results_' + counter;
content[counter] = "";
divs[counter] = id;
var item_str = '
';
item_str += '
';
item_str += '
';
items.push(item_str);
jQuery.each(val.fulltext_coverages, function(key3, val3) {
if(typeof val3 !== 'undefined' && val3 != null ){
content[counter] += '' + val3 + "
";
}
});
jQuery.each(val["links"], function(key4, val4) {
if(typeof val4.print_coverage !== 'undefined' && val4.print_coverage != null ){
content[counter] += '' + val4.print_coverage + "
";
}
});
counter++;
});
jQuery('#' + 'roblib-search-content-cufts').empty().append(items.join(''));
qtipify(divs, content, 'Coverage');
}
var originURL = settings.roblib_search_cufts.url;
var originSuffix = settings.roblib_search_cufts.suffix;
var newSuffix = originSuffix.replace("&format=json", "");
if (parseInt(data.numOfResults) > 0)
{
jQuery('#' + 'roblib-search-cufts-more').empty().append('see all ' + data.numOfResults + ' results');
}
else
{
jQuery('#' + 'roblib-search-content-cufts').empty().append('no result
');
jQuery('#' + 'roblib-search-cufts-more').empty();
}
});
}
}