Permalink
Browse files

add emoji.js

  • Loading branch information...
1 parent 980a7a5 commit aaa56e80c4d6e8b64bc6a20407fbcefe94600bc9 @fengmk2 fengmk2 committed Jun 24, 2012
Showing with 8,955 additions and 1 deletion.
  1. +22 −1 README.md
  2. +50 −0 bin/create_emoji_js.py
  3. +5 −0 bin/syncdata.sh
  4. +748 −0 demo.html
  5. +724 −0 emoji.css
  6. +737 −0 emoji.js
  7. +8 −0 emoji_tpl.js
  8. +86 −0 iOS_emojs.txt
  9. BIN iphone_emoji.png
  10. +5 −0 jquery.js
  11. +6,570 −0 table.htm
View
@@ -1,4 +1,25 @@
emoji
=====
-emoji
+## Usage
+
+see `demo.html`
+
+```js
+var $text = $('.emojstext');
+var html = $text.html().trim().replace(/\n/g, '<br/>');
+$text.html(unifiedToHTML(html));
+```
+
+## Sync data
+
+Source data come from [php-emoji](https://github.com/iamcal/php-emoji).
+
+Run `syncdata.sh` script, will keep `iphone_emoji.png`, `emoji.css`, `table.html` update.
+And it will create `emoji_map.js` from `table.html` for using by `Javascript`.
+
+```sh
+sh ./bin/syncdata.sh
+```
+
+
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# install pyquery first: $ sudo easy_install pyquery
+
+from pyquery import PyQuery as pq
+
+d = pq(url='https://raw.github.com/iamcal/php-emoji/master/table.htm')
+# d = pq(open('./table.htm', 'rb').read())
+
+tr = d('table tr')
+
+content = u'// Auto create by `bin/create_emoji_js.py`\n\n' \
+ + u'var EMOJI_MAP = {\n // Unified: [name, classname, DoCoMo, KDDI, Softbank, Google]\n'
+
+for tre in tr[1:]:
+ tds = pq(tre)('td')
+ # val, name, Unified DoCoMo KDDI Softbank Google
+ item = ['', '', '', '', '', '', '']
+
+ for index, tde in enumerate(tds):
+ td = pq(tde)
+ # <td><span class="emoji emoji2320e3"></span></td>
+ if index == 0:
+ val = td('span').attr('class')[11:].decode('utf-8')
+ else:
+ val = td.text().decode('utf-8')
+ if index != 1 and val != '-':
+ # convert to str
+ val = val[2:]
+ val = val.split(' U+')
+ val[0] = (r'\U' + '0' * (8 - len(val[0])) + val[0].lower()).decode('unicode-escape')
+ if len(val) > 1:
+ val[1] = (r'\U' + '0' * (8 - len(val[1])) + val[1].lower()).decode('unicode-escape')
+ val = val[0] + val[1]
+ else:
+ val = val[0]
+ item[index] = val
+ # print item
+ # unified: [name, classname, docomo, kddi, softbank, google]
+ content += u' "' + item[2] + '": ["' + item[1] + '", "' + item[0] + '", "' + \
+ item[3] + '", "' + item[4] + '", "' + item[5] + '", "' + item[6] + '"],\n'
+
+content = content[:-2] + u'\n};\n\n'
+
+content += open('emoji_tpl.js', 'rb').read().decode('utf-8')
+
+f = open('emoji.js', 'wb')
+f.write(content.encode('utf-8'))
+f.close()
View
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+curl -O https://github.com/iamcal/php-emoji/raw/master/iphone_emoji.png
+curl -O https://raw.github.com/iamcal/php-emoji/master/emoji.css
+curl -O https://raw.github.com/iamcal/php-emoji/master/table.htm
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -0,0 +1,8 @@
+var EMOJI_RE = new RegExp('(' + Object.keys(EMOJI_MAP).join('|') + ')', 'g');
+
+function unifiedToHTML(text) {
+ return text.replace(EMOJI_RE, function (_, m1) {
+ var em = EMOJI_MAP[m1];
+ return '<span class="emoji emoji' + em[1] + '" title="' + em[0] + '"></span>';
+ });
+}
View
@@ -0,0 +1,86 @@
+😄😊😃☺😉😍😘😚😳😌😁😜😝😒😏😓😔😞😖😥😰😨😣😢😭😂😲😱😠😡😪😷👿👿👽💛💙💜💗💚❤💔💓💘✨🌟💢❕❔💤💨💦🎶🎵🔥💩👍👎👌👊✊✌👋✋👃👀👂👄💋👣💀💂👸👼
+
+😄😊😃☺😉😍😘😚😳😌😁😜😝😒😏😓😔😞😖😥😰
+😨😣😢😭😂😲😱😠😡😪😷👿👽💛💙💜💗💚❤💔💓
+💘✨🌟💢❕❔💤💨💦🎶🎵🔥💩👍👎👌👊✊✌👋✋
+👐👆👇👉👈🙌🙏☝👏💪🚶🏃👫💃👯🙆🙅💁🙇💏💑
+💆💇💅👦👧👩👨👶👵👴👱👲👳👷👮👼👸💂💀👣💋
+👄👂👀👃
+
+☀☔☁⛄🌙⚡🌀🌊🐱🐶🐭🐹🐰🐺🐸🐯🐨🐻🐷🐮🐗
+🐵🐒🐴🐎🐫🐑🐘🐍🐦🐤🐔🐧🐛🐙🐠🐟🐳🐬💐🌸🌷
+🍀🌹🌻🌺🍁🍃🍂🌴🌵🌾🐚
+
+🎍💝🎎🎒🎓🎏🎆🎇🎐🎑🎃👻🎅🎄🎁🔔🎉🎈💿📀📷
+🎥💻📺📱📠☎💽📼🔊📢📣📻📡➿🔍🔓🔒🔑✂🔨💡
+📲📩📫📮🛀🚽💺💰🔱🚬💣🔫💊💉🏈🏀⚽⚾🎾⛳🎱
+🏊🏄🎿♠♥♣♦🏆👾🎯🀄🎬📝📖🎨🎤🎧🎺🎷🎸〽
+👟👡👠👢👕👔👗👘👙🎀🎩👑👒🌂💼👜💄💍💎☕🍵
+🍺🍻🍸🍶🍴🍔🍟🍝🍛🍱🍣🍙🍘🍚🍜🍲🍞🍳🍢🍡🍦
+🍧🎂🍰🍎🍊🍉🍓🍆🍅
+
+🏠🏫🏢🏣🏥🏦🏪🏩🏨💒⛪🏬🌇🌆🏯🏰⛺🏭🗼🗻
+🌄🌅🌃🗽🌈🎡⛲🎢🚢🚤⛵✈🚀🚲🚙🚗🚕🚌🚓🚒🚑
+🚚🚃🚉🚄🚅🎫⛽🚥⚠🚧🔰🏧🎰🚏💈♨🏁🎌🇯🇵🇰🇷🇨🇳🇺🇸
+🇫🇷🇪🇸🇮🇹🇷🇺🇬🇧🇩🇪
+
+1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣0⃣#⃣⬆⬇⬅➡↗↖↘↙◀▶
+⏪⏩🆗🆕🔝🆙🆒🎦🈁📶🈵🈳🉐🈹🈯🈺🈶🈚🈷🈸🈂
+🚻🚹🚺🚼🚭🅿♿🚇🚾㊙㊗🔞🆔✳✴💟🆚📳📴💹💱
+♈♉♊♋♌♍♎♏♐♑♒♓⛎🔯🅰🅱🆎🅾🔲🔴🔳
+🕛🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚⭕❌©®™
+
+🏠🏡🏫🏢🏣🏥🏦🏪🏩🏨💒⛪🏬🏤🌇🌆🏯🏰⛺🏭🗼
+🗾🗻🌄🌅🌃🗽🌉🎠🎡⛲🎢🚢⛵🚤🚣⚓🚀✈💺🚁🚂
+🚊🚉🚎🚆🚄🚅🚈🚇🚝🚋🚃🚎🚌🚍🚙🚘🚗🚕🚖🚛🚚
+🚨🚓🚔🚒🚑🚐🚲🚡🚟🚠🚜💈🚏🎫🚦🚥⚠🚧🔰⛽🏮
+🎰♨🗿🎪🎭📍🚩🇯🇵🇰🇷🇩🇪🇨🇳🇺🇸🇫🇷🇪🇸🇮🇹🇷🇺🇬🇧
+
+1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣0⃣🔟🔢#⃣🔣⬆⬇⬅➡🔠🔡🔤
+↗↖↘↙↔↕🔄◀▶🔼🔽↩↪ℹ⏪⏩⏫⏬⤵⤴🆗
+🔀🔁🔂🆕🆙🆒🆓🆖📶🎦🈁🈯🈳🈵🈴🈲🉐🈹🈺🈶🈚
+🚻🚹🚺🚼🚾🚰🚮🅿♿🚭🈷🈸🈂Ⓜ🛂🛄🛅🛃🉑㊙㊗
+🆑🆘🆔🚫🔞📵🚯🚱🚳🚷🚸⛔✳❇❎✅✴💟🆚📳📴
+🅰🅱🆎🅾💠➿♻♈♉♊♋♌♍♎♏♐♑♒♓⛎🔯
+🏧💹💲💱©®™❌‼⁉❗❓❕❔⭕🔝🔚🔙🔛🔜🔃
+🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙
+🕥🕚🕦✖➕➖➗♠♥♣♦💮💯✔☑🔘🔗➰〰〽🔱
+◼◻◾◽▪▫🔺🔲🔳⚫⚪🔴🔵🔻⬜⬛🔶🔷🔸🔹
+
+
+# 0 1 2 3 4 5 6 7 8 9 ⃣
+🇦 🇧 🇨 🇩 🇪 🇫 🇬 🇭 🇮 🇯 🇰 🇱 🇲 🇳 🇴 🇵 🇶 🇷 🇸 🇹 🇺 🇻 🇼 🇽 🇾 🇿
+#⃣0⃣1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣©®
+‼⁉
+™ℹ
+↔↕↖↗↘↙↩↪
+⌚⌛
+⏩⏪⏫⏬⏰⏳
+Ⓜ
+▪▫▶◀◻◼◽◾
+☀☁☎☑☔☕☝☺♈♉♊♋♌♍♎♏♐♑♒♓♠♣♥♦♨♻♿⚓⚠⚡⚪⚫⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽
+✂✅✈✉✊✋✌✏✒✔✖✨✳✴❄❇❌❎❓❔❕❗❤➕➖➗➡➰➿
+⤴⤵
+⬅⬆⬇⬛⬜⭐⭕
+〰〽
+㊗㊙
+
+🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚
+🇨🇳🇩🇪🇪🇸🇫🇷🇬🇧🇮🇹🇯🇵🇰🇷🇷🇺🇺🇸
+🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑
+🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠
+🌰🌱🌲🌳🌴🌵🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟
+🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓
+🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊
+🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟
+🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾👀👂👃👄👅👆👇👈👉👊👋👌👍👎👏
+👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿
+💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯
+💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📑📒📓📔📕📖📗📘📙📚📛📜📝📞📟
+📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📹📺📻📼🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏
+🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽
+🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🗻🗼🗽🗾🗿
+😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😒😓😔😖😘😚😜😝😞😠😡😢😣😤😥😨😩😪😫😭😰😱😲😳😵😶😷
+😸😹😺😻😼😽😾😿🙀🙅🙆🙇🙈🙉🙊🙋🙌🙍🙎🙏
+🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪
+🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit aaa56e8

Please sign in to comment.