Hi again,

The console error is because there's a problem with single quotes encoding. You 
should put encodeURIComponent when you actually sent the string to the server 
and not when you are reading the input box since the part where you add the 
color and stagename also need to be encoded (single quote in the HTML code). 

I had to do this also at one point for some API I create. It encode the single 
quotes __'___ into it's Hex value. Maybe it could help you if the previous 
doesn't work: encodeURIComponent(msg).replace(/'/g, "%27")


  - Louis

P.S.: My chat users are mostly french, so I had a bit of trouble with encoding 
myself with all those éàèçù lol.

Le 2014-05-24 à 19:14, michael <[email protected]> a écrit :

> requestMsg: function (pipe, options) {
>             var message = encodeURIComponent(chatBox.val()); // message 
> submitted by user / input value
>             // message depends on whether author is same or not
>             var userAvatar = $('.onAvatar').attr('src');
>             var messageError = $('.messageError'); // message error if less 
> than 3 characters or empty
>             var curTime = new Date().getTime();
>             var msg = '<span style="color:#' + SNColorCur + '">' + stagename 
> + ': </span>' + ' ' + message;
>             if ((curTime < lastMsg + sendLimit) && 
> (jQuery.trim(message)).length > 0){    // if the message is not 3 characters 
> or is a space don't post
>                 messageError.remove();
>                 $('.chatBoxmsginCon').append("<p class='newMessage' 
> id=newMessageW> You are sending messages too fast. </p>");
>                 $('.messageError').fadeOut(6000);
>                 return false;
>             }else {//send the message to everyone on channel
>                 if ((jQuery.trim(message)).length > 0) { 
>                     lastMsg = curTime;
>                         myPipe.request.send('objectPush', {
>                         'raw': 'newMessage',
>                         'channel': 'lobby',
>                         'data': {
>                             'author': stagename,
>                             'msg': msg
>                         }    
>                     });
>                     $('.chatBoxmsginCon').append("<p author='" + name + "'" + 
> "class='newMessage'>" + decodeURIComponent(msg) + "</p>");
>                     $('.newMessage:last-of-type').hide().fadeIn(300);
>                     chatBox.val("");// empty message box every message sent
>                     this.scrollBot;// chat box scroll to bottom
>                 }
>             }
>                 return false;
>     },
>     
>     createUser: function(user, pipe) {
>         
>     },
>     rawSendMsg: function (raw, pipe) {// this function handles actually 
> relaying the message to all users
>         this.sendMsg(pipe, raw.data.author, 
> decodeURIComponent(raw.data.msg));// used to send message to all users in 
> same channel
>     },
>     setAuthor: function () {
> 
>     },
>     parseMessage: function(message) {
>         return decodeURIComponent(message);// escape and return raw data for 
> use in sendMsg
>     },
>     sendMsg: function (pipe, from, message) { // function used to send 
> decoded message through rawDataEscape
>         $('.chatBoxmsginCon').append( // once rawDataEscape receives it, the 
> message will be sent to chat
>                     new Element('p', {'author':this.parseMessage(from), 
> 'class':'newMessage', html:this.parseMessage(message)}));
>                     $('.newMessage:last-of-type').hide().fadeIn(300);
>                         $(chatBox).val("");
>     }
> 
> 
> 
> 
> Also when i send a message like "  hello'  " i get a message in the console 
> of the browser receiving the message saying unexpected token ' 
> 
> 
> Thank you
> 
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "APE Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

--- 
You received this message because you are subscribed to the Google Groups "APE 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to