From 57918136e84ab7afe7ed9166700ea40de38a0438 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 18 Jul 2017 13:52:07 -0300 Subject: [PATCH] reformatted code and started work on formatting eds article results --- targets/eds/js/eds_results.js | 15 +-- targets/eds/js/eds_results_article.js | 136 +++++++++++++------------- 2 files changed, 74 insertions(+), 77 deletions(-) diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index c2b8816..ab1bcf7 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -28,18 +28,13 @@ Drupal.behaviors.roblib_search_eds = { items.push('' + val2.TitleFull + ''); }) } - val.pubType == 'Book' ? pubType = 'Print Book' : pubType = val.pubType; + pubType = val.pubType; pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"]; !pubYear ? pubYear = " " : pubYear = pubYear[0]["Y"]; - if (typeof val.Items.TypPub !== 'undefined') { - jQuery.each(val.Items.TypPub, function (key6, typpub) { - //strs = typpub.Data.split('; '); - //types = roblib_intersects(strs, ['Book', 'eBook']); - items.push('
' + pubYear + ' - ' + pubType + '
'); - }) - } + items.push('
' + pubYear + ' - ' + pubType + '
'); + var roblib_authors =[]; jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function (key3, author) { roblib_authors.push(author.NameFull); @@ -50,7 +45,7 @@ Drupal.behaviors.roblib_search_eds = { items.push(roblib_authors); items.push(''); - if (typeof val.Items.Src !== 'undefined') { + /*if (typeof val.Items.Src !== 'undefined') { jQuery.each(val.Items.Src, function (key4, source) { items.push('
' + source.Data + '
'); }) @@ -59,7 +54,7 @@ Drupal.behaviors.roblib_search_eds = { jQuery.each(val.Items.PubIrInfo, function (key5, pubinfo) { items.push('
' + pubinfo.Data + '
'); }) - } + }*/ var url; !val.Items.URL ? url = " " : url = val.Items.URL[0].Data; if(url) { diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js index 0340568..967ce97 100644 --- a/targets/eds/js/eds_results_article.js +++ b/targets/eds/js/eds_results_article.js @@ -1,77 +1,79 @@ Drupal.behaviors.roblib_search_eds_articles = { - attach: function(context, settings) { - $url = settings.roblib_search_eds_articles.search_url; - profile = 'eds'; //settings.roblib_search_eds.eds_profile; - jQuery.getJSON($url, function(data) { - var items = []; - var numberOfDocs = 0; - try { - numberOfDocs = data.records.length; - } catch (err) { - // do nothing leave docLength at 0 + attach: function (context, settings) { + $url = settings.roblib_search_eds_articles.search_url; + profile = 'eds'; //settings.roblib_search_eds.eds_profile; + jQuery.getJSON($url, function (data) { + var items = []; + var numberOfDocs = 0; + try { + numberOfDocs = data.records.length; + } catch (err) { + // do nothing leave docLength at 0 + } + if (numberOfDocs < 1) { + jQuery('#' + 'roblib-search-content-eds').empty().append('No Results'); + jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-articles').hide(); + } else { + var counter = 0; + var divs = new Array(); + var content = new Array(); + jQuery.each(data.records, function (key, val) { + id = 'roblib-search-eds-article-' + counter; + divs[counter++] = id; + + if (typeof val.Items !== 'undefined') { + items.push('
'); + if (typeof val.Items.Ti !== 'undefined') { + jQuery.each(val.Items.Ti, function (key2, val2) { + items.push('
'); + items.push('' + val2.Data + '
'); + }) } - if(numberOfDocs < 1){ - jQuery('#' + 'roblib-search-content-eds').empty().append('No Results'); - jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-articles').hide(); - } else { - var counter = 0; - var divs = new Array(); - var content = new Array(); - jQuery.each(data.records, function(key, val) { - id = 'roblib-search-eds-article-' + counter; - divs[counter++] = id; + pubType = val.pubType; - if (typeof val.Items !== 'undefined') { - items.push('
'); - if (typeof val.Items.Ti !== 'undefined') { - jQuery.each(val.Items.Ti, function(key2, val2){ - items.push('
'); - items.push(''+val2.Data+'
'); - }) - } - items.push('
'); - jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function(key3, authors){ - items.push(authors.NameFull+';'+' '); - }) - items.push('
'); - if (typeof val.Items.Src !== 'undefined') { - jQuery.each(val.Items.Src, function(key4, source){ - items.push('
'+source.Label+': '+source.Data+'
'); - }) - } - if (typeof val.PLink !== 'undefined' && typeof val.PDF !== 'undefined' && val.PDF == 'pdflink'){ - items.push(''); - } - if (typeof val.PLink !== 'undefined' && typeof val.HTML !== 'undefined' && val.HTML == '1'){ - items.push(''); - } - //items.push('
'+val.DbLabel+'
'); + pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"]; + !pubYear ? pubYear = " " : pubYear = pubYear[0]["Y"]; + + items.push('
' + pubYear + ' - ' + pubType + '
'); - items.push('
'); - } - }); - jQuery('#' + 'roblib-search-content-eds-articles').empty().append(items.join('')); - //qtipify(divs, content, 'Notes'); - } - var queries = []; - jQuery.each(data.queries, function(key7, query){ - queries.push(query.query); + var roblib_authors = []; + jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function (key3, author) { + roblib_authors.push(author.NameFull); }) - var query_str = data.queries[0].query; - var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile +'&mode=bool&lang=en&bquery='; - jQuery('#roblib-search-eds-article-more').empty().append('See all results (' + data.recordCount + ')'); + items.push('
'); + roblib_authors = roblib_shorten(roblib_authors.join('; '), 50, " "); + items.push(roblib_authors); + items.push('
'); + + + if (typeof val.Items.Src !== 'undefined') { + jQuery.each(val.Items.Src, function (key4, source) { + items.push('
In: ' + source.Data + '
'); + }) + } + if (typeof val.PLink !== 'undefined' && typeof val.PDF !== 'undefined' && val.PDF == 'pdflink') { + items.push(''); + } + if (typeof val.PLink !== 'undefined' && typeof val.HTML !== 'undefined' && val.HTML == '1') { + items.push(''); + } + items.push('
'); + } }); - } + jQuery('#' + 'roblib-search-content-eds-articles').empty().append(items.join('')); + } + + var queries = []; + jQuery.each(data.queries, function (key7, query) { + queries.push(query.query); + }) + var query_str = data.queries[0].query; + var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile + '&mode=bool&lang=en&bquery='; + jQuery('#roblib-search-eds-article-more').empty().append('See all results (' + data.recordCount + ')'); + + }); + } } -/*function edsArticlesPopulatePopupDivs(content, val, counter){ - content[counter] = ''; - jQuery.each(val.DetailedRecord, function(key, value){ - if(value.Group == 'Note') { - content[counter] += '
' + value.Label + '' ; - content[counter] += ' ' + value.Data +'
'; - } - }) -} */