Split searching and listing
This commit is contained in:
@@ -24,11 +24,10 @@
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function filterList(text) {
|
||||
let examples;
|
||||
function getMatchingExamples(text) {
|
||||
if (text.length < 2) {
|
||||
examples = info.examples;
|
||||
} else {
|
||||
return info.examples;
|
||||
}
|
||||
const words = text.split(/\W+/);
|
||||
const scores = {};
|
||||
for (let i = 0; i < words.length; ++i) {
|
||||
@@ -63,7 +62,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
examples = [];
|
||||
const examples = [];
|
||||
// eslint-disable-next-line prefer-const
|
||||
for (let j in scores) {
|
||||
const ex = info.examples[j];
|
||||
@@ -95,7 +94,11 @@
|
||||
}
|
||||
return cmp;
|
||||
});
|
||||
return examples;
|
||||
}
|
||||
|
||||
function filterList(text) {
|
||||
const examples = getMatchingExamples(text);
|
||||
listExamples(examples);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user