mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-15 03:52:06 +00:00
Merge 914605f393 into 8fb51e6dc3
This commit is contained in:
commit
dd5fffa3f0
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 partial = emoteLastWord();
|
||||||
var popup = $("#emote-suggestions");
|
var popup = $("#emote-suggestions");
|
||||||
if (partial.length < 2 || !CHANNEL.emotes || !CHANNEL.emotes.length) { popup.hide(); return; }
|
if (partial.length < 2 || !CHANNEL.emotes || !CHANNEL.emotes.length) { popup.hide(); return; }
|
||||||
var matches = CHANNEL.emotes.filter(function(e) {
|
var matches = CHANNEL.emotes
|
||||||
return e.name.toLowerCase().indexOf(partial) === 0;
|
.filter(e => e.name.toLowerCase().includes(partial))
|
||||||
}).slice(0, 8);
|
.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; }
|
if (!matches.length) { popup.hide(); return; }
|
||||||
popup.empty();
|
popup.empty();
|
||||||
matches.forEach(function(e) {
|
matches.forEach(function(e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue