Created
May 2, 2014 04:12
-
-
Save rderoldan1/09f28f576e1707122ca2 to your computer and use it in GitHub Desktop.
Revisions
-
rderoldan1 created this gist
May 2, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ $(document).on "page:change", -> chat = new Chat() socket = chat.socket socket.onopen = -> chat.send('user_new', 'Se ha conectado') chat.send('list', '') #socket.send('{"event":"user_message", "data": {"username": "'+username+'", "message": "oeoeo"}}') socket.onmessage = (evt) -> chat.parse_response(evt) $('<li>').text(evt.data).appendTo('.chat-history') #$('<li class="list-group-item">').text(evt.data).appendTo('.chat-users') send_message = -> if $('.chat-message').val() != "" chat.send("user_message", $(".chat-message").val()) $('.chat-message').val('') $('.btn-chat').click -> send_message() $('.chat-message').keyup (e)-> if e.keyCode == 13 send_message()