Replace text to emoticon using javascript

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
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 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
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 on 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 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
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 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.
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 on 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 : PHP, jQuery, SQL, JavaScript, HTML5, CSS3, Basic, C, C++ <?php echo 'English and Croatian'; ?>
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 on March 20th 2014, 7:53 am

Code:
var Smileys;

Smileys = {
    'Lara com Z' : 'http://illiweb.com/fa/pbucket.gif',
    'Gretchen' : 'http://illiweb.com/fa/pbucket.gif',
    'Falta de sacanagem' : 'http://illiweb.com/fa/pbucket.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 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
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 on 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 on 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 on 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 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
Ange Tuteur
Forumaster

Male Posts : 13222
Reputation : 2959
Language : EN, JA, FR
Location : Macungie, PA

https://github.com/SethClydesdale

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!!
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 on March 28th 2014, 7:26 pm

You're welcome Smile

Topic solved and archived
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13222
Reputation : 2959
Language : EN, JA, FR
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Back to top


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