forked from mirrors/treebird
JS Emoji picker
FossilOrigin-Name: dee0ddfe4af83bb952b8baf4d41d778974ee09d033c13b937fdc0c7a4a70eed0
This commit is contained in:
parent
e31e09029a
commit
91425632e2
4 changed files with 32 additions and 29 deletions
55
dist/js/emoji.js
vendored
55
dist/js/emoji.js
vendored
|
@ -1,3 +1,5 @@
|
|||
let emojo_json = null;
|
||||
|
||||
// Get emojis from file
|
||||
function get_emojo_json(callback)
|
||||
{
|
||||
|
@ -10,8 +12,9 @@ function get_emojo_json(callback)
|
|||
xhr.send();
|
||||
}
|
||||
|
||||
function construct_emojo_picker()
|
||||
function construct_emojo_picker(e)
|
||||
{
|
||||
let index = 0;
|
||||
let emoji_picker = document.createElement("div");
|
||||
emoji_picker.className = "emoji-picker";
|
||||
emoji_picker.innerHTML = `<table class="tabs ui-table">
|
||||
|
@ -61,37 +64,21 @@ function construct_emojo_picker()
|
|||
|
||||
<div class="emoji-picker-emojos-wrapper">
|
||||
<input type="radio" class="hidden" id="cat-smileys" name="emoji-cat" checked>
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_smileys}}
|
||||
</div>
|
||||
${construct_emojis("Smileys & Emotion").outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-animals" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_animals}}
|
||||
</div>
|
||||
${construct_emojis("Animals & Nature", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-food" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_food}}
|
||||
</div>
|
||||
${construct_emojis("Food & Drink", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-travel" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_travel}}
|
||||
</div>
|
||||
${construct_emojis("Travel & Places", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-activities" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_activities}}
|
||||
</div>
|
||||
${construct_emojis("Activities", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-objects" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_objects}}
|
||||
</div>
|
||||
${construct_emojis("Objects", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-symbols" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_symbols}}
|
||||
</div>
|
||||
${construct_emojis("Symbols", index).outerHTML}
|
||||
<input type="radio" class="hidden" id="cat-flags" name="emoji-cat">
|
||||
<div class="emoji-picker-emojos">
|
||||
{{%s:emojis_flags}}
|
||||
</div>
|
||||
${construct_emojis("Flags", index).outerHTML}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
@ -99,7 +86,21 @@ function construct_emojo_picker()
|
|||
return emoji_picker;
|
||||
}
|
||||
|
||||
function construct_emojis(category, start_index = 0)
|
||||
{
|
||||
let emoji_picker_div = document.createElement("div");
|
||||
emoji_picker_div.className = "emoji-picker-emojos";
|
||||
|
||||
for (let i = 0; i < emojo_json.length; ++i)
|
||||
{
|
||||
if (emojo_json[i].group === category)
|
||||
emoji_picker_div.innerHTML += `<span class="emoji">${emojo_json[i].char}</span>`;
|
||||
}
|
||||
|
||||
return emoji_picker_div;
|
||||
}
|
||||
|
||||
get_emojo_json((emojo_json_str) => {
|
||||
const emojo_json = JSON.parse(emojo_json_str);
|
||||
console.log(emojo_json);
|
||||
emojo_json = JSON.parse(emojo_json_str);
|
||||
document.body.appendChild(construct_emojo_picker(emojo_json));
|
||||
});
|
||||
|
|
|
@ -111,10 +111,11 @@ int main(int argc, char** argv)
|
|||
printf("#define EMOJO_CAT_SYMBOLS %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Flags") == 0 && cat == 6) {
|
||||
cat = 7;
|
||||
printf("#define EMOJO_CAT_FLAGS %d\n", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("#define EMOJO_CAT_MAX %d\n", i);
|
||||
|
||||
printf("static struct emoji_info emojos[] = {");
|
||||
i = 0;
|
||||
|
|
|
@ -125,7 +125,7 @@ char* construct_emoji_picker(char* status_id, size_t* size)
|
|||
emojis[EMO_CAT_ACTIVITIES] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_ACTIVITIES, EMOJO_CAT_OBJECTS - EMOJO_CAT_ACTIVITIES, NULL);
|
||||
emojis[EMO_CAT_OBJECTS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_OBJECTS, EMOJO_CAT_SYMBOLS - EMOJO_CAT_OBJECTS, NULL);
|
||||
emojis[EMO_CAT_SYMBOLS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_SYMBOLS, EMOJO_CAT_FLAGS - EMOJO_CAT_SYMBOLS, NULL);
|
||||
emojis[EMO_CAT_FLAGS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_FLAGS, 30 /* TODO there are not 100 flags */, NULL);
|
||||
emojis[EMO_CAT_FLAGS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_FLAGS, EMOJO_CAT_MAX - EMOJO_CAT_FLAGS, NULL);
|
||||
|
||||
struct emoji_picker_template data = {
|
||||
.emojis_smileys = emojis[EMO_CAT_SMILEYS],
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define EMOJO_CAT_OBJECTS 3715
|
||||
#define EMOJO_CAT_SYMBOLS 4014
|
||||
#define EMOJO_CAT_FLAGS 4315
|
||||
#define EMOJO_CAT_MAX 4590
|
||||
static struct emoji_info emojos[] = {{"😀","grinning face" }, /*0 : Smileys & Emotion*/
|
||||
{"😃","grinning face with big eyes" }, /*1 : Smileys & Emotion*/
|
||||
{"😄","grinning face with smiling eyes" }, /*2 : Smileys & Emotion*/
|
||||
|
|
Loading…
Reference in a new issue