Use css to show / hide items; track matched items

... to improve search speed.

Instead of marking all items as hidden, and then marking the matched
ones again, this keeps track of all matched items and only
removes those that no longer match and adds those that previously did
not match.
This commit is contained in:
Maximilian Krög
2020-02-09 19:14:34 +01:00
parent 646ecfd405
commit 2dec296aae
3 changed files with 213 additions and 67 deletions

View File

@@ -25,7 +25,7 @@ const printListWithStability = v => {
function listContent(item, title, listItemPrinter) {
const type = title.toLowerCase();
if (item[type] && item[type].length) { ?>
<div class="member-list">
<div class="member-list" data-type="<?js= type ?>">
<span class="subtitle"><?js= title ?></span>
<ul><?js
item[type].forEach(function (v) {
@@ -36,13 +36,13 @@ function listContent(item, title, listItemPrinter) {
}
}
?>
<div class="navigation">
<div class="navigation search-empty">
<div class="search">
<input id="search" type="text" class="form-control input-sm" placeholder="Search Documentation">
</div>
<ul class="list"><?js
this.nav.forEach(function (item) { ?>
<li class="item" data-longname="<?js= item.longname ?>" data-name="<?js= item.name.toLowerCase() ?>">
<li class="item" data-longname="<?js= item.longname ?>" data-name="<?js= item.prettyname.toLowerCase() ?>">
<span class="title">
<span class="glyphicon <?js= getItemCssClass(item.type) ?> toggle"></span>
<span><?js= self.linkto(item.longname, item.prettyname.replace(/[.~]/g, '\u200b$&')) ?></span>