The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
4 posters

    Replace text to emoticon using javascript

    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Replace text to emoticon using javascript

    Post by Chavo Thu 20 Mar - 5:26

    There's some code for replace a text to a image (emoticon)?


    Last edited by Chavo on Thu 20 Mar - 7:01; edited 1 time in total
    Pizza Boi
    Pizza Boi
    Hyperactive


    Male Posts : 2016
    Reputation : 160
    Language : French
    Location : Pizza Hut!

    Solved Re: Replace text to emoticon using javascript

    Post by Pizza Boi Thu 20 Mar - 6:58

    Hi Very Happy

    Please clarify which texts.

    If you want it easier, why don't you just use an html tag of an image or bbcode for it?

    Code:
    For HTML
    <img src="IMG Link here" title="Title of image" />

    Code:
    For BBC
    [img]IMG Link[/img]

    Regards,
    Pizza Boi
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Thu 20 Mar - 6:59

    It's for replace a text for a emoticon i've forgote to mention that
    Pizza Boi
    Pizza Boi
    Hyperactive


    Male Posts : 2016
    Reputation : 160
    Language : French
    Location : Pizza Hut!

    Solved Re: Replace text to emoticon using javascript

    Post by Pizza Boi Thu 20 Mar - 7:07

    Hi Very Happy

    If you're using the new editor (Which is pretty obvious) When you click on the "Switch Editor Mode", there's that option when you input a "Very Happy" emoticon for example, it will automatically change into that smiley. The "Switch Editor Mode" is located on the lower part and in the most right side  if it's in the quick reply and for the "Post Reply".

    Regards,
    Pizza Boi
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Thu 20 Mar - 7:24

    I know...

    I wanna imput new emoticons via javascript without add by the commom way.

    I have a javascript but it change by the title of the image (alt) and any image with the same title is changeg into the emoticons. I wanna do it by text.
    Ikerepc
    Ikerepc
    Active Poster


    Male Posts : 1187
    Reputation : 167
    Language : Who cares...
    Location : Where web help & support is needed

    Solved Re: Replace text to emoticon using javascript

    Post by Ikerepc Thu 20 Mar - 8:19

    Hi

    Can you put there that code so we can try to edit it.
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Thu 20 Mar - 8:53

    Code:
    var Smileys;

    Smileys = {
        'Lara com Z' : 'http://i738.photobucket.com/albums/xx29/forummultix/emoticons/Lara7_zps32c7c5d6.gif',
        'Gretchen' : 'http://i738.photobucket.com/albums/xx29/forummultix/emoticons/gretchensaindo_zpsbb7eafc6.gif',
        'Falta de sacanagem' : 'http://i738.photobucket.com/albums/xx29/forummultix/emoticons/putafaltadesacanagem_zps162a2df9.gif',
    };

    $(function() {
        $.each(Smileys, function(key, value) {
            $('img[alt="' + key + '"]').attr('src', value);
        });
    });
    (I've deleted some emoticons to put it here to don't be so many heavy)
    Pizza Boi
    Pizza Boi
    Hyperactive


    Male Posts : 2016
    Reputation : 160
    Language : French
    Location : Pizza Hut!

    Solved Re: Replace text to emoticon using javascript

    Post by Pizza Boi Thu 20 Mar - 9:16

    Hi Very Happy

    I'm not really good at javascript... but wouldn't declaring in the alt an image link or something like \('[img.][/img]'\) do justice?

    Sorry for not being of much help with this one.

    Regards,
    Pizza Boi
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Thu 20 Mar - 11:21

    Didn't work.
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Fri 21 Mar - 13:34

    bump
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Thu 27 Mar - 17:26

    So no one can help me? ....
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Replace text to emoticon using javascript

    Post by Ange Tuteur Fri 28 Mar - 17:16

    Hello Chavo,

    The most I can come up with is this :
    * Placement should be in the topics
    Code:
    $(function() {
     Â   var c = document.getElementsByClassName('entry-content');
     Â   for (i=0; i<c.length; i++) {    
     Â      c[i].innerHTML = c[i].innerHTML.replace(/:cool:/g,'<img src="http://2img.net/i/fa/i/smiles/icon_cool.gif"/>');
     Â      c[i].innerHTML = c[i].innerHTML.replace(/:sad:/g,'<img src="http://2img.net/i/fa/i/smiles/icon_sad.gif"/>');
     Â   }
    });

    We replace the text in a post with an image element.
    avatar
    Chavo
    New Member


    Male Posts : 19
    Reputation : 2
    Language : Engish, Portuguese

    Solved Re: Replace text to emoticon using javascript

    Post by Chavo Fri 28 Mar - 20:18

    Thank you!!! It works!! I've tested many codes i found on web but it won't work, but SO MANY THANKS!!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Replace text to emoticon using javascript

    Post by Ange Tuteur Fri 28 Mar - 20:26

    You're welcome Smile

    Topic solved and archived

      Current date/time is Mon 11 Nov - 20:28