You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
2.3 KiB
48 lines
2.3 KiB
11 years ago
|
Drupal.behaviors.roblib_search_solr_site_results = {
|
||
8 years ago
|
attach: function (context, settings) {
|
||
11 years ago
|
url = settings.roblib_search_solr_site_results.search_url;
|
||
|
query = settings.roblib_search_solr_site_results.search_query;
|
||
|
baseUrl = settings.roblib_search_solr_site_results.base_url;
|
||
11 years ago
|
default_site_type = settings.roblib_search_solr_site_results.default_site_type + '/';
|
||
8 years ago
|
jQuery.getJSON(url, function (data) {
|
||
11 years ago
|
var items = [];
|
||
8 years ago
|
total_found = data.response.numFound;
|
||
11 years ago
|
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-results').empty().append('No Results');
|
||
11 years ago
|
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-results').hide();
|
||
11 years ago
|
} else {
|
||
|
jQuery('#' + 'roblib-search-content-solr-site-results').empty();
|
||
11 years ago
|
var counter = 0;
|
||
|
var divs = new Array();
|
||
|
var content = new Array();
|
||
8 years ago
|
jQuery.each(data.response.docs, function (key, val) {
|
||
11 years ago
|
id = 'roblib_search_solr_results_' + counter;
|
||
|
content[counter] = val.teaser;
|
||
|
divs[counter++] = id;
|
||
8 years ago
|
items.push('<div class ="roblib-search-row" id="' + id + '">\n\
|
||
8 years ago
|
<span class="roblib-title results">\n\
|
||
|
<a href="' + val.url + '">' + val.label + '</a></span>' +
|
||
|
'\n\<span class="roblib-solr-bundle">(' + val.bundle_name + ')</span> <span class="roblib-solr-teaser"> ' + val.teaser + '</span></div>');
|
||
12 years ago
|
});
|
||
11 years ago
|
jQuery('#' + 'roblib-search-content-solr-site-results').empty().append(items.join(''));
|
||
|
}
|
||
8 years ago
|
if (numberOfDocs > 0) {
|
||
|
results_url = '<a href="' + baseUrl + '/search/' + default_site_type + query + '?f[0]=(-bundle:bestbet)"' + '>see all results ('
|
||
|
+ total_found + ') </a>';
|
||
8 years ago
|
move_me_div_url = '<a href="' + baseUrl + '/search/' + default_site_type + query + '?f[0]=(-bundle:bestbet)"' + '>Library Site ('
|
||
8 years ago
|
+ total_found + ') </a>';
|
||
8 years ago
|
jQuery('#' + 'roblib-search-solr-site-results-more').empty().append(results_url);
|
||
|
jQuery('#' + 'roblib-solr-more-results-results').empty().append(results_url);
|
||
8 years ago
|
jQuery('#' + 'roblib-solr-search-toc-results').empty().append(move_me_div_url);
|
||
8 years ago
|
}
|
||
11 years ago
|
});
|
||
|
}
|
||
12 years ago
|
|
||
11 years ago
|
}
|