You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
4.6 KiB
100 lines
4.6 KiB
11 years ago
|
Drupal.behaviors.roblib_search_islandscholar = {
|
||
8 years ago
|
attach: function (context, settings) {
|
||
11 years ago
|
url = settings.roblib_search_islandscholar.search_url;
|
||
8 years ago
|
jQuery.getJSON(url, function (data) {
|
||
11 years ago
|
var items = [];
|
||
|
var numberOfDocs = 0;
|
||
|
try {
|
||
|
numberOfDocs = data.response.docs.length;
|
||
|
} catch (err) {
|
||
|
// do nothing leave docLength at 0
|
||
|
}
|
||
|
if (numberOfDocs < 1) {
|
||
|
jQuery('#' + 'roblib-search-content-islandscholar').empty().append('No Results');
|
||
11 years ago
|
jQuery('.' + 'pane-roblib-search-islandscholar-roblib-islandscholar-results').hide();
|
||
11 years ago
|
} else {
|
||
11 years ago
|
var counter = 0;
|
||
|
var divs = new Array();
|
||
|
var content = new Array();
|
||
8 years ago
|
jQuery.each(data.response.docs, function (key, val) {
|
||
11 years ago
|
id = 'roblib-search-islandscholar-' + counter;
|
||
11 years ago
|
content[counter] = '';
|
||
8 years ago
|
if (typeof val['mods_abstract_s'] !== 'undefined') {
|
||
|
content[counter] = val['mods_abstract_s'][0];
|
||
10 years ago
|
} else {
|
||
|
content[counter] = 'No abstract available';
|
||
11 years ago
|
}
|
||
|
divs[counter++] = id;
|
||
|
items.push('<div class ="roblib-search-row" id="' + id + '">\n\
|
||
11 years ago
|
<div class="roblib-title islandscholar">\n\
|
||
8 years ago
|
<a href="http://www.islandscholar.ca/fedora/repository/' + val.PID + '">' + val['dc.title'] + '</a></div>');
|
||
11 years ago
|
try {
|
||
8 years ago
|
items.push('<div class="islandscholar-authors">');
|
||
|
jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) {
|
||
|
items.push('<span class="islandscholar-author">' + val2 + ';</span> ')
|
||
|
})
|
||
|
items.push('</div>')
|
||
|
} catch (e) {
|
||
11 years ago
|
|
||
|
}
|
||
|
|
||
8 years ago
|
items.push('<div class="islandscholar-source">');
|
||
|
|
||
|
|
||
|
if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-hostTitle">' + val.mods_relatedItem_host_titleInfo_title_s + '</span> ')
|
||
|
}
|
||
|
|
||
|
|
||
|
if (typeof val.mods_canonical_date_issued_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-citation">' + val.mods_canonical_date_issued_s + '</span> ')
|
||
|
}
|
||
|
|
||
|
|
||
|
if (typeof val.mods_part_detail_volume_number_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-citation">Vol. </span><span class="islandscholar-citation">' + val.mods_part_detail_volume_number_s + '</span> ')
|
||
|
}
|
||
11 years ago
|
|
||
8 years ago
|
|
||
|
if (typeof val.mods_part_detail_issue_number_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-citation">Issue </span><span class="islandscholar-citation">' + val.mods_part_detail_issue_number_s + ',</span> ')
|
||
|
}
|
||
|
|
||
|
|
||
|
if (typeof val.mods_part_extent_start_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-citation">p</span><span class="islandscholar-citation">' + val.mods_part_extent_start_s + '</span>')
|
||
|
}
|
||
|
|
||
|
|
||
|
if (typeof val.mods_part_extent_end_s !== 'undefined') {
|
||
|
items.push('<span class="islandscholar-citation">-</span><span class="islandscholar-citation">' + val.mods_part_extent_end_s + ',</span>')
|
||
11 years ago
|
}
|
||
8 years ago
|
|
||
|
if (typeof val.mods_genre_s !== 'undefined') {
|
||
|
items.push('<div class="islandscholar-label">' + val.mods_genre_s + '</div> ');
|
||
|
}
|
||
|
|
||
|
if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) {
|
||
|
items.push('<div>full text</div>');
|
||
|
}
|
||
|
|
||
|
items.push('</div>');
|
||
|
|
||
11 years ago
|
items.push('</div>');
|
||
|
});
|
||
|
|
||
11 years ago
|
|
||
11 years ago
|
jQuery('#roblib-search-content-islandscholar').empty().append(items.join(''));
|
||
11 years ago
|
qtipify(divs, content, 'Abstract');
|
||
11 years ago
|
var number = data.response.numFound;
|
||
|
var query = encodeURIComponent(data.responseHeader.params.q);//.'milk';
|
||
|
jQuery('#roblib-search-islandscholar-more').empty().append('<a id="islandscholar-see-more-result"' +
|
||
8 years ago
|
' href="http://www.islandscholar.ca/islandora/search/' + query + '?type=dismax">see all results</a>');
|
||
11 years ago
|
|
||
11 years ago
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|