diff options
author | Martin Fischer <martin@push-f.com> | 2025-03-30 13:58:58 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2025-04-05 12:10:36 +0200 |
commit | d980c8532918a1908b47d2a5571432520e425102 (patch) | |
tree | 5e179843c965180cd2752bdf2e102c9bd19feb5a /script.js | |
parent | e0ef47bb046163702addb625d8058b884b1411a9 (diff) |
refactor: port to Go
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -6,32 +6,32 @@ input.focus(); input.addEventListener('input', (e) => { const query = e.target.value.toLowerCase(); - for (const [key, data] of Object.entries(versions)) { - const heading = document.getElementById(key); + for (const version of versions) { + const heading = document.getElementById(version.name); - if (data.features == undefined) { + if (version.lib.length == 0 && version.non_lib.length == 0) { heading.hidden = query.length != 0; continue; } - const nonLibResults = search(data.features.non_lib_features, query); - const libResults = search(data.features.lib_features, query); + const nonLibResults = search(version.non_lib, query); + const libResults = search(version.lib, query); const totalResultCount = nonLibResults.length + libResults.length; // so that release notes don't get in the way when <Tab>ing through results document.body.classList.toggle('hide-release-notes', totalResultCount == 0); - let list = document.getElementById(key + '-non-lib-list'); + let list = document.getElementById(version.name + '-non-lib-list'); if (list) { list.replaceChildren(...renderList(nonLibResults).children); list.hidden = nonLibResults.length == 0; } - list = document.getElementById(key + '-lib-list'); + list = document.getElementById(version.name + '-lib-list'); if (list) { list.replaceChildren(...renderList(libResults).children); list.hidden = libResults.length == 0; - document.getElementById(key + '-lib').hidden = libResults.length == 0; + document.getElementById(version.name + '-lib-heading').hidden = libResults.length == 0; } heading.hidden = totalResultCount == 0; @@ -40,7 +40,7 @@ })(); function search(features, query) { - return Object.values(features).filter((feat) => { + return features.filter((feat) => { if (feat.title.toLowerCase().replaceAll('`', '').includes(query)) { return true; } |