mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add js files: lunr.min.js & search.js
This commit is contained in:
parent
55695c9c31
commit
0705bd6bea
2 changed files with 55 additions and 0 deletions
7
docs/assets/themes/zeppelin/js/lunr.min.js
vendored
Normal file
7
docs/assets/themes/zeppelin/js/lunr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
48
docs/assets/themes/zeppelin/js/search.js
Normal file
48
docs/assets/themes/zeppelin/js/search.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
|
||||
---
|
||||
jQuery(function() {
|
||||
window.idx = lunr(function () {
|
||||
this.field('id');
|
||||
this.field('title');
|
||||
this.field('content', { boost: 10 });
|
||||
this.field('group');
|
||||
});
|
||||
|
||||
window.data = $.getJSON('/search_data.json');
|
||||
window.data.then(function(loaded_data){
|
||||
$.each(loaded_data, function(index, value){
|
||||
window.idx.add(
|
||||
$.extend({ "id": index }, value)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
$("#site_search").keyup(function(event){
|
||||
event.preventDefault();
|
||||
var query = $("#search_box").val();
|
||||
var results = window.idx.search(query);
|
||||
display_search_results(results);
|
||||
});
|
||||
|
||||
function display_search_results(results) {
|
||||
var $search_results = $("#search_results");
|
||||
var zeppelin_version = {{site.ZEPPELIN_VERSION | jsonify}};
|
||||
|
||||
window.data.then(function(loaded_data) {
|
||||
if (results.length) {
|
||||
$search_results.empty();
|
||||
$search_results.prepend('<p class="">Found '+results.length+' result(s)</p><hr>');
|
||||
|
||||
results.forEach(function(result) {
|
||||
var item = loaded_data[result.ref];
|
||||
var appendString = '<a href="'+item.url+'">'+item.title+'</a><div class="link">'+'https://zeppelin.apache.org/docs/'+zeppelin_version+item.url+'</div><p>'+item.excerpt+'</p><br/>';
|
||||
|
||||
$search_results.append(appendString);
|
||||
});
|
||||
} else {
|
||||
$search_results.html('<p>No results found.</p>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue