Sha256: cdd4273b1b63595f8734cf23a46077b8a8bc4d1d798e246aafd10108a912d1b7

Contents?: true

Size: 889 Bytes

Versions: 18

Compression:

Stored size: 889 Bytes

Contents

var io = new RocketIO({channel: channel}).connect();

$(function(){
  $("#chat #btn_send").click(post);
  $("#chat #message").keydown(function(e){
    if(e.keyCode == 13) post();
  });
});

io.on("chat", function(data){
  var m = $("<li>").text(data.name + " : " +data.message);
  $("#chat #timeline").prepend(m);
});

io.on("connect", function(){
  console.log("connect!! "+io.session);
  $("#type").text("type : "+io.type);
});

io.on("disconnect", function(){
  console.log("disconnect!!");
});

io.on("*", function(event, data){ // catch all events
  console.log(event + " - " + JSON.stringify(data));
});

io.on("error", function(err){
  console.error(err);
});

var post = function(){
  var name = $("#chat #name").val();
  var message = $("#chat #message").val();
  if(message.length < 1) return;
  io.push("chat", {name: name, message: message});
  $("#chat #message").val("");
};

Version data entries

18 entries across 11 versions & 1 rubygems

Version Path
sinatra-rocketio-0.3.3 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.3.3 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.3.2 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.3.2 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.3.1 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.3.1 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.3.0 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.3.0 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.2.6 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.2.6 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.2.5 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.2.5 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.2.4 sample/modular_style/public/js/chat.js
sinatra-rocketio-0.2.4 sample/classic_style/public/js/chat.js
sinatra-rocketio-0.2.3 sample/public/js/chat.js
sinatra-rocketio-0.2.2 sample/public/js/chat.js
sinatra-rocketio-0.2.1 sample/public/js/chat.js
sinatra-rocketio-0.2.0 sample/public/js/chat.js