feat: add search filter to doc-wasm sidebar

This commit is contained in:
Accusys
2026-05-19 03:16:06 +08:00
parent f6f623eeea
commit b046a3b91c

View File

@@ -37,6 +37,7 @@ html, body { height: 100%; }
<div id="app">
<div class="sidebar" id="sidebar">
<h1>Momentry Docs</h1>
<input id="search" type="text" placeholder="搜尋模組..." style="width:100%;padding:8px;margin-bottom:12px;border:1px solid #ddd;border-radius:6px;font-size:13px;box-sizing:border-box">
<div id="module-list"></div>
<div class="logout">
<a id="logout-btn">Logout</a>
@@ -186,6 +187,16 @@ async function initApp() {
a.onclick = function(e) { e.preventDefault(); loadDoc(m[0]); };
listEl.appendChild(a);
});
// Search filter
var searchEl = document.getElementById('search');
if (searchEl) {
searchEl.oninput = function() {
var q = this.value.toLowerCase();
document.querySelectorAll('#module-list a').forEach(function(a) {
a.style.display = a.textContent.toLowerCase().indexOf(q) >= 0 ? '' : 'none';
});
};
}
// Watch for logout disappearing
var lo = document.getElementById('logout-btn');
if (lo) {