// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. const emoticonPatterns = { smile: /:-?\)/g, // :) open_mouth: /:o/gi, // :o scream: /:-o/gi, // :-o smirk: /[:;]-?]/g, // :] grinning: /[:;]-?d/gi, // :D stuck_out_tongue_closed_eyes: /x-d/gi, // x-d stuck_out_tongue_winking_eye: /[:;]-?p/gi, // ;p rage: /:-?[\[@]/g, // :@ frowning: /:-?\(/g, // :( sob: /:['’]-?\(|:'\(/g, // :`( kissing_heart: /:-?\*/g, // :* wink: /;-?\)/g, // ;) pensive: /:-?\//g, // :/ confounded: /:-?s/gi, // :s flushed: /:-?\|/g, // :| relaxed: /:-?\$/g, // :$ mask: /:-x/gi, // :-x heart: /<3|<3/g, // <3 broken_heart: /<\/3|</3/g, // `, originalText: match }); return alias; } return match; } output = output.replace(/:([a-zA-Z0-9_-]+):/g, replaceEmoticonWithToken); $.each(emoticonPatterns, (name, pattern) => { // this might look a bit funny, but since the name isn't contained in the actual match // like with the named emoticons, we need to add it in manually output = output.replace(pattern, (match) => replaceEmoticonWithToken(match, name)); }); return output; } function getImagePathForEmoticon(name) { return `/static/images/emoji/${name}.png`; }