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.

Replace text to emoticon using javascript

4 posters

Go down

Solved Replace text to emoticon using javascript

Post by Chavo March 20th 2014, 4:26 am

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


Last edited by Chavo on March 20th 2014, 6:01 am; edited 1 time in total
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi March 20th 2014, 5:58 am

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
Pizza Boi
Pizza Boi
Hyperactive

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

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 20th 2014, 5:59 am

It's for replace a text for a emoticon i've forgote to mention that
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi March 20th 2014, 6:07 am

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
Pizza Boi
Pizza Boi
Hyperactive

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

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 20th 2014, 6:24 am

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.
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Ikerepc March 20th 2014, 7:19 am

Hi

Can you put there that code so we can try to edit it.
Ikerepc
Ikerepc
Active Poster

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

http://admins.forumotion.com

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 20th 2014, 7:53 am

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)
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi March 20th 2014, 8:16 am

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
Pizza Boi
Pizza Boi
Hyperactive

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

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 20th 2014, 10:21 am

Didn't work.
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 21st 2014, 12:34 pm

bump
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 27th 2014, 4:26 pm

So no one can help me? ....
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Ange Tuteur March 28th 2014, 4:16 pm

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.
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo March 28th 2014, 7:18 pm

Thank you!!! It works!! I've tested many codes i found on web but it won't work, but SO MANY THANKS!!
avatar
Chavo
New Member

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

https://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Ange Tuteur March 28th 2014, 7:26 pm

You're welcome Smile

Topic solved and archived
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum