diy / jquery-emojiarea

A rich textarea control that supports emojis, WYSIWYG-style.
298 stars 87 forks source link

Avoid duplicate entries in menu #7

Open marcocarnazzo opened 10 years ago

marcocarnazzo commented 10 years ago

If you have the same image for many smiley (i. e. ':)' and ':-)'), emoji-menu has duplicate entries.

To avoid this, I changed your code. Here if you want to integrate this feature:

        var filenames = [];
        for (var key in options) {
            if (options.hasOwnProperty(key)) {
                var filename = options[key];
                var alreadyExists = ($.inArray(filename, filenames) > -1);
                if (!alreadyExists) {
                    filenames.push(filename);
                    html.push('<a href="javascript:void(0)" title="' + util.htmlEntities(key) + '">' + EmojiArea.createIcon(key) + '<span class="label">' + util.htmlEntities(key) + '</span></a>');
                }
            }
        }
marcocarnazzo commented 10 years ago

Uh, just a note. This makes sense only with another piece: I'm trying to implement also live rendering (issue #3 )