561 lines
664 KiB
JavaScript
561 lines
664 KiB
JavaScript
|
/* jshint maxerr: 10000 */
|
||
|
/* jslint unused: true */
|
||
|
/* jshint shadow: true */
|
||
|
/* jshint -W075 */
|
||
|
(function(ns){
|
||
|
// this list must be ordered from largest length of the value array, index 0, to the shortest
|
||
|
ns.emojioneList = {":kiss_mm:":{"uc_base":"1f468-2764-1f48b-1f468","uc_output":"1f468-200d-2764-fe0f-200d-1f48b-200d-1f468","uc_match":"1f468-2764-fe0f-1f48b-1f468","uc_greedy":"1f468-2764-1f48b-1f468","shortnames":[":couplekiss_mm:"],"category":"people"},":kiss_woman_man:":{"uc_base":"1f469-2764-1f48b-1f468","uc_output":"1f469-200d-2764-fe0f-200d-1f48b-200d-1f468","uc_match":"1f469-2764-fe0f-1f48b-1f468","uc_greedy":"1f469-2764-1f48b-1f468","shortnames":[],"category":"people"},":kiss_ww:":{"uc_base":"1f469-2764-1f48b-1f469","uc_output":"1f469-200d-2764-fe0f-200d-1f48b-200d-1f469","uc_match":"1f469-2764-fe0f-1f48b-1f469","uc_greedy":"1f469-2764-1f48b-1f469","shortnames":[":couplekiss_ww:"],"category":"people"},":england:":{"uc_base":"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f","uc_output":"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f","uc_match":"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f","uc_greedy":"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f","shortnames":[],"category":"flags"},":scotland:":{"uc_base":"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f","uc_output":"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f","uc_match":"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f","uc_greedy":"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f","shortnames":[],"category":"flags"},":wales:":{"uc_base":"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f","uc_output":"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f","uc_match":"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f","uc_greedy":"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f","shortnames":[],"category":"flags"},":family_mmbb:":{"uc_base":"1f468-1f468-1f466-1f466","uc_output":"1f468-200d-1f468-200d-1f466-200d-1f466","uc_match":"1f468-1f468-1f466-1f466","uc_greedy":"1f468-1f468-1f466-1f466","shortnames":[],"category":"people"},":family_mmgb:":{"uc_base":"1f468-1f468-1f467-1f466","uc_output":"1f468-200d-1f468-200d-1f467-200d-1f466","uc_match":"1f468-1f468-1f467-1f466","uc_greedy":"1f468-1f468-1f467-1f466","shortnames":[],"category":"people"},":family_mmgg:":{"uc_base":"1f468-1f468-1f467-1f467","uc_output":"1f468-200d-1f468-200d-1f467-200d-1f467","uc_match":"1f468-1f468-1f467-1f467","uc_greedy":"1f468-1f468-1f467-1f467","shortnames":[],"category":"people"},":family_mwbb:":{"uc_base":"1f468-1f469-1f466-1f466","uc_output":"1f468-200d-1f469-200d-1f466-200d-1f466","uc_match":"1f468-1f469-1f466-1f466","uc_greedy":"1f468-1f469-1f466-1f466","shortnames":[],"category":"people"},":family_mwgb:":{"uc_base":"1f468-1f469-1f467-1f466","uc_output":"1f468-200d-1f469-200d-1f467-200d-1f466","uc_match":"1f468-1f469-1f467-1f466","uc_greedy":"1f468-1f469-1f467-1f466","shortnames":[],"category":"people"},":family_mwgg:":{"uc_base":"1f468-1f469-1f467-1f467","uc_output":"1f468-200d-1f469-200d-1f467-200d-1f467","uc_match":"1f468-1f469-1f467-1f467","uc_greedy":"1f468-1f469-1f467-1f467","shortnames":[],"category":"people"},":family_wwbb:":{"uc_base":"1f469-1f469-1f466-1f466","uc_output":"1f469-200d-1f469-200d-1f466-200d-1f466","uc_match":"1f469-1f469-1f466-1f466","uc_greedy":"1f469-1f469-1f466-1f466","shortnames":[],"category":"people"},":family_wwgb:":{"uc_base":"1f469-1f469-1f467-1f466","uc_output":"1f469-200d-1f469-200d-1f467-200d-1f466","uc_match":"1f469-1f469-1f467-1f466","uc_greedy":"1f469-1f469-1f467-1f466","shortnames":[],"category":"people"},":family_wwgg:":{"uc_base":"1f469-1f469-1f467-1f467","uc_output":"1f469-200d-1f469-200d-1f467-200d-1f467","uc_match":"1f469-1f469-1f467-1f467","uc_greedy":"1f469-1f469-1f467-1f467","shortnames":[],"category":"people"},":couple_mm:":{"uc_base":"1f468-2764-1f468","uc_output":"1f468-200d-2764-fe0f-200d-1f468","uc_match":"1f468-2764-fe0f-1f468","uc_greedy":"1f468-2764-1f468","shortnames":[":couple_with_heart_mm:"],"category":"people"},":couple_with_heart_woman_man:":{"uc_base":"1f469-2764-1f468","uc_output":"1f469-200d-2764-fe0f-200d-1f468","uc_match":"1f469-2764-fe0f-1f468","uc_greedy":"1f469-2764-1f468","shortnames":[],"category":"people"},":couple_ww:":{"uc_base":"1f469-2764-1f469","uc_output":"1f469-200d-2764-fe0f-200d-1f469","uc_match":"1f469-2764-fe0f-1f469","uc_greedy":"1f469-2764-1f469","shortnames":[":
|
||
|
|
||
|
var tmpShortNames = [], emoji;
|
||
|
for (emoji in ns.emojioneList) {
|
||
|
if (!ns.emojioneList.hasOwnProperty(emoji) || (emoji === '')) continue;
|
||
|
tmpShortNames.push(emoji.replace(/[+]/g, "\\$&"));
|
||
|
for (var i = 0; i < ns.emojioneList[emoji].shortnames.length; i++) {
|
||
|
tmpShortNames.push(ns.emojioneList[emoji].shortnames[i].replace(/[+]/g, "\\$&"));
|
||
|
}
|
||
|
}
|
||
|
ns.shortnames = tmpShortNames.join('|');
|
||
|
|
||
|
// javascript escapes here must be ordered from largest length to shortest
|
||
|
ns.jsEscapeMap = {"\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC69":"1f469-2764-1f48b-1f469","\uD83D\uDC68\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC68":"1f468-2764-1f48b-1f468","\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC68":"1f469-2764-1f48b-1f468","\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67\uDB40\uDC7F":"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f","\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74\uDB40\uDC7F":"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f","\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73\uDB40\uDC7F":"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f","\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC66\u200D\uD83D\uDC66":"1f468-1f468-1f466-1f466","\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66":"1f468-1f468-1f467-1f466","\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC67":"1f468-1f468-1f467-1f467","\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66":"1f468-1f469-1f466-1f466","\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66":"1f468-1f469-1f467-1f466","\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67":"1f468-1f469-1f467-1f467","\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66":"1f469-1f469-1f466-1f466","\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66":"1f469-1f469-1f467-1f466","\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67":"1f469-1f469-1f467-1f467","\uD83D\uDC68\u200D\u2764\u200D\uD83D\uDC8B\u200D\uD83D\uDC68":"1f468-2764-1f48b-1f468","\uD83D\uDC69\u200D\u2764\u200D\uD83D\uDC8B\u200D\uD83D\uDC68":"1f469-2764-1f48b-1f468","\uD83D\uDC69\u200D\u2764\u200D\uD83D\uDC8B\u200D\uD83D\uDC69":"1f469-2764-1f48b-1f469","\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC69":"1f469-2764-1f469","\uD83D\uDC68\u200D\u2764\uFE0F\u200D\uD83D\uDC68":"1f468-2764-1f468","\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC68":"1f469-2764-1f468","\uD83D\uDD75\uFE0F\uD83C\uDFFB\u200D\u2640\uFE0F":"1f575-1f3fb-2640","\uD83D\uDD75\uFE0F\uD83C\uDFFB\u200D\u2642\uFE0F":"1f575-1f3fb-2642","\uD83D\uDD75\uFE0F\uD83C\uDFFC\u200D\u2640\uFE0F":"1f575-1f3fc-2640","\uD83D\uDD75\uFE0F\uD83C\uDFFC\u200D\u2642\uFE0F":"1f575-1f3fc-2642","\uD83D\uDD75\uFE0F\uD83C\uDFFD\u200D\u2640\uFE0F":"1f575-1f3fd-2640","\uD83D\uDD75\uFE0F\uD83C\uDFFD\u200D\u2642\uFE0F":"1f575-1f3fd-2642","\uD83D\uDD75\uFE0F\uD83C\uDFFE\u200D\u2640\uFE0F":"1f575-1f3fe-2640","\uD83D\uDD75\uFE0F\uD83C\uDFFE\u200D\u2642\uFE0F":"1f575-1f3fe-2642","\uD83D\uDD75\uFE0F\uD83C\uDFFF\u200D\u2640\uFE0F":"1f575-1f3ff-2640","\uD83D\uDD75\uFE0F\uD83C\uDFFF\u200D\u2642\uFE0F":"1f575-1f3ff-2642","\uD83C\uDFCB\uFE0F\uD83C\uDFFB\u200D\u2640\uFE0F":"1f3cb-1f3fb-2640","\uD83C\uDFCB\uFE0F\uD83C\uDFFB\u200D\u2642\uFE0F":"1f3cb-1f3fb-2642","\uD83C\uDFCB\uFE0F\uD83C\uDFFC\u200D\u2640\uFE0F":"1f3cb-1f3fc-2640","\uD83C\uDFCB\uFE0F\uD83C\uDFFC\u200D\u2642\uFE0F":"1f3cb-1f3fc-2642","\uD83C\uDFCB\uFE0F\uD83C\uDFFD\u200D\u2640\uFE0F":"1f3cb-1f3fd-2640","\uD83C\uDFCB\uFE0F\uD83C\uDFFD\u200D\u2642\uFE0F":"1f3cb-1f3fd-2642","\uD83C\uDFCB\uFE0F\uD83C\uDFFE\u200D\u2640\uFE0F":"1f3cb-1f3fe-2640","\uD83C\uDFCB\uFE0F\uD83C\uDFFE\u200D\u2642\uFE0F":"1f3cb-1f3fe-2642","\uD83C\uDFCB\uFE0F\uD83C\uDFFF\u200D\u2640\uFE0F":"1f3cb-1f3ff-2640","\uD83C\uDFCB\uFE0F\uD83C\uDFFF\u200D\u2642\uFE0F":"1f3cb-1f3ff-2642","\uD83C\uDFCC\uFE0F\uD83C\uDFFB\u200D\u2640\uFE0F":"1f3cc-1f3fb-2640","\uD83C\uDFCC\uFE0F\uD83C\uDFFB\u200D\u2642\uFE0F":"1f3cc-1f3fb-2642","\uD83C\uDFCC\uFE0F\uD83C\uDFFC\u200D\u2640\uFE0F":"1f3cc-1f3fc-2640","\uD83C\uDFCC\uFE0F\uD83C\uDFFC\u200D\u2642\uFE0F":"1f3cc-1f3fc-2642","\uD83C\uDFCC\uFE0F\uD83C\uDFFD\u200D\u2640\uFE0F":"1f3cc-1f3fd-2640","\uD83C\uDFCC\uFE0F\uD83C\uDFFD\u200D\u2642\uFE0F":"1f3cc-1f3fd-2642","\uD83C\uDFCC\uFE0F\uD83C\uDFFE\u200D\u2640\uFE0F":"1f3cc-1f3fe-2640","\uD83C\uDFCC\uFE0F\uD83C\uDFFE\u200D\u2642\uFE0F":"1f3cc-1f3fe-2642","\uD83C\uDFCC\uFE0F\uD83C\uDFFF\u200D\u2640\uFE0F":"1f3cc-1f3ff-2640","\uD83C\uDFCC\uFE0F\uD83C\uDFFF\u200D\u
|
||
|
|
||
|
ns.jsEscapeMapGreedy = {"\uD83D\uDC69\u2764\uD83D\uDC8B\uD83D\uDC69":"1f469-2764-1f48b-1f469","\uD83D\uDC68\u2764\uD83D\uDC8B\uD83D\uDC68":"1f468-2764-1f48b-1f468","\uD83D\uDC69\u2764\uD83D\uDC8B\uD83D\uDC68":"1f469-2764-1f48b-1f468","\uD83D\uDC69\u2764\uD83D\uDC69":"1f469-2764-1f469","\uD83D\uDC68\u2764\uD83D\uDC68":"1f468-2764-1f468","\uD83C\uDFCC\uD83C\uDFFB\u2642":"1f3cc-1f3fb-2642","\uD83C\uDFCC\uD83C\uDFFC\u2642":"1f3cc-1f3fc-2642","\uD83C\uDFCC\uD83C\uDFFD\u2642":"1f3cc-1f3fd-2642","\uD83C\uDFCC\uD83C\uDFFE\u2642":"1f3cc-1f3fe-2642","\uD83C\uDFCC\uD83C\uDFFF\u2642":"1f3cc-1f3ff-2642","\uD83C\uDFCC\uD83C\uDFFB\u2640":"1f3cc-1f3fb-2640","\uD83C\uDFCC\uD83C\uDFFC\u2640":"1f3cc-1f3fc-2640","\uD83C\uDFCC\uD83C\uDFFD\u2640":"1f3cc-1f3fd-2640","\uD83C\uDFCC\uD83C\uDFFE\u2640":"1f3cc-1f3fe-2640","\uD83C\uDFCC\uD83C\uDFFF\u2640":"1f3cc-1f3ff-2640","\uD83D\uDC68\uD83C\uDFFB\u2696":"1f468-1f3fb-2696","\uD83D\uDC68\uD83C\uDFFC\u2696":"1f468-1f3fc-2696","\uD83D\uDC68\uD83C\uDFFD\u2696":"1f468-1f3fd-2696","\uD83D\uDC68\uD83C\uDFFE\u2696":"1f468-1f3fe-2696","\uD83D\uDC68\uD83C\uDFFF\u2696":"1f468-1f3ff-2696","\uD83D\uDC69\uD83C\uDFFB\u2696":"1f469-1f3fb-2696","\uD83D\uDC69\uD83C\uDFFC\u2696":"1f469-1f3fc-2696","\uD83D\uDC69\uD83C\uDFFD\u2696":"1f469-1f3fd-2696","\uD83D\uDC69\uD83C\uDFFE\u2696":"1f469-1f3fe-2696","\uD83D\uDC69\uD83C\uDFFF\u2696":"1f469-1f3ff-2696","\uD83D\uDC68\uD83C\uDFFB\u2708":"1f468-1f3fb-2708","\uD83D\uDC68\uD83C\uDFFC\u2708":"1f468-1f3fc-2708","\uD83D\uDC68\uD83C\uDFFD\u2708":"1f468-1f3fd-2708","\uD83D\uDC68\uD83C\uDFFE\u2708":"1f468-1f3fe-2708","\uD83D\uDC68\uD83C\uDFFF\u2708":"1f468-1f3ff-2708","\uD83D\uDC69\uD83C\uDFFB\u2708":"1f469-1f3fb-2708","\uD83D\uDC69\uD83C\uDFFC\u2708":"1f469-1f3fc-2708","\uD83D\uDC69\uD83C\uDFFD\u2708":"1f469-1f3fd-2708","\uD83D\uDC69\uD83C\uDFFE\u2708":"1f469-1f3fe-2708","\uD83D\uDC69\uD83C\uDFFF\u2708":"1f469-1f3ff-2708","\uD83D\uDC69\u2764\uD83D\uDC68":"1f469-2764-1f468","\uD83D\uDC68\uD83C\uDFFB\u2695":"1f468-1f3fb-2695","\uD83D\uDC68\uD83C\uDFFC\u2695":"1f468-1f3fc-2695","\uD83D\uDC68\uD83C\uDFFD\u2695":"1f468-1f3fd-2695","\uD83D\uDC68\uD83C\uDFFE\u2695":"1f468-1f3fe-2695","\uD83D\uDC68\uD83C\uDFFF\u2695":"1f468-1f3ff-2695","\uD83D\uDC69\uD83C\uDFFB\u2695":"1f469-1f3fb-2695","\uD83D\uDC69\uD83C\uDFFC\u2695":"1f469-1f3fc-2695","\uD83D\uDC69\uD83C\uDFFD\u2695":"1f469-1f3fd-2695","\uD83D\uDC69\uD83C\uDFFE\u2695":"1f469-1f3fe-2695","\uD83D\uDC69\uD83C\uDFFF\u2695":"1f469-1f3ff-2695","\uD83D\uDC6E\uD83C\uDFFB\u2640":"1f46e-1f3fb-2640","\uD83D\uDC6E\uD83C\uDFFB\u2642":"1f46e-1f3fb-2642","\uD83D\uDC6E\uD83C\uDFFC\u2640":"1f46e-1f3fc-2640","\uD83D\uDC6E\uD83C\uDFFC\u2642":"1f46e-1f3fc-2642","\uD83D\uDC6E\uD83C\uDFFD\u2640":"1f46e-1f3fd-2640","\uD83D\uDC6E\uD83C\uDFFD\u2642":"1f46e-1f3fd-2642","\uD83D\uDC6E\uD83C\uDFFE\u2640":"1f46e-1f3fe-2640","\uD83D\uDC6E\uD83C\uDFFE\u2642":"1f46e-1f3fe-2642","\uD83D\uDC6E\uD83C\uDFFF\u2640":"1f46e-1f3ff-2640","\uD83D\uDC6E\uD83C\uDFFF\u2642":"1f46e-1f3ff-2642","\uD83D\uDC71\uD83C\uDFFB\u2640":"1f471-1f3fb-2640","\uD83D\uDC71\uD83C\uDFFB\u2642":"1f471-1f3fb-2642","\uD83D\uDC71\uD83C\uDFFC\u2640":"1f471-1f3fc-2640","\uD83D\uDC71\uD83C\uDFFC\u2642":"1f471-1f3fc-2642","\uD83D\uDC71\uD83C\uDFFD\u2640":"1f471-1f3fd-2640","\uD83D\uDC71\uD83C\uDFFD\u2642":"1f471-1f3fd-2642","\uD83D\uDC71\uD83C\uDFFE\u2640":"1f471-1f3fe-2640","\uD83D\uDC71\uD83C\uDFFE\u2642":"1f471-1f3fe-2642","\uD83D\uDC71\uD83C\uDFFF\u2640":"1f471-1f3ff-2640","\uD83D\uDC71\uD83C\uDFFF\u2642":"1f471-1f3ff-2642","\uD83D\uDC73\uD83C\uDFFB\u2640":"1f473-1f3fb-2640","\uD83D\uDC73\uD83C\uDFFB\u2642":"1f473-1f3fb-2642","\uD83D\uDC73\uD83C\uDFFC\u2640":"1f473-1f3fc-2640","\uD83D\uDC73\uD83C\uDFFC\u2642":"1f473-1f3fc-2642","\uD83D\uDC73\uD83C\uDFFD\u2640":"1f473-1f3fd-2640","\uD83D\uDC73\uD83C\uDFFD\u2642":"1f473-1f3fd-2642","\uD83D\uDC73\uD83C\uDFFE\u2640":"1f473-1f3fe-2640","\uD83D\uDC73\uD83C\uDFFE\u2642":"1f473-1f3fe-2642","\uD83D\uDC73\uD83C\uDFFF\u2640":"1f473-1f3ff-2640","\uD83D\uDC73\uD83C\uDFFF\u2642":"1f473-1f3ff-2642","\uD83D\uDC77\uD83C\uDFFB\u2640":"1f477-1f3fb-2640","\uD83D\u
|
||
|
|
||
|
ns.asciiList = {
|
||
|
'*\\0/*':'1f646',
|
||
|
'*\\O/*':'1f646',
|
||
|
'-___-':'1f611',
|
||
|
':\'-)':'1f602',
|
||
|
'\':-)':'1f605',
|
||
|
'\':-D':'1f605',
|
||
|
'>:-)':'1f606',
|
||
|
'\':-(':'1f613',
|
||
|
'>:-(':'1f620',
|
||
|
':\'-(':'1f622',
|
||
|
'O:-)':'1f607',
|
||
|
'0:-3':'1f607',
|
||
|
'0:-)':'1f607',
|
||
|
'0;^)':'1f607',
|
||
|
'O;-)':'1f607',
|
||
|
'0;-)':'1f607',
|
||
|
'O:-3':'1f607',
|
||
|
'-__-':'1f611',
|
||
|
':-Þ':'1f61b',
|
||
|
'</3':'1f494',
|
||
|
':\')':'1f602',
|
||
|
':-D':'1f603',
|
||
|
'\':)':'1f605',
|
||
|
'\'=)':'1f605',
|
||
|
'\':D':'1f605',
|
||
|
'\'=D':'1f605',
|
||
|
'>:)':'1f606',
|
||
|
'>;)':'1f606',
|
||
|
'>=)':'1f606',
|
||
|
';-)':'1f609',
|
||
|
'*-)':'1f609',
|
||
|
';-]':'1f609',
|
||
|
';^)':'1f609',
|
||
|
'\':(':'1f613',
|
||
|
'\'=(':'1f613',
|
||
|
':-*':'1f618',
|
||
|
':^*':'1f618',
|
||
|
'>:P':'1f61c',
|
||
|
'X-P':'1f61c',
|
||
|
'>:[':'1f61e',
|
||
|
':-(':'1f61e',
|
||
|
':-[':'1f61e',
|
||
|
'>:(':'1f620',
|
||
|
':\'(':'1f622',
|
||
|
';-(':'1f622',
|
||
|
'>.<':'1f623',
|
||
|
'#-)':'1f635',
|
||
|
'%-)':'1f635',
|
||
|
'X-)':'1f635',
|
||
|
'\\0/':'1f646',
|
||
|
'\\O/':'1f646',
|
||
|
'0:3':'1f607',
|
||
|
'0:)':'1f607',
|
||
|
'O:)':'1f607',
|
||
|
'O=)':'1f607',
|
||
|
'O:3':'1f607',
|
||
|
'B-)':'1f60e',
|
||
|
'8-)':'1f60e',
|
||
|
'B-D':'1f60e',
|
||
|
'8-D':'1f60e',
|
||
|
'-_-':'1f611',
|
||
|
'>:\\':'1f615',
|
||
|
'>:/':'1f615',
|
||
|
':-/':'1f615',
|
||
|
':-.':'1f615',
|
||
|
':-P':'1f61b',
|
||
|
':Þ':'1f61b',
|
||
|
':-b':'1f61b',
|
||
|
':-O':'1f62e',
|
||
|
'O_O':'1f62e',
|
||
|
'>:O':'1f62e',
|
||
|
':-X':'1f636',
|
||
|
':-#':'1f636',
|
||
|
':-)':'1f642',
|
||
|
'(y)':'1f44d',
|
||
|
'<3':'2764',
|
||
|
':D':'1f603',
|
||
|
'=D':'1f603',
|
||
|
';)':'1f609',
|
||
|
'*)':'1f609',
|
||
|
';]':'1f609',
|
||
|
';D':'1f609',
|
||
|
':*':'1f618',
|
||
|
'=*':'1f618',
|
||
|
':(':'1f61e',
|
||
|
':[':'1f61e',
|
||
|
'=(':'1f61e',
|
||
|
':@':'1f620',
|
||
|
';(':'1f622',
|
||
|
'D:':'1f628',
|
||
|
':$':'1f633',
|
||
|
'=$':'1f633',
|
||
|
'#)':'1f635',
|
||
|
'%)':'1f635',
|
||
|
'X)':'1f635',
|
||
|
'B)':'1f60e',
|
||
|
'8)':'1f60e',
|
||
|
':/':'1f615',
|
||
|
':\\':'1f615',
|
||
|
'=/':'1f615',
|
||
|
'=\\':'1f615',
|
||
|
':L':'1f615',
|
||
|
'=L':'1f615',
|
||
|
':P':'1f61b',
|
||
|
'=P':'1f61b',
|
||
|
':b':'1f61b',
|
||
|
':O':'1f62e',
|
||
|
':X':'1f636',
|
||
|
':#':'1f636',
|
||
|
'=X':'1f636',
|
||
|
'=#':'1f636',
|
||
|
':)':'1f642',
|
||
|
'=]':'1f642',
|
||
|
'=)':'1f642',
|
||
|
':]':'1f642'
|
||
|
};
|
||
|
|
||
|
ns.asciiRegexp = '(\\*\\\\0\\/\\*|\\*\\\\O\\/\\*|\\-___\\-|\\:\'\\-\\)|\'\\:\\-\\)|\'\\:\\-D|\\>\\:\\-\\)|>\\:\\-\\)|\'\\:\\-\\(|\\>\\:\\-\\(|>\\:\\-\\(|\\:\'\\-\\(|O\\:\\-\\)|0\\:\\-3|0\\:\\-\\)|0;\\^\\)|O;\\-\\)|0;\\-\\)|O\\:\\-3|\\-__\\-|\\:\\-Þ|\\:\\-Þ|\\<\\/3|<\\/3|\\:\'\\)|\\:\\-D|\'\\:\\)|\'\\=\\)|\'\\:D|\'\\=D|\\>\\:\\)|>\\:\\)|\\>;\\)|>;\\)|\\>\\=\\)|>\\=\\)|;\\-\\)|\\*\\-\\)|;\\-\\]|;\\^\\)|\'\\:\\(|\'\\=\\(|\\:\\-\\*|\\:\\^\\*|\\>\\:P|>\\:P|X\\-P|\\>\\:\\[|>\\:\\[|\\:\\-\\(|\\:\\-\\[|\\>\\:\\(|>\\:\\(|\\:\'\\(|;\\-\\(|\\>\\.\\<|>\\.<|#\\-\\)|%\\-\\)|X\\-\\)|\\\\0\\/|\\\\O\\/|0\\:3|0\\:\\)|O\\:\\)|O\\=\\)|O\\:3|B\\-\\)|8\\-\\)|B\\-D|8\\-D|\\-_\\-|\\>\\:\\\\|>\\:\\\\|\\>\\:\\/|>\\:\\/|\\:\\-\\/|\\:\\-\\.|\\:\\-P|\\:Þ|\\:Þ|\\:\\-b|\\:\\-O|O_O|\\>\\:O|>\\:O|\\:\\-X|\\:\\-#|\\:\\-\\)|\\(y\\)|\\<3|<3|\\:D|\\=D|;\\)|\\*\\)|;\\]|;D|\\:\\*|\\=\\*|\\:\\(|\\:\\[|\\=\\(|\\:@|;\\(|D\\:|\\:\\$|\\=\\$|#\\)|%\\)|X\\)|B\\)|8\\)|\\:\\/|\\:\\\\|\\=\\/|\\=\\\\|\\:L|\\=L|\\:P|\\=P|\\:b|\\:O|\\:X|\\:#|\\=X|\\=#|\\:\\)|\\=\\]|\\=\\)|\\:\\])';
|
||
|
|
||
|
ns.emojiVersion = '3.1'; // you can [optionally] modify this to load alternate emoji versions. see readme for backwards compatibility and version options
|
||
|
ns.emojiSize = '32';
|
||
|
ns.greedyMatch = false; // set to true for greedy unicode matching
|
||
|
ns.imagePathPNG = 'https://cdn.jsdelivr.net/emojione/assets/' + ns.emojiVersion + '/png/';
|
||
|
ns.defaultPathPNG = ns.imagePathPNG;
|
||
|
ns.imageTitleTag = true; // set to false to remove title attribute from img tag
|
||
|
ns.sprites = false; // if this is true then sprite markup will be used
|
||
|
ns.spriteSize = '32';
|
||
|
ns.unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better)
|
||
|
ns.ascii = false; // change to true to convert ascii smileys
|
||
|
ns.riskyMatchAscii = false; // set true to match ascii without leading/trailing space char
|
||
|
|
||
|
ns.regShortNames = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|("+ns.shortnames+")", "gi");
|
||
|
ns.regAscii = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|((\\s|^)"+ns.asciiRegexp+"(?=\\s|$|[!,.?]))", "gi");
|
||
|
ns.regAsciiRisky = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(()"+ns.asciiRegexp+"())", "gi");
|
||
|
|
||
|
ns.regUnicode = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(?:\uD83C\uDFF3)\uFE0F?\u200D?(?:\uD83C\uDF08)|(?:\uD83D\uDC41)\uFE0F?\u200D?(?:\uD83D\uDDE8)\uFE0F?|[#-9]\uFE0F?\u20E3|(?:(?:\uD83C\uDFF4)(?:\uDB40[\uDC60-\uDCFF]){1,6})|(?:\uD83C[\uDDE0-\uDDFF]){2}|(?:(?:\uD83D[\uDC68\uDC69]))\uFE0F?(?:\uD83C[\uDFFA-\uDFFF])?\u200D?(?:[\u2695\u2696\u2708]|\uD83C[\uDF3E-\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83D[\uDC68\uDC69]|\uD83E[\uDDD0-\uDDDF])(?:\uD83C[\uDFFA-\uDFFF])?\u200D?[\u2640\u2642\u2695\u2696\u2708]?\uFE0F?|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])[\u200D\uFE0F]{0,2}){1,3}(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])\uFE0F?){2,4}|(?:\uD83D[\uDC68\uDC69\uDC6E\uDC71-\uDC87\uDD75\uDE45-\uDE4E]|\uD83E[\uDD26\uDD37]|\uD83C[\uDFC3-\uDFCC]|\uD83E[\uDD38-\uDD3E]|\uD83D[\uDEA3-\uDEB6]|\u26f9|\uD83D\uDC6F)\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])?\u200D?[\u2640\u2642]?\uFE0F?|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85-\uDFCC]|\uD83D[\uDC42-\uDCAA\uDD74-\uDD96\uDE45-\uDE4F\uDEA3-\uDECC]|\uD83E[\uDD18-\uDD3E])\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u2194-\u2199\u21a9-\u21aa]\uFE0F?|[\u0023\u002a]|[\u3030\u303d]\uFE0F?|(?:\ud83c[\udd70-\udd71]|\ud83c\udd8e|\ud83c[\udd91-\udd9a])\uFE0F?|\u24c2\uFE0F?|[\u3297\u3299]\uFE0F?|(?:\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51])\uFE0F?|[\u203c\u2049]\uFE0F?|[\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe]\uFE0F?|[\u00a9\u00ae]\uFE0F?|[\u2122\u2139]\uFE0F?|\ud83c\udc04\uFE0F?|[\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55]\uFE0F?|[\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa]\uFE0F?|\ud83c\udccf|[\u2934\u2935]\uFE0F?)|[\u2700-\u27bf]\uFE0F?|[\ud800-\udbff][\udc00-\udfff]\uFE0F?|[\u2600-\u26FF]\uFE0F?|[\u0030-\u0039]\uFE0F", "g");
|
||
|
|
||
|
ns.toImage = function(str) {
|
||
|
str = ns.unicodeToImage(str);
|
||
|
str = ns.shortnameToImage(str);
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
// Uses toShort to transform all unicode into a standard shortname
|
||
|
// then transforms the shortname into unicode
|
||
|
// This is done for standardization when converting several unicode types
|
||
|
ns.unifyUnicode = function(str) {
|
||
|
str = ns.toShort(str);
|
||
|
str = ns.shortnameToUnicode(str);
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
// Replace shortnames (:wink:) with Ascii equivalents ( ;^) )
|
||
|
// Useful for systems that dont support unicode nor images
|
||
|
ns.shortnameToAscii = function(str) {
|
||
|
var unicode,
|
||
|
// something to keep in mind here is that array flip will destroy
|
||
|
// half of the ascii text "emojis" because the unicode numbers are duplicated
|
||
|
// this is ok for what it's being used for
|
||
|
unicodeToAscii = ns.objectFlip(ns.asciiList);
|
||
|
|
||
|
str = str.replace(ns.regShortNames, function(shortname) {
|
||
|
if( (typeof shortname === 'undefined') || (shortname === '') || (!(shortname in ns.emojioneList)) ) {
|
||
|
// if the shortname doesnt exist just return the entire match
|
||
|
return shortname;
|
||
|
}
|
||
|
else {
|
||
|
unicode = ns.emojioneList[shortname].uc_output;
|
||
|
if(typeof unicodeToAscii[unicode] !== 'undefined') {
|
||
|
return unicodeToAscii[unicode];
|
||
|
} else {
|
||
|
return shortname;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
// will output unicode from shortname
|
||
|
// useful for sending emojis back to mobile devices
|
||
|
ns.shortnameToUnicode = function(str) {
|
||
|
// replace regular shortnames first
|
||
|
var unicode,fname;
|
||
|
str = str.replace(ns.regShortNames, function(shortname) {
|
||
|
if( (typeof shortname === 'undefined') || (shortname === '') || (!(shortname in ns.emojioneList)) ) {
|
||
|
// if the shortname doesnt exist just return the entire matchhju
|
||
|
return shortname;
|
||
|
}
|
||
|
unicode = ns.emojioneList[shortname].uc_output.toUpperCase();
|
||
|
fname = ns.emojioneList[shortname].uc_base;
|
||
|
return ns.convert(unicode);
|
||
|
});
|
||
|
|
||
|
// if ascii smileys are turned on, then we'll replace them!
|
||
|
if (ns.ascii) {
|
||
|
|
||
|
var asciiRX = ns.riskyMatchAscii ? ns.regAsciiRisky : ns.regAscii;
|
||
|
|
||
|
str = str.replace(asciiRX, function(entire, m1, m2, m3) {
|
||
|
if( (typeof m3 === 'undefined') || (m3 === '') || (!(ns.unescapeHTML(m3) in ns.asciiList)) ) {
|
||
|
// if the ascii doesnt exist just return the entire match
|
||
|
return entire;
|
||
|
}
|
||
|
|
||
|
m3 = ns.unescapeHTML(m3);
|
||
|
unicode = ns.asciiList[m3].toUpperCase();
|
||
|
return m2+ns.convert(unicode);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
ns.shortnameToImage = function(str) {
|
||
|
// replace regular shortnames first
|
||
|
var replaceWith,shortname,unicode,fname,alt,category,title,size,ePath;
|
||
|
var mappedUnicode = ns.mapUnicodeToShort();
|
||
|
str = str.replace(ns.regShortNames, function(shortname) {
|
||
|
if( (typeof shortname === 'undefined') || (shortname === '') || (ns.shortnames.indexOf(shortname) === -1) ) {
|
||
|
// if the shortname doesnt exist just return the entire match
|
||
|
return shortname;
|
||
|
}
|
||
|
else {
|
||
|
// map shortname to parent
|
||
|
if (!ns.emojioneList[shortname]) {
|
||
|
for ( var emoji in ns.emojioneList ) {
|
||
|
if (!ns.emojioneList.hasOwnProperty(emoji) || (emoji === '')) continue;
|
||
|
if (ns.emojioneList[emoji].shortnames.indexOf(shortname) === -1) continue;
|
||
|
shortname = emoji;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
unicode = ns.emojioneList[shortname].uc_output;
|
||
|
fname = ns.emojioneList[shortname].uc_base;
|
||
|
category = (fname.includes("-1f3f")) ? 'diversity' : ns.emojioneList[shortname].category;
|
||
|
title = ns.imageTitleTag ? 'title="' + shortname + '"' : '';
|
||
|
size = (ns.spriteSize == '32' || ns.spriteSize == '64') ? ns.spriteSize : '32';
|
||
|
//if the image path has not changed, we'll assume the default cdn path, otherwise we'll assume the provided path
|
||
|
ePath = (ns.imagePathPNG != ns.defaultPathPNG) ? ns.imagePathPNG : ns.defaultPathPNG + ns.emojiSize + '/';
|
||
|
|
||
|
// depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname
|
||
|
alt = (ns.unicodeAlt) ? ns.convert(unicode.toUpperCase()) : shortname;
|
||
|
|
||
|
if(ns.sprites) {
|
||
|
replaceWith = '<span class="emojione emojione-' + size + '-' + category + ' _' + fname + '" ' + title + '>' + alt + '</span>';
|
||
|
}
|
||
|
else {
|
||
|
replaceWith = '<img class="emojione" alt="' + alt + '" ' + title + ' src="' + ePath + fname + '.png"/>';
|
||
|
}
|
||
|
|
||
|
return replaceWith;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// if ascii smileys are turned on, then we'll replace them!
|
||
|
if (ns.ascii) {
|
||
|
|
||
|
var asciiRX = ns.riskyMatchAscii ? ns.regAsciiRisky : ns.regAscii;
|
||
|
|
||
|
str = str.replace(asciiRX, function(entire, m1, m2, m3) {
|
||
|
if( (typeof m3 === 'undefined') || (m3 === '') || (!(ns.unescapeHTML(m3) in ns.asciiList)) ) {
|
||
|
// if the ascii doesnt exist just return the entire match
|
||
|
return entire;
|
||
|
}
|
||
|
|
||
|
m3 = ns.unescapeHTML(m3);
|
||
|
unicode = ns.asciiList[m3];
|
||
|
shortname = mappedUnicode[unicode];
|
||
|
category = (unicode.includes("-1f3f")) ? 'diversity' : ns.emojioneList[shortname].category;
|
||
|
title = ns.imageTitleTag ? 'title="' + ns.escapeHTML(m3) + '"' : '';
|
||
|
size = (ns.spriteSize == '32' || ns.spriteSize == '64') ? ns.spriteSize : '32';
|
||
|
//if the image path has not changed, we'll assume the default cdn path, otherwise we'll assume the provided path
|
||
|
ePath = (ns.imagePathPNG != ns.defaultPathPNG) ? ns.imagePathPNG : ns.defaultPathPNG + ns.emojiSize + '/';
|
||
|
|
||
|
// depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname
|
||
|
alt = (ns.unicodeAlt) ? ns.convert(unicode.toUpperCase()) : ns.escapeHTML(m3);
|
||
|
|
||
|
if(ns.sprites) {
|
||
|
replaceWith = m2+'<span class="emojione emojione-' + size + '-' + category + ' _' + unicode +'" ' + title + '>' + alt + '</span>';
|
||
|
}
|
||
|
else {
|
||
|
replaceWith = m2+'<img class="emojione" alt="'+alt+'" ' + title + ' src="' + ePath + unicode + '.png"/>';
|
||
|
}
|
||
|
|
||
|
return replaceWith;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
ns.unicodeToImage = function(str) {
|
||
|
|
||
|
var replaceWith,unicode,short,fname,alt,category,title,size,ePath;
|
||
|
var mappedUnicode = ns.mapUnicodeToShort();
|
||
|
var eList = ns.emojioneList;
|
||
|
str = str.replace(ns.regUnicode, function(unicodeChar) {
|
||
|
if( (typeof unicodeChar === 'undefined') || (unicodeChar === '') )
|
||
|
{
|
||
|
return unicodeChar;
|
||
|
}
|
||
|
else if ( unicodeChar in ns.jsEscapeMap )
|
||
|
{
|
||
|
fname = ns.jsEscapeMap[unicodeChar];
|
||
|
}
|
||
|
else if ( ns.greedyMatch && unicodeChar in ns.jsEscapeMapGreedy )
|
||
|
{
|
||
|
fname = ns.jsEscapeMapGreedy[unicodeChar];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return unicodeChar;
|
||
|
}
|
||
|
|
||
|
// then map to shortname and locate the filename
|
||
|
short = mappedUnicode[fname];
|
||
|
|
||
|
// then pull the unicode output from emojioneList
|
||
|
fname = eList[short].uc_base;
|
||
|
unicode = eList[short].uc_output;
|
||
|
category = (fname.includes("-1f3f")) ? 'diversity' : eList[short].category;
|
||
|
size = (ns.spriteSize == '32' || ns.spriteSize == '64') ? ns.spriteSize : '32';
|
||
|
//if the image path has not changed, we'll assume the default cdn path, otherwise we'll assume the provided path
|
||
|
ePath = (ns.imagePathPNG != ns.defaultPathPNG) ? ns.imagePathPNG : ns.defaultPathPNG + ns.emojiSize + '/';
|
||
|
|
||
|
// depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname
|
||
|
alt = (ns.unicodeAlt) ? ns.convert(unicode.toUpperCase()) : short;
|
||
|
title = ns.imageTitleTag ? 'title="' + short + '"' : '';
|
||
|
|
||
|
if(ns.sprites) {
|
||
|
replaceWith = '<span class="emojione emojione-' + size + '-' + category + ' _' + fname + '" ' + title + '>' + alt + '</span>';
|
||
|
}
|
||
|
else {
|
||
|
replaceWith = '<img class="emojione" alt="' + alt + '" ' + title + ' src="' + ePath + fname + '.png"/>';
|
||
|
}
|
||
|
|
||
|
return replaceWith;
|
||
|
});
|
||
|
|
||
|
// if ascii smileys are turned on, then we'll replace them!
|
||
|
if (ns.ascii) {
|
||
|
|
||
|
var asciiRX = ns.riskyMatchAscii ? ns.regAsciiRisky : ns.regAscii;
|
||
|
|
||
|
str = str.replace(asciiRX, function(entire, m1, m2, m3) {
|
||
|
if( (typeof m3 === 'undefined') || (m3 === '') || (!(ns.unescapeHTML(m3) in ns.asciiList)) ) {
|
||
|
// if the ascii doesnt exist just return the entire match
|
||
|
return entire;
|
||
|
}
|
||
|
|
||
|
m3 = ns.unescapeHTML(m3);
|
||
|
unicode = ns.asciiList[m3];
|
||
|
shortname = mappedUnicode[unicode];
|
||
|
category = (unicode.includes("-1f3f")) ? 'diversity' : ns.emojioneList[shortname].category;
|
||
|
title = ns.imageTitleTag ? 'title="' + ns.escapeHTML(m3) + '"' : '';
|
||
|
size = (ns.spriteSize == '32' || ns.spriteSize == '64') ? ns.spriteSize : '32';
|
||
|
//if the image path has not changed, we'll assume the default cdn path, otherwise we'll assume the provided path
|
||
|
ePath = (ns.imagePathPNG != ns.defaultPathPNG) ? ns.imagePathPNG : ns.defaultPathPNG + ns.emojiSize + '/';
|
||
|
|
||
|
// depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname
|
||
|
alt = (ns.unicodeAlt) ? ns.convert(unicode.toUpperCase()) : ns.escapeHTML(m3);
|
||
|
|
||
|
if(ns.sprites) {
|
||
|
replaceWith = m2+'<span class="emojione emojione-' + size + '-' + category + ' _' + unicode +'" ' + title + '>' + alt + '</span>';
|
||
|
}
|
||
|
else {
|
||
|
replaceWith = m2+'<img class="emojione" alt="'+alt+'" ' + title + ' src="' + ePath + unicode + '.png"/>';
|
||
|
}
|
||
|
|
||
|
return replaceWith;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return str;
|
||
|
};
|
||
|
|
||
|
// this is really just unicodeToShortname() but I opted for the shorthand name to match toImage()
|
||
|
ns.toShort = function(str) {
|
||
|
var find = ns.unicodeCharRegex();
|
||
|
return ns.replaceAll(str, find);
|
||
|
};
|
||
|
|
||
|
// for converting unicode code points and code pairs to their respective characters
|
||
|
ns.convert = function(unicode) {
|
||
|
if(unicode.indexOf("-") > -1) {
|
||
|
var parts = [];
|
||
|
var s = unicode.split('-');
|
||
|
for(var i = 0; i < s.length; i++) {
|
||
|
var part = parseInt(s[i], 16);
|
||
|
if (part >= 0x10000 && part <= 0x10FFFF) {
|
||
|
var hi = Math.floor((part - 0x10000) / 0x400) + 0xD800;
|
||
|
var lo = ((part - 0x10000) % 0x400) + 0xDC00;
|
||
|
part = (String.fromCharCode(hi) + String.fromCharCode(lo));
|
||
|
}
|
||
|
else {
|
||
|
part = String.fromCharCode(part);
|
||
|
}
|
||
|
parts.push(part);
|
||
|
}
|
||
|
return parts.join('');
|
||
|
}
|
||
|
else {
|
||
|
var s = parseInt(unicode, 16);
|
||
|
if (s >= 0x10000 && s <= 0x10FFFF) {
|
||
|
var hi = Math.floor((s - 0x10000) / 0x400) + 0xD800;
|
||
|
var lo = ((s - 0x10000) % 0x400) + 0xDC00;
|
||
|
return (String.fromCharCode(hi) + String.fromCharCode(lo));
|
||
|
}
|
||
|
else {
|
||
|
return String.fromCharCode(s);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
ns.escapeHTML = function (string) {
|
||
|
var escaped = {
|
||
|
'&' : '&',
|
||
|
'<' : '<',
|
||
|
'>' : '>',
|
||
|
'"' : '"',
|
||
|
'\'': '''
|
||
|
};
|
||
|
|
||
|
return string.replace(/[&<>"']/g, function (match) {
|
||
|
return escaped[match];
|
||
|
});
|
||
|
};
|
||
|
ns.unescapeHTML = function (string) {
|
||
|
var unescaped = {
|
||
|
'&' : '&',
|
||
|
'&' : '&',
|
||
|
'&' : '&',
|
||
|
'<' : '<',
|
||
|
'<' : '<',
|
||
|
'<' : '<',
|
||
|
'>' : '>',
|
||
|
'>' : '>',
|
||
|
'>' : '>',
|
||
|
'"' : '"',
|
||
|
'"' : '"',
|
||
|
'"' : '"',
|
||
|
''' : '\'',
|
||
|
''' : '\'',
|
||
|
''' : '\''
|
||
|
};
|
||
|
|
||
|
return string.replace(/&(?:amp|#38|#x26|lt|#60|#x3C|gt|#62|#x3E|apos|#39|#x27|quot|#34|#x22);/ig, function (match) {
|
||
|
return unescaped[match];
|
||
|
});
|
||
|
};
|
||
|
|
||
|
ns.shortnameConversionMap = function() {
|
||
|
var map = [], emoji;
|
||
|
for (emoji in ns.emojioneList) {
|
||
|
if (!ns.emojioneList.hasOwnProperty(emoji) || (emoji === '')) continue;
|
||
|
map[ns.convert(ns.emojioneList[emoji].uc_output)] = emoji;
|
||
|
}
|
||
|
return map;
|
||
|
};
|
||
|
|
||
|
ns.unicodeCharRegex = function() {
|
||
|
var map = [];
|
||
|
for (emoji in ns.emojioneList) {
|
||
|
if (!ns.emojioneList.hasOwnProperty(emoji) || (emoji === '')) continue;
|
||
|
map.push(ns.convert(ns.emojioneList[emoji].uc_output));
|
||
|
}
|
||
|
return map.join('|');
|
||
|
};
|
||
|
|
||
|
ns.mapEmojioneList = function (addToMapStorage) {
|
||
|
for (var shortname in ns.emojioneList) {
|
||
|
if (!ns.emojioneList.hasOwnProperty(shortname)) { continue; }
|
||
|
var unicode = ns.emojioneList[shortname].uc_base;
|
||
|
addToMapStorage(unicode, shortname);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
ns.mapUnicodeToShort = function() {
|
||
|
if (!ns.memMapShortToUnicode) {
|
||
|
ns.memMapShortToUnicode = {};
|
||
|
ns.mapEmojioneList(function (unicode, shortname) {
|
||
|
ns.memMapShortToUnicode[unicode] = shortname;
|
||
|
});
|
||
|
}
|
||
|
return ns.memMapShortToUnicode;
|
||
|
};
|
||
|
|
||
|
ns.memorizeReplacement = function() {
|
||
|
if (!ns.unicodeReplacementRegEx || !ns.memMapShortToUnicodeCharacters) {
|
||
|
var unicodeList = [];
|
||
|
ns.memMapShortToUnicodeCharacters = {};
|
||
|
ns.mapEmojioneList(function (unicode, shortname) {
|
||
|
var emojiCharacter = ns.convert(unicode);
|
||
|
ns.memMapShortToUnicodeCharacters[emojiCharacter] = shortname;
|
||
|
unicodeList.push(emojiCharacter);
|
||
|
});
|
||
|
ns.unicodeReplacementRegEx = unicodeList.join('|');
|
||
|
}
|
||
|
};
|
||
|
|
||
|
ns.mapUnicodeCharactersToShort = function() {
|
||
|
ns.memorizeReplacement();
|
||
|
return ns.memMapShortToUnicodeCharacters;
|
||
|
};
|
||
|
|
||
|
//reverse an object
|
||
|
ns.objectFlip = function (obj) {
|
||
|
var key, tmp_obj = {};
|
||
|
|
||
|
for (key in obj) {
|
||
|
if (obj.hasOwnProperty(key)) {
|
||
|
tmp_obj[obj[key]] = key;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return tmp_obj;
|
||
|
};
|
||
|
|
||
|
ns.escapeRegExp = function(string) {
|
||
|
return string.replace(/[-[\]{}()*+?.,;:&\\^$#\s]/g, "\\$&");
|
||
|
};
|
||
|
|
||
|
ns.replaceAll = function(string, find) {
|
||
|
var escapedFind = ns.escapeRegExp(find); //sorted largest output to smallest output
|
||
|
var search = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|("+escapedFind+")", "gi");
|
||
|
|
||
|
// callback prevents replacing anything inside of these common html tags as well as between an <object></object> tag
|
||
|
|
||
|
var replace = function(entire, m1) {
|
||
|
return ((typeof m1 === 'undefined') || (m1 === '')) ? entire : ns.shortnameConversionMap()[m1];
|
||
|
};
|
||
|
|
||
|
return string.replace(search,replace);
|
||
|
};
|
||
|
|
||
|
}(this.emojione = this.emojione || {}));
|
||
|
if(typeof module === "object") module.exports = this.emojione;
|