Support all short_names when getting emoji data [Fix #15]

nolan/hinaloe-test
Etienne Lemay 2016-10-13 16:19:46 -04:00
parent 00eea58760
commit 2aece93395
2 changed files with 15 additions and 3 deletions

View File

@ -5,7 +5,7 @@ var fs = require('fs'),
mkdirp = require('mkdirp') mkdirp = require('mkdirp')
var categories = ['People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags'], var categories = ['People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags'],
data = { categories: [], emojis: {}, skins: {} }, data = { categories: [], emojis: {}, skins: {}, short_names: {} },
categoriesIndex = {} categoriesIndex = {}
categories.forEach((category, i) => { categories.forEach((category, i) => {
@ -22,7 +22,6 @@ emojiData.sort((a, b) => {
emojiData.forEach((datum) => { emojiData.forEach((datum) => {
var category = datum.category, var category = datum.category,
shortName = datum.short_name,
keywords = [], keywords = [],
categoryIndex categoryIndex
@ -83,6 +82,11 @@ emojiData.forEach((datum) => {
data.emojis[datum.short_name] = datum data.emojis[datum.short_name] = datum
} }
datum.short_names.forEach((short_name, i) => {
if (i == 0) { return }
data.short_names[short_name] = datum.short_name
})
delete datum.docomo delete datum.docomo
delete datum.au delete datum.au
delete datum.softbank delete datum.softbank

View File

@ -37,13 +37,21 @@ function getSanitizedData() {
function getData(emoji, skin, sheetURL) { function getData(emoji, skin, sheetURL) {
var emojiData = {}, var emojiData = {},
_emojiData = null _emojiData, _emoji, _id
if (typeof emoji == 'string') { if (typeof emoji == 'string') {
if (_emoji = data.short_names[emoji]) {
emoji = _emoji
}
if (_emojiData = data.emojis[emoji]) { if (_emojiData = data.emojis[emoji]) {
emojiData = _emojiData emojiData = _emojiData
} }
} else if (emoji.id) { } else if (emoji.id) {
if (_id = data.short_names[emoji.id]) {
emoji.id = _id
}
if (_emojiData = data.emojis[emoji.id]) { if (_emojiData = data.emojis[emoji.id]) {
emojiData = _emojiData emojiData = _emojiData
skin || (skin = emoji.skin) skin || (skin = emoji.skin)