summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.prettierrc.toml4
-rw-r--r--script.js36
2 files changed, 20 insertions, 20 deletions
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) => `<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);
}