0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Clean up redundant code

This commit is contained in:
Trevor Buckner
2024-04-14 16:06:12 -04:00
parent 58f487ac58
commit d854fe1202

View File

@@ -21,20 +21,16 @@ const showEmojiAutocomplete = function(CodeMirror, editor) {
const list = Object.keys(emojis).filter(function(emoji) {
return emoji.indexOf(currentWord) >= 0;
}).sort((a, b) => { // Sort autocomplete options alphabetically, case-insensitive
let lowerA = a.toLowerCase();
let lowerB = b.toLowerCase();
lowerA = lowerA.replace(/\d+/g, function(match) { // Temporarily convert any numbers in emoji string
return match.padStart(4, '0'); // to 4-digits, left-padded with 0's. To aid in
}); // sorting numbers, i.e., "d6, d10, d20", not "d10, d20, d6"
lowerB = lowerB.replace(/\d+/g, function(match) {
}).sort((a, b) => {
const lowerA = a.replace(/\d+/g, function(match) { // Temporarily convert any numbers in emoji string
return match.padStart(4, '0'); // to 4-digits, left-padded with 0's, to aid in
}).toLowerCase(); // sorting numbers, i.e., "d6, d10, d20", not "d10, d20, d6"
const lowerB = b.replace(/\d+/g, function(match) { // Also make lowercase for case-insensitive alpha sorting
return match.padStart(4, '0');
});
}).toLowerCase();
if (lowerA < lowerB)
return -1;
return 1;
}).map(function(emoji) {
return {