Skip to content

Commit

Permalink
Improve viewer performance by using v-show
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 21, 2023
1 parent 52b397f commit dcb1245
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
28 changes: 18 additions & 10 deletions code/viewer_partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<p></p>
<p></p>
<p></p>
<details v-for="intrinsic in intrinsics" style="margin-top: 5px;padding-left: 5px;border-top: 1px solid black;border-left: 5px solid black">
<details v-for="intrinsic in intrinsics.inner" v-show="intrinsic.display" style="margin-top: 5px;padding-left: 5px;border-top: 1px solid black;border-left: 5px solid black">
<summary>{{ intrinsic.name }}</summary>
<div v-html="intrinsic.content" style="padding: 10px"></div>
</details>
Expand Down Expand Up @@ -87,31 +87,39 @@
r.searchParams.set('q', search.value);
window.history.pushState({ path: r.href }, '', r.href);

let result = [];
let length = 0;
if (search.value === "") {
for (let val of allIntrinsics) {
if (!groups.value.includes(val.group)) {
continue;
val.display = false;
} else if (!extensions.value.includes(val.extension)) {
continue;
val.display = false;
} else {
val.display = true;
length = length + 1;
}
result.push(val);
}
} else {
let candidates = fuse.search(search.value)
for (let val of allIntrinsics) {
val.display = false;
}

let candidates = fuse.search(search.value);
for (let val of candidates) {
if (!groups.value.includes(val.item.group)) {
continue;
} else if (!extensions.value.includes(val.item.extension)) {
continue;
}
result.push(val.item);
allIntrinsics[val.refIndex].display = true;
length = length + 1;
}
}


nextTick(hljs.highlightAll);
return result;
return {
inner: allIntrinsics,
length: length,
};
});

return {
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ def all_intrinsics(render=True):
),
"group": title,
"extension": extension,
"display": True
}
)
else:
Expand Down

0 comments on commit dcb1245

Please sign in to comment.