This commit is contained in:
remi 2022-06-11 01:03:01 +02:00
parent baa691fa03
commit f88202b792

22
main.js
View File

@ -226,8 +226,26 @@ function search(word) {
for (let key in searchDictionary) { for (let key in searchDictionary) {
for (let value in searchDictionary[key]) { for (let value in searchDictionary[key]) {
if (searchDictionary[key][value].includes(word)) { if (searchDictionary[key][value].includes(word)) {
result.push(key); if (value == 0) {
break; //???? result.push(key);
break;
} else {
//if its a description (i.e: includes a space)
//do startsWith or something instead to prevent
//false positive search results
let t = false;
let d = searchDictionary[key][value].split(" ")
for (let w in d) {
if (d[w].startsWith(word)) {
t = true;
console.log(searchDictionary[key][value] + " " + d[w]);
}
}
if (t) {
result.push(key);
break;
}
}
} }
} }
} }