Browse Source

added try catch when checking for number of results

2.x-ebsco
Paul Pound 11 years ago
parent
commit
2ed4c3b267
  1. 8
      targets/cufts/js/cufts_results.js
  2. 8
      targets/eds/js/eds_results.js
  3. 8
      targets/evergreen/js/evergreen_results.js
  4. 10
      targets/solr_site/js/solr_site_results.js

8
targets/cufts/js/cufts_results.js

@ -3,7 +3,13 @@ Drupal.behaviors.roblib_search_cufts = {
url = settings.roblib_search_cufts.search_url; url = settings.roblib_search_cufts.search_url;
jQuery.getJSON(url, function(data) { jQuery.getJSON(url, function(data) {
var items = []; var items = [];
if (data.journals.length < 1) { var numberOfDocs = 0;
try {
numberOfDocs = data.journals.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-cufts').empty().append('No Results'); jQuery('#' + 'roblib-search-content-cufts').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-cufts-roblib-search-cufts-results').hide(); jQuery('.' + 'pane-roblib-search-cufts-roblib-search-cufts-results').hide();
} else { } else {

8
targets/eds/js/eds_results.js

@ -3,7 +3,13 @@ Drupal.behaviors.roblib_search_eds = {
$url = settings.roblib_search_eds.search_url; $url = settings.roblib_search_eds.search_url;
jQuery.getJSON($url, function(data) { jQuery.getJSON($url, function(data) {
var items = []; var items = [];
if(data.records.length < 1){ 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('#' + 'roblib-search-content-eds').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-results').hide(); jQuery('.' + 'pane-roblib-search-eds-roblib-search-eds-results').hide();
} else { } else {

8
targets/evergreen/js/evergreen_results.js

@ -3,7 +3,13 @@ Drupal.behaviors.roblib_search_evergreen = {
url = settings.roblib_search_evergreen.search_url; url = settings.roblib_search_evergreen.search_url;
jQuery.getJSON(url, function(data) { jQuery.getJSON(url, function(data) {
var items = []; var items = [];
if(data.numberOfRecords < 1){ var numberOfDocs = 0;
try {
numberOfDocs = data.numberOfRecords;
} catch (err) {
// do nothing leave docLength at 0
}
if(numberOfDocs < 1){
jQuery('#' + 'roblib-search-content-evergreen').empty().append('No Results'); jQuery('#' + 'roblib-search-content-evergreen').empty().append('No Results');
jQuery('.pane-roblib-search-evergreen-roblib-search-evergreen-results').hide(); jQuery('.pane-roblib-search-evergreen-roblib-search-evergreen-results').hide();
} else { } else {

10
targets/solr_site/js/solr_site_results.js

@ -3,8 +3,16 @@ Drupal.behaviors.roblib_search_solr_site = {
url = settings.roblib_search_solr_site.search_url; url = settings.roblib_search_solr_site.search_url;
jQuery.getJSON(url, function(data) { jQuery.getJSON(url, function(data) {
var items = []; var items = [];
if (data.response.docs.length < 1) { var numberOfDocs = 0;
try {
numberOfDocs = data.response.docs.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-solr-site').empty().append('No Results'); jQuery('#' + 'roblib-search-content-solr-site').empty().append('No Results');
//<section class="panel-pane pane-block pane-roblib-search-solr-site-roblib-search-solr-site-results block">
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-results').hide(); jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-results').hide();
} else { } else {
jQuery.each(data.response.docs, function(key, val) { jQuery.each(data.response.docs, function(key, val) {

Loading…
Cancel
Save