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.
44 lines
2.4 KiB
44 lines
2.4 KiB
Drupal.behaviors.roblib_search_solr_site_results = { |
|
attach: function (context, settings) { |
|
if (context == document) { |
|
unencoded_query = drupalSettings.path.currentPath.replace('roblib_search/', ''); |
|
query = encodeURIComponent(unencoded_query); |
|
solrUrl = settings.solr_site_search_url + query; |
|
baseUrl = settings.solr_site_base_url + query; |
|
jQuery.getJSON(baseUrl, function (data) { |
|
var items = []; |
|
total_found = data.resultCount; |
|
|
|
if (total_found < 1) { |
|
jQuery('#' + 'roblib-search-content-solr-site-results').empty().append('No Results'); |
|
jQuery('.' + 'pane-roblib-search-solr-site-roblib-search-solr-site-results').hide(); |
|
} else { |
|
jQuery('#' + 'roblib-search-content-solr-site-results').empty(); |
|
var counter = 0; |
|
var divs = new Array(); |
|
var content = new Array(); |
|
jQuery.each(data.results, function (key, val) { |
|
id = 'roblib_search_solr_results_' + counter; |
|
content[counter] = val.teaser; |
|
divs[counter++] = id; |
|
items.push('<div class ="roblib-search-row" id="' + id + '">\n\ |
|
<span class="roblib-title results">\n\ |
|
<a href="' + val.url + '">' + val.title + '</a></span>' + |
|
'\n\<span class="roblib-solr-bundle">(' + val.type + ')</span> <span class="roblib-solr-teaser"> ' + val.body + '</span></div>'); |
|
}); |
|
jQuery('#' + 'roblib-search-content-solr-site-results').empty().append(items.join('')); |
|
} |
|
if (total_found > 0) { |
|
results_url = '<a href=\'' + solrUrl + '\'>see all results (' |
|
+ total_found + ') </a>'; |
|
move_me_div_url = '<a href=\'' + solrUrl + '\'>Library Site (' |
|
+ total_found + ') </a>'; |
|
jQuery('#' + 'roblib-search-solr-site-results-more').empty().append(results_url); |
|
jQuery('#' + 'roblib-solr-more-results-results').empty().append(results_url); |
|
jQuery('#' + 'roblib-solr-search-toc-results').empty().append(move_me_div_url); |
|
} |
|
}); |
|
} |
|
} |
|
|
|
}
|
|
|