UNPKG

1.18 kBJavaScriptView Raw
1// universal module definition: https://github.com/umdjs/umd/blob/master/returnExports.js#L41
2(function (root, factory) {
3 if (typeof exports === 'object') {
4 // Node. Does not work with strict CommonJS, but
5 // only CommonJS-like enviroments that support module.exports,
6 // like Node.
7 module.exports = factory();
8 } else if (typeof define === 'function' && define.amd) {
9 // AMD. Register as an anonymous module.
10 define(factory);
11 } else {
12 // Browser globals (root is window)
13 root.returnExports = factory();
14 }
15}(this, function () {
16 var emojis = {{data}},
17 test = /\:[a-z0-9_\-\+]+\:/g;
18
19 function emoji(someString, url, size) {
20 return someString.replace(test, function (match) {
21 if (emojis.indexOf(match) !== -1) {
22 var name = String(match).slice(1, -1);
23 return '<img class="emoji" title=":' + name + ':" alt="' + name + '" src="' + url + '/' + encodeURIComponent(name) + '.png"' + (size ? (' height="' + size + '"') : '') + ' />';
24 } else {
25 return match;
26 }
27 });
28 };
29
30 return emoji;
31}));