handler/PadMessageHandler: use jshint

This commit is contained in:
booo 2011-12-22 13:02:27 +01:00
parent 8e42192f2f
commit 4fe4afe1b3

View file

@ -61,7 +61,7 @@ var socketio;
exports.setSocketIO = function(socket_io)
{
socketio=socket_io;
}
};
/**
* Handles the connection of a new user
@ -72,7 +72,7 @@ exports.handleConnect = function(client)
//Initalize session2pad and sessioninfos for this new session
session2pad[client.id]=null;
sessioninfos[client.id]={};
}
};
/**
* Kicks all sessions from a pad
@ -89,7 +89,7 @@ exports.kickSessionsFromPad = function(padID)
{
socketio.sockets.sockets[pad2sessions[padID][i]].json.send({disconnect:"deleted"});
}
}
};
/**
* Handles the disconnection of a user
@ -125,7 +125,7 @@ exports.handleDisconnect = function(client)
};
//Go trough all user that are still on the pad, and send them the USER_LEAVE message
for(i in pad2sessions[sessionPad])
for(var i in pad2sessions[sessionPad])
{
socketio.sockets.sockets[pad2sessions[sessionPad][i]].json.send(messageToTheOtherUsers);
}
@ -133,7 +133,7 @@ exports.handleDisconnect = function(client)
}
//Go trough all sessions of this pad, search and destroy the entry of this client
for(i in pad2sessions[sessionPad])
for(var i in pad2sessions[sessionPad])
{
if(pad2sessions[sessionPad][i] == client.id)
{
@ -145,7 +145,7 @@ exports.handleDisconnect = function(client)
//Delete the session2pad and sessioninfos entrys of this session
delete session2pad[client.id];
delete sessioninfos[client.id];
}
};
/**
* Handles a message from a user
@ -154,7 +154,7 @@ exports.handleDisconnect = function(client)
*/
exports.handleMessage = function(client, message)
{
if(message == null)
if(!message)
{
messageLogger.warn("Message is null!");
return;
@ -196,7 +196,7 @@ exports.handleMessage = function(client, message)
{
messageLogger.warn("Dropped message, unknown Message Type " + message.type);
}
}
};
/**
* Handles a Chat Message
@ -273,12 +273,12 @@ function handleChatMessage(client, message)
function handleSuggestUserName(client, message)
{
//check if all ok
if(message.data.payload.newName == null)
if(!message.data.payload.newName)
{
messageLogger.warn("Dropped message, suggestUserName Message has no newName!");
return;
}
if(message.data.payload.unnamedId == null)
if(!message.data.payload.unnamedId)
{
messageLogger.warn("Dropped message, suggestUserName Message has no unnamedId!");
return;
@ -305,7 +305,7 @@ function handleSuggestUserName(client, message)
function handleUserInfoUpdate(client, message)
{
//check if all ok
if(message.data.userInfo.colorId == null)
if(!message.data.userInfo.colorId)
{
messageLogger.warn("Dropped message, USERINFO_UPDATE Message has no colorId!");
return;
@ -321,7 +321,7 @@ function handleUserInfoUpdate(client, message)
var padId = session2pad[client.id];
//set a null name, when there is no name set. cause the client wants it null
if(message.data.userInfo.name == null)
if(!message.data.userInfo.name)
{
message.data.userInfo.name = null;
}
@ -349,17 +349,17 @@ function handleUserInfoUpdate(client, message)
function handleUserChanges(client, message)
{
//check if all ok
if(message.data.baseRev == null)
if(message.data.baseRev === null || message.data.baseRev === undefined)
{
messageLogger.warn("Dropped message, USER_CHANGES Message has no baseRev!");
return;
}
if(message.data.apool == null)
if(!message.data.apool)
{
messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!");
return;
}
if(message.data.changeset == null)
if(!message.data.changeset)
{
messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!");
return;
@ -488,7 +488,7 @@ exports.updatePadClients = function(pad, callback)
//https://github.com/caolan/async#whilst
//send them all new changesets
async.whilst(
function (){ return lastRev < pad.getHeadRevisionNumber()},
function (){ return lastRev < pad.getHeadRevisionNumber(); },
function(callback)
{
var author, revChangeset;
@ -541,7 +541,7 @@ exports.updatePadClients = function(pad, callback)
sessioninfos[session].rev = pad.getHeadRevisionNumber();
},callback);
}
};
/**
* Copied from the Etherpad Source Code. Don't know what this methode does excatly...
@ -570,7 +570,7 @@ function _correctMarkersInPad(atext, apool) {
}
}
if (badMarkers.length == 0) {
if (badMarkers.length === 0) {
return null;
}
@ -640,7 +640,7 @@ function handleClientReady(client, message)
//no access, send the client a message that tell him why
else
{
client.json.send({accessStatus: statusObject.accessStatus})
client.json.send({accessStatus: statusObject.accessStatus});
}
});
},
@ -756,8 +756,8 @@ function handleClientReady(client, message)
atext.attribs = attribsForWire.translated;
//check if abiword is avaiable
var abiwordAvailable = settings.abiword != null ? "yes" : "no";
if(settings.abiword != null && os.type().indexOf("Windows") != -1)
var abiwordAvailable = settings.abiword = null ? "yes" : "no";
if(settings.abiword && os.type().indexOf("Windows") != -1)
{
abiwordAvailable = "withoutPDF";
}
@ -800,10 +800,10 @@ function handleClientReady(client, message)
},
"abiwordAvailable": abiwordAvailable,
"hooks": {}
}
};
//Add a username to the clientVars if one avaiable
if(authorName != null)
if(authorName)
{
clientVars.userName = authorName;
}
@ -811,7 +811,7 @@ function handleClientReady(client, message)
if(sessioninfos[client.id] !== undefined)
{
//This is a reconnect, so we don't have to send the client the ClientVars again
if(message.reconnect == true)
if(message.reconnect)
{
//Save the revision in sessioninfos, we take the revision from the info the client send to us
sessioninfos[client.id].rev = message.client_rev;
@ -844,7 +844,7 @@ function handleClientReady(client, message)
};
//Add the authorname of this new User, if avaiable
if(authorName != null)
if(authorName)
{
messageToTheOtherUsers.data.userInfo.name = authorName;
}
@ -866,7 +866,7 @@ function handleClientReady(client, message)
if(ERR(err, callback)) return;
sessionAuthorColorId = value;
callback();
})
});
},
function(callback)
{
@ -875,7 +875,7 @@ function handleClientReady(client, message)
if(ERR(err, callback)) return;
sessionAuthorName = value;
callback();
})
});
}
],callback);
},