mirror of
https://github.com/wahyd4/ocelots.git
synced 2026-08-13 15:06:12 +10:00
33 lines
825 B
JavaScript
33 lines
825 B
JavaScript
/**
|
|
* Created with JetBrains RubyMine.
|
|
* User: junv
|
|
* Date: 12/5/12
|
|
* Time: 12:59 PM
|
|
* To change this template use File | Settings | File Templates.
|
|
*/
|
|
$(document).ready(function(){
|
|
var dispatcher = new WebSocketRails('localhost:3000/websocket');
|
|
|
|
dispatcher.on_open = function(data) {
|
|
console.log('Connection has been established: ' + data);
|
|
}
|
|
$('.submit-mess').click(function(){
|
|
if ($('#content').val().replace(/\s+/, "") == ""){
|
|
return ;
|
|
}
|
|
params= {};
|
|
params.content = $('#content').val();
|
|
params.slug = $('#slug').val()
|
|
dispatcher.trigger('new_message',params);
|
|
|
|
|
|
});
|
|
|
|
dispatcher.bind('new_message', function(content) {
|
|
$('#content').val("");
|
|
$('.message-list').prepend(content).show('slow');
|
|
});
|
|
|
|
});
|
|
|