0

I have a somewhat simple JavaScript chat box, and it works great. I would really like to have it work like the Twitch chat box where when a user types a certain string, the text is 'converted' to an emoticon.

Example: I type ":)" and the text turns into a smiley face!

So far I have not found any questions/answers which demonstrate how to do this.

I already know to use a switch statement, so is there a simple way to convert the user input to a picture in JavaScript, or is it much more complicated?

Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
  • I'm just spitballing here, but you could read certain input and when executing whatever mechanism you use to add the text to your chat box, you could do an ajax request for an image and append that instead. Perhaps you could load up all the images with the page and use those. – Antrikshy Apr 04 '15 at 03:22
  • What is this chat box? A ` – tckmn Apr 04 '15 at 03:22
  • look up regular expressions – Rooster Apr 04 '15 at 03:25
  • This chat box is a , sorry for not being specific. And the ajax could possibly work, i'm going to have to try that out myself. – Eoin Fitzpatrick Apr 04 '15 at 03:25
  • i found a duplicate for your question, it just that you have searched a wrong keyword. have a look at this. http://stackoverflow.com/questions/3055515/replace-a-list-of-emoticons-with-their-images – Dyrandz Famador Apr 04 '15 at 03:37
  • haha, it's like my twin asked that question. I'm definitely going to use that! Thanks! – Eoin Fitzpatrick Apr 04 '15 at 03:38

0 Answers0