Twemoji parsing

This commit is contained in:
Jeremy Zhang 2017-09-06 07:11:32 +00:00
parent 315173924c
commit 7badfea64f
2 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,7 @@
/* global cheet */
/* global location */
/* global io */
/* global twemoji */
(function () {
const theme_options = ["DiscordDark", "BetterTitan"]; // All the avaliable theming names
@ -672,6 +673,18 @@
}
var rendered = Mustache.render(template, {"id": "$2", "name": "$1"}).trim();
message.content = message.content.replace(/<:(.*?):(.*?)>/g, rendered);
message.content = twemoji.parse(message.content, {
className: "message_emoji",
callback: function(icon, options, variant) { // exclude special characters
switch (icon) {
case 'a9': // © copyright
case 'ae': // ® registered trademark
case '2122': // ™ trademark
return false;
}
return ''.concat(options.base, options.size, '/', icon, options.ext);
}
});
return message;
}

View File

@ -189,6 +189,7 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/jQuery-linkify/2.1.4/linkify-jquery.min.js" integrity="sha256-BlSfVPlZijMLojgte2AtSget879chk1+8Z8bEH/L4Cs=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cheet.js/0.3.3/cheet.min.js" integrity="sha256-FxQrnIC3BX45JRzOyFUlKiM6dY3A/ZakV6w4WpYyfyA=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js" integrity="sha256-sdmLD9jD1PIzq3KOQPNSGZYxjv76rds79Mnyk5JNp1M=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twemoji/2.5.0/2/twemoji.min.js" integrity="sha256-t5bxASdQ5tDbKQZy330h/YufCiZg82xG8PqIYzFpwhU=" crossorigin="anonymous"></script>
{% raw %}
<script id="mustache_channellistings" type="text/template">