Sha256: 69c7d8268bc506cf155d9a1572b4a5feff01fc8a540b9a623e8360330a868f4e
Contents?: true
Size: 749 Bytes
Versions: 28
Compression:
Stored size: 749 Bytes
Contents
var io = new CometIO().connect(); io.on("chat", function(data){ var m = $("<li>").text(data.name + " : " +data.message); $("#chat #timeline").prepend(m); }); io.on("*", function(event, data){ // catch all events console.log(event + " - " + JSON.stringify(data)); }); io.on("connect", function(session){ console.log("connect!! "+session); $("#chat #btn_send").click(post); $("#chat #message").keydown(function(e){ if(e.keyCode == 13) post(); }); }); 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
28 entries across 28 versions & 1 rubygems