Permalink
Browse files

Fix some indentation

  • Loading branch information...
1 parent 20ecebb commit c93b61895379ca1ac17936249576d194a3ea7f99 @pksunkara committed Sep 18, 2011
Showing with 43 additions and 43 deletions.
  1. +21 −21 app.js
  2. +22 −22 public/javascripts/collab.js
View
42 app.js
@@ -58,28 +58,28 @@ app.get('/code/:id', function(req, res){
var sessions = [];
io.sockets.on('connection', function(socket){
- socket.emit('nickname?', {});
- socket.on('nickname', function(data){
- data = (data===null)? randomString() : data;
- console.log(data, 'joined the session');
+ socket.emit('nickname?', {});
+ socket.on('nickname', function(data){
+ data = (data===null)? randomString() : data;
+ console.log(data, 'joined the session');
socket.emit('members', sessions);
- io.sockets.emit('join', {name: data, msg: data+' has joined the session'});
- socket.set('nickname', data);
- sessions.push(data);
- });
- socket.on('chat', function(data){
- socket.get('nickname', function(err, nickname){
- console.log("msg from", nickname, ":", data);
- io.sockets.emit('chat', nickname+': '+data);
- });
- });
- socket.on('disconnect', function(){
- socket.get('nickname', function(err, nickname){
- console.log(nickname, 'quit the session');
- io.sockets.emit('quit', {name: nickname, msg: nickname+' has quit the session'});
- sessions.splice(sessions.indexOf(nickname), 1);
- });
- });
+ io.sockets.emit('join', {name: data, msg: data+' has joined the session'});
+ socket.set('nickname', data);
+ sessions.push(data);
+ });
+ socket.on('chat', function(data){
+ socket.get('nickname', function(err, nickname){
+ console.log("msg from", nickname, ":", data);
+ io.sockets.emit('chat', nickname+': '+data);
+ });
+ });
+ socket.on('disconnect', function(){
+ socket.get('nickname', function(err, nickname){
+ console.log(nickname, 'quit the session');
+ io.sockets.emit('quit', {name: nickname, msg: nickname+' has quit the session'});
+ sessions.splice(sessions.indexOf(nickname), 1);
+ });
+ });
})
// Start listening to server
@@ -33,36 +33,36 @@ getCursor = function() {
}
key_handler = function (key) {
- console.log('{'+cpos+','+ver+','+substr+','+e+'}');
- socket.emit('text edit', {cursor:cpos, version:ver, substring:substr, edit:e});
+ console.log('{'+cpos+','+ver+','+substr+','+e+'}');
+ socket.emit('text edit', {cursor:cpos, version:ver, substring:substr, edit:e});
}
socket.on('text edit', function (data){
- console.log('text-edit: '+data);
- var text = acee.getValue();
- text = text.substr(0,data.cpos-1) + data.edit + text.substr(data.cpos -1 + data.edit.length);
- ver += 1;
- acee.setValue(text);
+ console.log('text-edit: '+data);
+ var text = acee.getValue();
+ text = text.substr(0,data.cpos-1) + data.edit + text.substr(data.cpos -1 + data.edit.length);
+ ver += 1;
+ acee.setValue(text);
});
socket.on('nickname?', function(data){
- var nickname = prompt('Your nickname?');
- socket.emit('nickname', nickname);
- socket.on('members', function(data){
- members = data;
- updateMembers();
- });
- socket.on('join', function(data){
- members.push(data.name);
+ var nickname = prompt('Your nickname?');
+ socket.emit('nickname', nickname);
+ socket.on('members', function(data){
+ members = data;
+ updateMembers();
+ });
+ socket.on('join', function(data){
+ members.push(data.name);
+ updateMembers();
+ putChat(data.msg);
+ });
+ socket.on('quit', function(data){
+ members.splice(members.indexOf(data.name), 1);
updateMembers();
putChat(data.msg);
- });
- socket.on('quit', function(data){
- members.splice(members.indexOf(data.name), 1);
- updateMembers();
- putChat(data.msg);
- });
+ });
socket.on('chat', function(data){
- putChat(data);
+ putChat(data);
});
});

0 comments on commit c93b618

Please sign in to comment.