mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-13 19:22:05 +00:00
Improve emote autocomplete to match substrings
This commit is contained in:
parent
2a62e6df90
commit
914605f393
1 changed files with 9 additions and 3 deletions
12
www/js/ui.js
12
www/js/ui.js
|
|
@ -184,9 +184,15 @@ function emoteRefresh() {
|
|||
var partial = emoteLastWord();
|
||||
var popup = $("#emote-suggestions");
|
||||
if (partial.length < 2 || !CHANNEL.emotes || !CHANNEL.emotes.length) { popup.hide(); return; }
|
||||
var matches = CHANNEL.emotes.filter(function(e) {
|
||||
return e.name.toLowerCase().indexOf(partial) === 0;
|
||||
}).slice(0, 8);
|
||||
var matches = CHANNEL.emotes
|
||||
.filter(e => e.name.toLowerCase().includes(partial))
|
||||
.sort((a, b) => {
|
||||
const an = a.name.toLowerCase();
|
||||
const bn = b.name.toLowerCase();
|
||||
|
||||
return (bn.startsWith(partial) - an.startsWith(partial)) || an.localeCompare(bn);
|
||||
})
|
||||
.slice(0, 8);
|
||||
if (!matches.length) { popup.hide(); return; }
|
||||
popup.empty();
|
||||
matches.forEach(function(e) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue