Make emojis.json much smaller.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4285 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-05-04 00:32:50 +00:00
parent 470b998b61
commit acabec940e
3 changed files with 15 additions and 15126 deletions

View File

@ -54,21 +54,27 @@ export function picker(callback, anchor) {
} }
} }
function chosen(event) {
console.log(event.srcElement.innerText);
callback(event.srcElement.innerText);
cleanup();
}
function refresh() { function refresh() {
while (list.firstChild) { while (list.firstChild) {
list.removeChild(list.firstChild); list.removeChild(list.firstChild);
} }
let search = input.value; let search = input.value;
let any_at_all = false; let any_at_all = false;
Object.entries(json).forEach(function(row) { for (let row of Object.entries(json)) {
let header = document.createElement('div'); let header = document.createElement('div');
header.appendChild(document.createTextNode(row[0])); header.appendChild(document.createTextNode(row[0]));
list.appendChild(header); list.appendChild(header);
let any = false; let any = false;
for (let entry of row[1]) { for (let entry of Object.entries(row[1])) {
if (search && if (search &&
search.length && search.length &&
entry.name.indexOf(search) == -1) { entry[0].indexOf(search) == -1) {
continue; continue;
} }
let emoji = document.createElement('span'); let emoji = document.createElement('span');
@ -76,12 +82,9 @@ export function picker(callback, anchor) {
emoji.style.display = 'inline-block'; emoji.style.display = 'inline-block';
emoji.style.overflow = 'hidden'; emoji.style.overflow = 'hidden';
emoji.style.cursor = 'pointer'; emoji.style.cursor = 'pointer';
emoji.onclick = function() { emoji.onclick = chosen;
callback(entry); emoji.title = entry[0];
cleanup(); emoji.appendChild(document.createTextNode(entry[1]));
};
emoji.title = entry.name;
emoji.appendChild(document.createTextNode(entry.emoji));
list.appendChild(emoji); list.appendChild(emoji);
any = true; any = true;
any_at_all = true; any_at_all = true;
@ -89,7 +92,7 @@ export function picker(callback, anchor) {
if (!any) { if (!any) {
list.removeChild(header); list.removeChild(header);
} }
}); }
if (!any_at_all) { if (!any_at_all) {
list.appendChild(document.createTextNode('No matches found.')); list.appendChild(document.createTextNode('No matches found.'));
} }

File diff suppressed because one or more lines are too long

View File

@ -74,7 +74,7 @@ class TfMessageElement extends LitElement {
} }
vote(emoji) { vote(emoji) {
let reaction = emoji.emoji; let reaction = emoji;
let message = this.message.id; let message = this.message.id;
if (confirm('Are you sure you want to react with ' + reaction + ' to ' + message + '?')) { if (confirm('Are you sure you want to react with ' + reaction + ' to ' + message + '?')) {
tfrpc.rpc.appendMessage( tfrpc.rpc.appendMessage(