mirror of
https://github.com/danbulant/api_docs
synced 2026-05-19 12:19:08 +00:00
41 lines
863 B
JavaScript
41 lines
863 B
JavaScript
(function (global) {
|
|
|
|
window.topic = topic;
|
|
|
|
var index = lunr(function () {
|
|
this.field('title', { boost: 10 });
|
|
this.field('tags', { boost: 100 });
|
|
this.field('body');
|
|
this.ref('id');
|
|
});
|
|
|
|
$(bindSearch);
|
|
|
|
function bindSearch () {
|
|
$('#search').on('keyup', function () {
|
|
if (this.value) {
|
|
var items = index.search(this.value);
|
|
$('article, nav li').hide();
|
|
items.forEach(function (item) {
|
|
$('#' + item.ref + ', #' + item.ref + '-nav').show();
|
|
});
|
|
} else {
|
|
$('article, nav li').show();
|
|
}
|
|
});
|
|
|
|
$('form').on('submit', function (event) {
|
|
event.preventDefault();
|
|
});
|
|
}
|
|
|
|
function topic (title, tags, handle) {
|
|
index.add({
|
|
id: handle,
|
|
title: title,
|
|
tags: tags,
|
|
body: $('#' + handle + '-body').text()
|
|
});
|
|
}
|
|
|
|
})(window);
|