From d980c8532918a1908b47d2a5571432520e425102 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 30 Mar 2025 13:58:58 +0200 Subject: refactor: port to Go --- script.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index a631288..0e2491e 100644 --- a/script.js +++ b/script.js @@ -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 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; } -- cgit v1.2.3