2016-02-15 21:53:37 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
|
|
|
|
;(function() {
|
|
|
|
'use strict';
|
|
|
|
window.emoji_util = window.emoji_util || {};
|
|
|
|
|
2016-09-01 19:21:23 +00:00
|
|
|
// EmojiConverter overrides
|
2016-09-01 06:32:17 +00:00
|
|
|
EmojiConvertor.prototype.init_env = function() {
|
|
|
|
if (this.inits.env) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-01 19:21:23 +00:00
|
|
|
this.inits.env = 1;
|
2016-09-01 06:32:17 +00:00
|
|
|
this.include_title = true;
|
2016-09-01 20:31:36 +00:00
|
|
|
this.img_sets.apple.path = '/images/emoji/apple/';
|
2016-09-01 06:32:17 +00:00
|
|
|
this.replace_mode = 'img';
|
2016-09-01 19:21:23 +00:00
|
|
|
};
|
|
|
|
EmojiConvertor.prototype.replace_unified = function(str) {
|
|
|
|
var self = this;
|
|
|
|
self.init_unified();
|
|
|
|
return str.replace(self.rx_unified, function(m, p1, p2) {
|
|
|
|
var val = self.map.unified[p1];
|
|
|
|
if (!val) { return m; }
|
|
|
|
var idx = null;
|
|
|
|
if (p2 == '\uD83C\uDFFB') { idx = '1f3fb'; }
|
|
|
|
if (p2 == '\uD83C\uDFFC') { idx = '1f3fc'; }
|
|
|
|
if (p2 == '\uD83C\uDFFD') { idx = '1f3fd'; }
|
|
|
|
if (p2 == '\uD83C\uDFFE') { idx = '1f3fe'; }
|
|
|
|
if (p2 == '\uD83C\uDFFF') { idx = '1f3ff'; }
|
|
|
|
if (idx) {
|
|
|
|
return self.replacement(val, null, null, {
|
|
|
|
idx : idx,
|
|
|
|
actual : p2,
|
|
|
|
wrapper : ':'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// wrap names in :'s
|
|
|
|
return self.replacement(val, ':' + self.data[val][3][0] + ':');
|
|
|
|
});
|
2016-09-01 06:32:17 +00:00
|
|
|
};
|
|
|
|
window.emoji = new EmojiConvertor();
|
|
|
|
emoji.init_colons();
|
|
|
|
|
|
|
|
window.emoji_util.parse = function($el) {
|
2016-09-01 21:01:51 +00:00
|
|
|
if (!$el || !$el.length) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-01 20:31:36 +00:00
|
|
|
$el.html(emoji.replace_unified($el.html()));
|
2016-09-01 06:32:17 +00:00
|
|
|
};
|
|
|
|
|
2016-02-15 21:53:37 +00:00
|
|
|
})();
|