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