|
@@ -90,34 +90,34 @@ class EmojiAutoCompleteHelper {
|
|
|
const maxLength = 12;
|
|
const maxLength = 12;
|
|
|
|
|
|
|
|
let results1 = [], results2 = [], results3 = [], results4 = [];
|
|
let results1 = [], results2 = [], results3 = [], results4 = [];
|
|
|
- const countLen1 = () => { results1.length; }
|
|
|
|
|
- const countLen2 = () => { countLen1() + results2.length; }
|
|
|
|
|
- const countLen3 = () => { countLen2() + results3.length; }
|
|
|
|
|
- const countLen4 = () => { countLen3() + results4.length; }
|
|
|
|
|
|
|
+ const countLen1 = () => { results1.length };
|
|
|
|
|
+ const countLen2 = () => { countLen1() + results2.length };
|
|
|
|
|
+ const countLen3 = () => { countLen2() + results3.length };
|
|
|
|
|
+ const countLen4 = () => { countLen3() + results4.length };
|
|
|
// TODO performance tune
|
|
// TODO performance tune
|
|
|
// when total length of all results is less than `maxLength`
|
|
// when total length of all results is less than `maxLength`
|
|
|
for (let unicode in this.emojiStrategy) {
|
|
for (let unicode in this.emojiStrategy) {
|
|
|
const data = this.emojiStrategy[unicode];
|
|
const data = this.emojiStrategy[unicode];
|
|
|
|
|
|
|
|
- if (maxLength <= countLen1()) { break; }
|
|
|
|
|
|
|
+ if (maxLength <= countLen1()) { break }
|
|
|
// prefix match to shortname
|
|
// prefix match to shortname
|
|
|
else if (data.shortname.indexOf(`:${term}`) > -1) {
|
|
else if (data.shortname.indexOf(`:${term}`) > -1) {
|
|
|
results1.push(data.shortname);
|
|
results1.push(data.shortname);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- else if (maxLength <= countLen2()) { continue; }
|
|
|
|
|
|
|
+ else if (maxLength <= countLen2()) { continue }
|
|
|
// partial match to shortname
|
|
// partial match to shortname
|
|
|
else if (data.shortname.indexOf(term) > -1) {
|
|
else if (data.shortname.indexOf(term) > -1) {
|
|
|
results2.push(data.shortname);
|
|
results2.push(data.shortname);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- else if (maxLength <= countLen3()) { continue; }
|
|
|
|
|
|
|
+ else if (maxLength <= countLen3()) { continue }
|
|
|
// partial match to elements of aliases
|
|
// partial match to elements of aliases
|
|
|
else if ((data.aliases != null) && data.aliases.find(elem => elem.indexOf(term) > -1)) {
|
|
else if ((data.aliases != null) && data.aliases.find(elem => elem.indexOf(term) > -1)) {
|
|
|
results3.push(data.shortname);
|
|
results3.push(data.shortname);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- else if (maxLength <= countLen4()) { continue; }
|
|
|
|
|
|
|
+ else if (maxLength <= countLen4()) { continue }
|
|
|
// partial match to elements of keywords
|
|
// partial match to elements of keywords
|
|
|
else if ((data.keywords != null) && data.keywords.find(elem => elem.indexOf(term) > -1)) {
|
|
else if ((data.keywords != null) && data.keywords.find(elem => elem.indexOf(term) > -1)) {
|
|
|
results4.push(data.shortname);
|
|
results4.push(data.shortname);
|