Browse Source

started on formating eds book search results

2.x-ebsco
Paul Pound 7 years ago
parent
commit
bf71832881
  1. 1
      js/jquery.arrayUtilities.min.js
  2. 2
      roblib_search.module
  3. 59
      targets/eds/js/eds_results.js
  4. 1
      targets/eds/js/eds_results_article.js

1
js/jquery.arrayUtilities.min.js vendored

@ -0,0 +1 @@
(function(e){var t={};var n=function(e){for(var t=0;t<e.length;t++){if(!(e[t]instanceof Array)){throw new Error("Every argument must be an array!")}}};t.distinct=function(t){if(arguments.length!=1)throw new Error("There must be exactly 1 array argument!");n(arguments);var r=[];for(var i=0;i<t.length;i++){var s=t[i];if(e.inArray(s,r)===-1){r.push(s)}}return r};t.union=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=this.distinct(arguments[0]);for(var r=1;r<arguments.length;r++){var i=arguments[r];for(var s=0;s<i.length;s++){var o=i[s];if(e.inArray(o,t)===-1){t.push(o)}}}return t};t.intersect=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=[];var r=this.distinct(arguments[0]);if(r.length===0)return[];for(var i=0;i<r.length;i++){var s=r[i];var o=true;for(var u=1;u<arguments.length;u++){var a=arguments[u];if(a.length==0)return[];if(e.inArray(s,a)===-1){o=false;break}}if(o){t.push(s)}}return t};t.except=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=[];var r=this.distinct(arguments[0]);var i=[];for(var s=1;s<arguments.length;s++){var o=arguments[s];i=i.concat(o)}for(var s=0;s<r.length;s++){var u=r[s];if(e.inArray(u,i)===-1){t.push(u)}}return t};e.arrayUtilities=t;e.distinct=t.distinct;e.union=t.union;e.intersect=t.intersect;e.except=t.except})(jQuery)

2
roblib_search.module

@ -214,8 +214,6 @@ function roblib_search_preprocess_panels_pane(&$variables, $hook){
* Implements hook_init().
*/
function roblib_search_init() {
// Make qtip available for all targets js.
drupal_add_js(drupal_get_path('module', 'roblib_search') . '/js/jquery.qtip.min.js');
drupal_add_js(drupal_get_path('module', 'roblib_search') . '/js/imagesloaded.pkg.min.js');
drupal_add_js(drupal_get_path('module', 'roblib_search') . '/js/roblib_search.js');
drupal_add_css(drupal_get_path('module', 'roblib_search') . '/css/jquery.qtip.min.css');

59
targets/eds/js/eds_results.js

@ -19,7 +19,6 @@ Drupal.behaviors.roblib_search_eds = {
var content = new Array();
jQuery.each(data.records, function(key, val) {
id = 'roblib-search-eds-' + counter;
edsPopulatePopupDivs(content, val, counter);
divs[counter++] = id;
if (typeof val.Items !== 'undefined') {
items.push('<div class ="roblib-search-row" id="' + id + '">');
@ -29,10 +28,24 @@ Drupal.behaviors.roblib_search_eds = {
items.push('<a href="http://proxy.library.upei.ca/login?url='+val.PLink+'&scope=site">'+val2.Data+'</a></div>');
})
}
pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"][0]["Y"];
if(pubYear == 'undefined') {
pubYear = "Unknown";
}
if (typeof val.Items.TypPub !== 'undefined') {
jQuery.each(val.Items.TypPub, function(key6, typpub){
strs = typpub.Data.split('; ');
types = roblib_intersects(strs, ['<span class="highlight">Book</span>', '<span class="highlight">eBook</span>']);
items.push('<div class="eds-type"><span class="eds-pubyear">'+pubYear+'</span> - '+ types.join(', ') + '</div>');
})
}
items.push('<div class="eds-sor">');
jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function(key3, authors){
items.push(authors.NameFull+';'+' ');
roblib_authors = "";
jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function(key3, author){
roblib_authors += author.NameFull;
})
roblib_authors = roblib_shorten(roblib_authors, 50, " ");
items.push(roblib_authors);
items.push('</div>');
if (typeof val.Items.Src !== 'undefined') {
jQuery.each(val.Items.Src, function(key4, source){
@ -44,11 +57,6 @@ Drupal.behaviors.roblib_search_eds = {
items.push('<div class="eds-pubinfo">'+pubinfo.Data+'</div>');
})
}
if (typeof val.Items.TypPub !== 'undefined') {
jQuery.each(val.Items.TypPub, function(key6, typpub){
items.push('<div class="eds-type"><span class="eds-label">'+typpub.Label+'</span>: '+typpub.Data+'</div>');
})
}
items.push('<div class="eds-db">'+val.DbLabel+'</div>');
@ -72,27 +80,22 @@ Drupal.behaviors.roblib_search_eds = {
}
}
function edsPopulatePopupDivs(content, val, counter){
content[counter] = '';
try{
jQuery.each(val.DetailedRecord, function(key, value){
if (content.length < 5 &&
(value.Group == 'PubInfo' || value.Group =="TypPub" || value.Group == "TypeDoc" || value.Group =="Su" || value.Group == "Au")) {
content[counter] += '<div class="eds-popup-content"><span class="eds-popup-label">' + value.Label + ': </span>' ;
content[counter] += '<span class="eds-popup-value"> ' + value.Data +'</span></div>';(value.Group =='Ab' || value.Group == 'Note' )
} else if (content[counter].length < 5 && (value.Group == "Note" || value.Group== "Ab")) {
content[counter] += '<div class="eds-popup-content"><span class="eds-popup-label">' + value.Label + ': </span>' ;
content[counter] += '<span class="eds-popup-value"> ' + value.Data +'</span></div>';
} else if (content[counter].length < 3 && (value.Group == 'TOC' || value.Group == 'Src')) {
content[counter] += '<div class="eds-popup-content"><span class="eds-popup-label">' + value.Label + ': </span>' ;
content[counter] += '<span class="eds-popup-value"> ' + value.Data +'</span></div>';
} else if (content[counter].length < 1 && value.Group == 'Ti') {
content[counter] += '<div class="eds-popup-content"><span class="eds-popup-label">' + value.Label + ': </span>' ;
content[counter] += '<span class="eds-popup-value"> ' + value.Data +'</span></div>';
function roblib_intersects(a, b) {
var d = {};
var results = [];
for (var i = 0; i < b.length; i++) {
d[b[i]] = true;
}
})
} catch (err) {
// do nothing as there is no data to work with
for (var j = 0; j < a.length; j++) {
if (d[a[j]])
results.push(a[j]);
}
return results;
}
function roblib_shorten(str, maxLen, separator) {
if (str.length <= maxLen) return str;
return str.substr(0, str.lastIndexOf(separator, maxLen)) + ' et al.';
}

1
targets/eds/js/eds_results_article.js

@ -19,7 +19,6 @@ Drupal.behaviors.roblib_search_eds_articles = {
var content = new Array();
jQuery.each(data.records, function(key, val) {
id = 'roblib-search-eds-article-' + counter;
edsPopulatePopupDivs(content, val, counter);
divs[counter++] = id;
if (typeof val.Items !== 'undefined') {

Loading…
Cancel
Save