ppound
3 years ago
5 changed files with 97 additions and 244 deletions
@ -1,85 +1,89 @@ |
|||||||
Drupal.behaviors.roblib_search_eds_articles = { |
Drupal.behaviors.roblib_search_eds_articles = { |
||||||
attach: function (context, settings) { |
attach: function (context, settings) { |
||||||
$url = settings.roblib_search_eds_articles.search_url; |
if (context == document) { |
||||||
articles_profile = settings.roblib_search_eds_articles.eds_profile; |
$query = $current_path.replace('roblib_search/', ''); |
||||||
proxy_url = "https://proxy.library.upei.ca/login?url="; |
$url = settings.eds_article_search_url + $query; |
||||||
jQuery.getJSON($url, function (data) { |
profile = settings.eds_article_profile; |
||||||
var items = []; |
proxy_url = "https://proxy.library.upei.ca/login?url="; |
||||||
var numberOfDocs = 0; |
jQuery.getJSON($url, function (data) { |
||||||
try { |
var items = []; |
||||||
numberOfDocs = data.numFound; |
var numberOfDocs = 0; |
||||||
} catch (err) { |
try { |
||||||
// do nothing leave docLength at 0
|
numberOfDocs = data.numFound; |
||||||
} |
} catch (err) { |
||||||
if (numberOfDocs < 1) { |
// do nothing leave docLength at 0
|
||||||
jQuery('#' + 'roblib-search-content-eds').empty().append('No Results'); |
} |
||||||
jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-articles').hide(); |
if (numberOfDocs < 1) { |
||||||
} else { |
jQuery('#' + 'roblib-search-content-eds').empty().append('No Results'); |
||||||
var counter = 0; |
jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-articles').hide(); |
||||||
var divs = new Array(); |
} else { |
||||||
var content = new Array(); |
var counter = 0; |
||||||
var queries = []; |
var divs = new Array(); |
||||||
jQuery.each(data.queries, function (key7, query) { |
var content = new Array(); |
||||||
queries.push(query.query); |
var queries = []; |
||||||
}) |
jQuery.each(data.queries, function (key7, query) { |
||||||
var query_str = encodeURI(data.queries[0].query); |
queries.push(query.query); |
||||||
var href_str = 'https://search.ebscohost.com/login.aspx?direct=true&site=eds-live&scope=site&type=1&custid=uprince&groupid=main&profile=eds&mode=bool&lang=en&bquery='; |
}) |
||||||
jQuery.each(data.documents, function (key, val) { |
var query_str = encodeURI(data.queries[0].query); |
||||||
id = 'roblib-search-eds-article-' + counter; |
var href_str = 'https://search.ebscohost.com/login.aspx?direct=true&site=eds-live&scope=site&type=1&custid=uprince&groupid=main&profile=eds&mode=bool&lang=en&bquery='; |
||||||
divs[counter++] = id; |
jQuery.each(data.documents, function (key, val) { |
||||||
|
id = 'roblib-search-eds-article-' + counter; |
||||||
|
divs[counter++] = id; |
||||||
|
|
||||||
if (typeof val.Items !== 'undefined') { |
if (typeof val.Items !== 'undefined') { |
||||||
items.push('<div class ="roblib-search-row" id="' + id + '">'); |
items.push('<div class ="roblib-search-row" id="' + id + '">'); |
||||||
if (typeof val.Items.Title !== 'undefined') { |
if (typeof val.Items.Title !== 'undefined') { |
||||||
items.push('<div class="roblib-title eds">'); |
items.push('<div class="roblib-title eds">'); |
||||||
items.push('<a href="' + proxy_url + val.PLink + '&scope=site">' + val.Items.Title.Data + '</a></div>'); |
items.push('<a href="' + proxy_url + val.PLink + '&scope=site">' + val.Items.Title.Data + '</a></div>'); |
||||||
} |
} |
||||||
pubType = val.PubType; |
pubType = val.PubType; |
||||||
|
|
||||||
pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"]; |
pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"]; |
||||||
!pubYear ? pubYear = " " : pubYear = pubYear[0]["Y"]; |
!pubYear ? pubYear = " " : pubYear = pubYear[0]["Y"]; |
||||||
|
|
||||||
items.push('<div class="eds-type"><span class="eds-pubyear">' + pubYear + '</span> - ' + pubType + '</div>'); |
items.push('<div class="eds-type"><span class="eds-pubyear">' + pubYear + '</span> - ' + pubType + '</div>'); |
||||||
|
|
||||||
|
|
||||||
var roblib_authors = []; |
var roblib_authors = []; |
||||||
jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function (key3, author) { |
jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function (key3, author) { |
||||||
roblib_authors.push(author.NameFull); |
roblib_authors.push(author.NameFull); |
||||||
}) |
}) |
||||||
|
|
||||||
items.push('<div class="eds-sor">'); |
items.push('<div class="eds-sor">'); |
||||||
roblib_authors = roblib_shorten(roblib_authors.join('; '), 50, " "); |
roblib_authors = roblib_shorten(roblib_authors.join('; '), 50, " "); |
||||||
items.push(roblib_authors); |
items.push(roblib_authors); |
||||||
items.push('</div>'); |
items.push('</div>'); |
||||||
|
|
||||||
|
|
||||||
if (typeof val.Items.TitleSource !== 'undefined') { |
if (typeof val.Items.TitleSource !== 'undefined') { |
||||||
items.push('<div class="eds-src"><span class="eds-label">In:</span> ' + val.Items.TitleSource.Data + '</div>'); |
items.push('<div class="eds-src"><span class="eds-label">In:</span> ' + val.Items.TitleSource.Data + '</div>'); |
||||||
} |
} |
||||||
if (typeof val.PLink !== 'undefined' && typeof val.PDF !== 'undefined' && val.PDF == 'pdflink') { |
if (typeof val.PLink !== 'undefined' && typeof val.PDF !== 'undefined' && val.PDF == 'pdflink') { |
||||||
items.push('<div class="eds-db eds-pdf-link"><a href="' + proxy_url + val.PLink + '&scope=site">PDF Full Text</a></div>'); |
items.push('<div class="eds-db eds-pdf-link"><a href="' + proxy_url + val.PLink + '&scope=site">PDF Full Text</a></div>'); |
||||||
} |
} |
||||||
if (typeof val.PLink !== 'undefined' && typeof val.HTML !== 'undefined' && val.HTML == '1') { |
if (typeof val.PLink !== 'undefined' && typeof val.HTML !== 'undefined' && val.HTML == '1') { |
||||||
items.push('<div class="eds-db eds-pdf-link"><a href="' + proxy_url + val.PLink + '&scope=site">HTML Full Text</a></div>'); |
items.push('<div class="eds-db eds-pdf-link"><a href="' + proxy_url + val.PLink + '&scope=site">HTML Full Text</a></div>'); |
||||||
} |
} |
||||||
|
|
||||||
items.push('</div>'); |
items.push('</div>'); |
||||||
} else { |
} else { |
||||||
items.push('<div class ="roblib-search-row roblib-eds-unauthorized" id="\' + id + \'">You must login to view this result, <a href="https://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-unauthorized-result">click here to login</a></div>' );} |
items.push('<div class ="roblib-search-row roblib-eds-unauthorized" id="\' + id + \'">You must login to view this result, <a href="https://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-unauthorized-result">click here to login</a></div>'); |
||||||
}); |
} |
||||||
jQuery('#' + 'roblib-search-content-eds-articles').empty().append(items.join('')); |
}); |
||||||
} |
jQuery('#' + 'roblib-search-content-eds-articles').empty().append(items.join('')); |
||||||
var non_upei_link = ''; |
} |
||||||
var upei_link = '<a href="' + proxy_url + href_str + query_str + '" id="eds-article-see-all-results">SEE ALL (' + data.recordCount + ')</a> '; |
var non_upei_link = ''; |
||||||
if(!data.is_local_ip) { |
var upei_link = '<a href="' + proxy_url + href_str + query_str + '" id="eds-article-see-all-results">SEE ALL (' + data.recordCount + ')</a> '; |
||||||
non_upei_link = '<a href="' + href_str + query_str + '&authtype=ip,guest" id="eds-article-non-upei-see_all_results">[Non-UPEI]</a>'; |
if (!data.is_local_ip) { |
||||||
upei_link = upei_link + non_upei_link; |
non_upei_link = '<a href="' + href_str + query_str + '&authtype=ip,guest" id="eds-article-non-upei-see_all_results">[Non-UPEI]</a>'; |
||||||
} |
upei_link = upei_link + non_upei_link; |
||||||
jQuery('#roblib-search-eds-article-more').empty().append(upei_link); |
} |
||||||
jQuery('#roblib-eds-articles-more-results').empty().append(upei_link); |
jQuery('#roblib-search-eds-article-more').empty().append(upei_link); |
||||||
jQuery('#roblib-eds-articles-toc').empty().append('<a href="' + proxy_url + href_str + query_str + '" id="eds-article-see-all-results-toc">Articles (' + data.recordCount + ')</a>'); |
jQuery('#roblib-eds-articles-more-results').empty().append(upei_link); |
||||||
|
jQuery('#roblib-eds-articles-toc').empty().append('<a href="' + proxy_url + href_str + query_str + '" id="eds-article-see-all-results-toc">Articles (' + data.recordCount + ')</a>'); |
||||||
|
|
||||||
}); |
}); |
||||||
} |
} |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
|
@ -1,60 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/* |
|
||||||
* all we do here is pass a url to some javascript so the results can be |
|
||||||
* loaded async |
|
||||||
*/ |
|
||||||
|
|
||||||
// TODO: combine these two functions and call this function from the preprocessor |
|
||||||
|
|
||||||
function roblib_search_eds_preprocess_roblib_search_eds(&$variables) { |
|
||||||
/*global $base_url; |
|
||||||
if (!isset($query)) { |
|
||||||
if (isset($_GET['roblib_query'])) { |
|
||||||
$query = $_GET['roblib_query']; |
|
||||||
} |
|
||||||
else { |
|
||||||
return ''; |
|
||||||
} |
|
||||||
} |
|
||||||
$spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/' . 'spinner.gif'; |
|
||||||
$variables['spinner_path'] = $spinner_path; |
|
||||||
$search_url = $base_url . '/roblib_search/eds/ajax/' . urlencode($query); |
|
||||||
drupal_add_js(drupal_get_path('module', 'roblib_search_eds') . '/js/eds_results.js'); |
|
||||||
drupal_add_js(array( |
|
||||||
'roblib_search_eds' => array( |
|
||||||
'search_url' => $search_url, |
|
||||||
'eds_profile' => |
|
||||||
variable_get('roblib_search_eds_book_profile', 'apilite') |
|
||||||
) |
|
||||||
), array('type' => 'setting')); |
|
||||||
* */ |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
function roblib_search_eds_preprocess_roblib_search_eds_articles(&$variables) { |
|
||||||
global $base_url; |
|
||||||
if (!isset($query)) { |
|
||||||
if (isset($_GET['roblib_query'])) { |
|
||||||
$query = $_GET['roblib_query']; |
|
||||||
} |
|
||||||
else { |
|
||||||
return ''; |
|
||||||
} |
|
||||||
} |
|
||||||
$spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/' . 'spinner.gif'; |
|
||||||
$variables['spinner_path'] = $spinner_path; |
|
||||||
$search_url = $base_url . '/roblib_search/eds/articles/' . urlencode($query); |
|
||||||
drupal_add_js(drupal_get_path('module', 'roblib_search_eds') . '/js/eds_results_article.js'); |
|
||||||
drupal_add_js(array( |
|
||||||
'roblib_search_eds_articles' => array( |
|
||||||
'search_url' => $search_url, |
|
||||||
'eds_profile' => |
|
||||||
variable_get('roblib_search_eds_profile', 'edsapi') |
|
||||||
) |
|
||||||
), array('type' => 'setting')); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
?> |
|
Loading…
Reference in new issue