Sha256: 95b2fd4e5d37defd4d9a241bb8ba28c1b52adb85eff7ba5cf383d509bc1c0b79

Contents?: true

Size: 882 Bytes

Versions: 12

Compression:

Stored size: 882 Bytes

Contents

var io = new RocketIO().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(session){
  console.log("connect!! "+session);
  $("#type").text("type : "+io.type);
});

io.on("disconnect", function(session){
  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

12 entries across 12 versions & 1 rubygems

Version Path
sinatra-rocketio-0.1.2 sample/public/js/index.js
sinatra-rocketio-0.1.1 sample/public/js/index.js
sinatra-rocketio-0.1.0 sample/public/js/index.js
sinatra-rocketio-0.0.9 sample/public/js/index.js
sinatra-rocketio-0.0.8 sample/public/js/index.js
sinatra-rocketio-0.0.7 sample/public/js/index.js
sinatra-rocketio-0.0.6 sample/public/js/index.js
sinatra-rocketio-0.0.5 sample/public/js/index.js
sinatra-rocketio-0.0.4 sample/public/js/index.js
sinatra-rocketio-0.0.3 sample/public/js/index.js
sinatra-rocketio-0.0.2 sample/public/js/index.js
sinatra-rocketio-0.0.1 sample/public/js/index.js