From 7546e3325fba124472153b801460720b4dbe74a6 Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Thu, 5 Oct 2017 19:52:16 +0530 Subject: [PATCH] emoji_picker: Add `get_emoji_coordinates()` function. Given the `emoji-id` of an emoji in emoji picker this function returns its coordinates, i.e, section number and index. --- static/js/emoji_picker.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index 197c597358..f5f8220cbb 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -72,6 +72,16 @@ function get_emoji_id(section, index) { return emoji_id; } +function get_emoji_coordinates(emoji_id) { + // Emoji id is of the following form: __ + // itself contains two underscores. See `get_emoji_id()`. + var emoji_info = emoji_id.split("_"); + return { + section: parseInt(emoji_info[3], 10), + index: parseInt(emoji_info[4], 10), + }; +} + function show_search_results() { $(".emoji-popover-emoji-map").hide(); $(".emoji-popover-category-tabs").hide();