diff options
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 36 |
1 files changed, 16 insertions, 20 deletions
@@ -1,4 +1,4 @@ -(async function(){ +(async function () { const res = await fetch('data.json'); const versions = await res.json(); @@ -40,26 +40,24 @@ })(); function search(features, query) { - return Object.values(features).filter( - feat => { - if (feat.title.toLowerCase().replaceAll('`', '').includes(query)) { + return Object.values(features).filter((feat) => { + if (feat.title.toLowerCase().replaceAll('`', '').includes(query)) { + return true; + } + if (feat.flag && feat.flag.toLowerCase().includes(query)) { + return true; + } + if (query.length > 1) { + if (feat.aliases && feat.aliases.some((a) => a.toLowerCase().includes(query))) { return true; } - if (feat.flag && feat.flag.toLowerCase().includes(query)) { + if (feat.items && feat.items.some((i) => i.toLowerCase().includes(query))) { return true; } - if (query.length > 1) { - if (feat.aliases && feat.aliases.some(a => a.toLowerCase().includes(query))) { - return true; - } - if (feat.items && feat.items.some(i => i.toLowerCase().includes(query))) { - return true; - } - } - - return false; } - ); + + return false; + }); } function renderList(results) { @@ -69,10 +67,8 @@ function renderList(results) { const a = document.createElement('a'); a.textContent = feat.title; a.innerHTML = a.innerHTML.replaceAll(/`(.+?)`/g, (_, x) => `<code>${x}</code>`); - if (feat.url) - a.href = feat.url; - if (feat.flag) - a.title = feat.flag; + if (feat.url) a.href = feat.url; + if (feat.flag) a.title = feat.flag; li.appendChild(a); ul.appendChild(li); } |