The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Replace text to emoticon using javascript

View previous topic View next topic Go down

Solved Replace text to emoticon using javascript

Post by Chavo on 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

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi on 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
Hyperactive

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

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

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

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi on 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
Hyperactive

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

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo on 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.

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

Hi

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

Ikerepc
Active Poster

Male Posts : 1114
Reputation : 152
Language : Croatian, HTML, CSS, jQuery, JavaScript, PHP, SQL, Bascom, Python, C, FBD & LAD for PLC and more... Little English :D
Location : Around electronics and progmamming ;)

http://help.forumotion.com

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo on 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)

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Pizza Boi on 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
Hyperactive

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

http://redlustempire.forumtl.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

Didn't work.

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

bump

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

So no one can help me? ....

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Ange Tuteur on 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://illiweb.com/fa/i/smiles/icon_cool.gif"/>');
  c[i].innerHTML = c[i].innerHTML.replace(/:sad:/g,'<img src="http://illiweb.com/fa/i/smiles/icon_sad.gif"/>');
  }
});

We replace the text in a post with an image element.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Replace text to emoticon using javascript

Post by Chavo on 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!!

Chavo
New Member

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

http://help.forumotion.com/

Back to top Go down

Solved Re: Replace text to emoticon using javascript

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

You're welcome Smile

Topic solved and archived

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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