Skip to content

Commit

Permalink
updated messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerson Vinicius committed Feb 23, 2011
1 parent a3f9e37 commit d3c71e9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/views/chat.erb
Expand Up @@ -53,18 +53,19 @@

// Set event handlers.
ws.onopen = function() {
output([{message: "Connection opened"}]);
output([{from: 'Host', msg: ' Welcome to chat. Please don\'t hurt each other.'}]);
};

ws.onmessage = function(e) {
// e.data contains received string.
output(eval(e.data));
};
ws.onclose = function() {
output([{message: "Connection closed"}]);
initConnection(); // reconnect
};
};
}

$(document).ready(function() {
initConnection();
$("#msg").focus();
Expand All @@ -82,7 +83,7 @@
$("#messages").append( '<li class="message"> <p><span class="from">' + item.from + ':</span> ' + item.msg + '</p> </li>');
}
if (item.message != null) {
$("#messages").append( "<p>" + item.message + "</p>");
$("#status").html( item.message);
}
})
var messages = document.getElementById("messages");
Expand Down

0 comments on commit d3c71e9

Please sign in to comment.