From e318e64ab34d9da19829e8a097995081ab1bb486 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Wed, 2 Apr 2025 21:18:41 +0200 Subject: chore: format script.js with Prettier --- .prettierrc.toml | 4 ++++ script.js | 36 ++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 .prettierrc.toml diff --git a/.prettierrc.toml b/.prettierrc.toml new file mode 100644 index 0000000..96c2143 --- /dev/null +++ b/.prettierrc.toml @@ -0,0 +1,4 @@ +singleQuote = true +tabWidth = 2 +useTabs = true +printWidth = 100 diff --git a/script.js b/script.js index 4bac43c..a631288 100644 --- a/script.js +++ b/script.js @@ -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) => `${x}`); - 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); } -- cgit v1.2.3