From 610ea2b2853e2185ceedb29da17bbceffbd7a11d Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Mon, 17 Jul 2017 16:08:54 -0300 Subject: [PATCH] coding standards --- targets/eds/js/eds_results.js | 144 +++++++++++++++++----------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index b290306..c85d775 100644 --- a/targets/eds/js/eds_results.js +++ b/targets/eds/js/eds_results.js @@ -1,82 +1,82 @@ Drupal.behaviors.roblib_search_eds = { - attach: function(context, settings) { - $url = settings.roblib_search_eds.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.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-results').hide(); + } else { + var counter = 0; + var divs = new Array(); + var content = new Array(); + jQuery.each(data.records, function (key, val) { + id = 'roblib-search-eds-' + 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-results').hide(); - } else { - var counter = 0; - var divs = new Array(); - var content = new Array(); - jQuery.each(data.records, function(key, val) { - id = 'roblib-search-eds-' + 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+'
'); - }) - } - pubYear = val.RecordInfo.BibRelationships.IsPartOfRelationships["date"]; - !pubYear ? pubYear = " " : pubYear = pubYear[0]["Y"]; + 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+' - '+ types.join(', ') + '
'); - }) - } - items.push('
'); - 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('
'); - if (typeof val.Items.Src !== 'undefined') { - jQuery.each(val.Items.Src, function(key4, source){ - items.push('
'+source.Data+'
'); - }) - } - if (typeof val.Items.PubIrInfo !== 'undefined') { - jQuery.each(val.Items.PubIrInfo, function(key5, pubinfo){ - items.push('
'+pubinfo.Data+'
'); - }) - } - - items.push('
'+val.DbLabel+'
'); - - items.push('
'); - } - }); - jQuery('#' + 'roblib-search-content-eds').empty().append(items.join('')); + 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 + ' - ' + types.join(', ') + '
'); + }) } - - var queries = []; - jQuery.each(data.queries, function(key7, query){ - queries.push(query.query); + items.push('
'); + roblib_authors = ""; + jQuery.each(val.RecordInfo.BibRelationships.HasContributorRelationships, function (key3, author) { + roblib_authors += author.NameFull; }) - var query_str = data.queries[0].query; - //var host = "http://eds-api.ebscohost.com"; - //var get = "/edsapi/rest/Search?query=history&searchmode=all&resultsperpage=20&pagenumber=1&sort=relevance&highlight=y&includefacets=y&facetfilter=1%2cSourceType%3aMagazines%2cSourceType%3aNews%2cSourceType%3aAcademic+Journals%2cSourceType%3aConference+Materials&view=detailed"; - 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-more').empty().append('See all results (' + data.recordCount + ')'); + roblib_authors = roblib_shorten(roblib_authors, 50, " "); + items.push(roblib_authors); + items.push('
'); + if (typeof val.Items.Src !== 'undefined') { + jQuery.each(val.Items.Src, function (key4, source) { + items.push('
' + source.Data + '
'); + }) + } + if (typeof val.Items.PubIrInfo !== 'undefined') { + jQuery.each(val.Items.PubIrInfo, function (key5, pubinfo) { + items.push('
' + pubinfo.Data + '
'); + }) + } + items.push('
' + val.DbLabel + '
'); + + items.push('
'); + } }); - } + jQuery('#' + 'roblib-search-content-eds').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 host = "http://eds-api.ebscohost.com"; + //var get = "/edsapi/rest/Search?query=history&searchmode=all&resultsperpage=20&pagenumber=1&sort=relevance&highlight=y&includefacets=y&facetfilter=1%2cSourceType%3aMagazines%2cSourceType%3aNews%2cSourceType%3aAcademic+Journals%2cSourceType%3aConference+Materials&view=detailed"; + 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-more').empty().append('See all results (' + data.recordCount + ')'); + + }); + } } function roblib_intersects(a, b) {