mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
handler/PadMessageHandler: use jshint
This commit is contained in:
parent
8e42192f2f
commit
4fe4afe1b3
1 changed files with 113 additions and 113 deletions
|
@ -61,7 +61,7 @@ var socketio;
|
||||||
exports.setSocketIO = function(socket_io)
|
exports.setSocketIO = function(socket_io)
|
||||||
{
|
{
|
||||||
socketio=socket_io;
|
socketio=socket_io;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the connection of a new user
|
* Handles the connection of a new user
|
||||||
|
@ -72,7 +72,7 @@ exports.handleConnect = function(client)
|
||||||
//Initalize session2pad and sessioninfos for this new session
|
//Initalize session2pad and sessioninfos for this new session
|
||||||
session2pad[client.id]=null;
|
session2pad[client.id]=null;
|
||||||
sessioninfos[client.id]={};
|
sessioninfos[client.id]={};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kicks all sessions from a pad
|
* Kicks all sessions from a pad
|
||||||
|
@ -89,7 +89,7 @@ exports.kickSessionsFromPad = function(padID)
|
||||||
{
|
{
|
||||||
socketio.sockets.sockets[pad2sessions[padID][i]].json.send({disconnect:"deleted"});
|
socketio.sockets.sockets[pad2sessions[padID][i]].json.send({disconnect:"deleted"});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the disconnection of a user
|
* 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
|
//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);
|
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
|
//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)
|
if(pad2sessions[sessionPad][i] == client.id)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ exports.handleDisconnect = function(client)
|
||||||
//Delete the session2pad and sessioninfos entrys of this session
|
//Delete the session2pad and sessioninfos entrys of this session
|
||||||
delete session2pad[client.id];
|
delete session2pad[client.id];
|
||||||
delete sessioninfos[client.id];
|
delete sessioninfos[client.id];
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a message from a user
|
* Handles a message from a user
|
||||||
|
@ -154,7 +154,7 @@ exports.handleDisconnect = function(client)
|
||||||
*/
|
*/
|
||||||
exports.handleMessage = function(client, message)
|
exports.handleMessage = function(client, message)
|
||||||
{
|
{
|
||||||
if(message == null)
|
if(!message)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Message is null!");
|
messageLogger.warn("Message is null!");
|
||||||
return;
|
return;
|
||||||
|
@ -196,7 +196,7 @@ exports.handleMessage = function(client, message)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, unknown Message Type " + message.type);
|
messageLogger.warn("Dropped message, unknown Message Type " + message.type);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a Chat Message
|
* Handles a Chat Message
|
||||||
|
@ -273,12 +273,12 @@ function handleChatMessage(client, message)
|
||||||
function handleSuggestUserName(client, message)
|
function handleSuggestUserName(client, message)
|
||||||
{
|
{
|
||||||
//check if all ok
|
//check if all ok
|
||||||
if(message.data.payload.newName == null)
|
if(!message.data.payload.newName)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, suggestUserName Message has no newName!");
|
messageLogger.warn("Dropped message, suggestUserName Message has no newName!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(message.data.payload.unnamedId == null)
|
if(!message.data.payload.unnamedId)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, suggestUserName Message has no unnamedId!");
|
messageLogger.warn("Dropped message, suggestUserName Message has no unnamedId!");
|
||||||
return;
|
return;
|
||||||
|
@ -305,7 +305,7 @@ function handleSuggestUserName(client, message)
|
||||||
function handleUserInfoUpdate(client, message)
|
function handleUserInfoUpdate(client, message)
|
||||||
{
|
{
|
||||||
//check if all ok
|
//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!");
|
messageLogger.warn("Dropped message, USERINFO_UPDATE Message has no colorId!");
|
||||||
return;
|
return;
|
||||||
|
@ -321,7 +321,7 @@ function handleUserInfoUpdate(client, message)
|
||||||
var padId = session2pad[client.id];
|
var padId = session2pad[client.id];
|
||||||
|
|
||||||
//set a null name, when there is no name set. cause the client wants it null
|
//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;
|
message.data.userInfo.name = null;
|
||||||
}
|
}
|
||||||
|
@ -349,17 +349,17 @@ function handleUserInfoUpdate(client, message)
|
||||||
function handleUserChanges(client, message)
|
function handleUserChanges(client, message)
|
||||||
{
|
{
|
||||||
//check if all ok
|
//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!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no baseRev!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(message.data.apool == null)
|
if(!message.data.apool)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(message.data.changeset == null)
|
if(!message.data.changeset)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!");
|
||||||
return;
|
return;
|
||||||
|
@ -488,7 +488,7 @@ exports.updatePadClients = function(pad, callback)
|
||||||
//https://github.com/caolan/async#whilst
|
//https://github.com/caolan/async#whilst
|
||||||
//send them all new changesets
|
//send them all new changesets
|
||||||
async.whilst(
|
async.whilst(
|
||||||
function (){ return lastRev < pad.getHeadRevisionNumber()},
|
function (){ return lastRev < pad.getHeadRevisionNumber(); },
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
var author, revChangeset;
|
var author, revChangeset;
|
||||||
|
@ -541,7 +541,7 @@ exports.updatePadClients = function(pad, callback)
|
||||||
|
|
||||||
sessioninfos[session].rev = pad.getHeadRevisionNumber();
|
sessioninfos[session].rev = pad.getHeadRevisionNumber();
|
||||||
},callback);
|
},callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copied from the Etherpad Source Code. Don't know what this methode does excatly...
|
* 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ function handleClientReady(client, message)
|
||||||
//no access, send the client a message that tell him why
|
//no access, send the client a message that tell him why
|
||||||
else
|
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;
|
atext.attribs = attribsForWire.translated;
|
||||||
|
|
||||||
//check if abiword is avaiable
|
//check if abiword is avaiable
|
||||||
var abiwordAvailable = settings.abiword != null ? "yes" : "no";
|
var abiwordAvailable = settings.abiword = null ? "yes" : "no";
|
||||||
if(settings.abiword != null && os.type().indexOf("Windows") != -1)
|
if(settings.abiword && os.type().indexOf("Windows") != -1)
|
||||||
{
|
{
|
||||||
abiwordAvailable = "withoutPDF";
|
abiwordAvailable = "withoutPDF";
|
||||||
}
|
}
|
||||||
|
@ -800,10 +800,10 @@ function handleClientReady(client, message)
|
||||||
},
|
},
|
||||||
"abiwordAvailable": abiwordAvailable,
|
"abiwordAvailable": abiwordAvailable,
|
||||||
"hooks": {}
|
"hooks": {}
|
||||||
}
|
};
|
||||||
|
|
||||||
//Add a username to the clientVars if one avaiable
|
//Add a username to the clientVars if one avaiable
|
||||||
if(authorName != null)
|
if(authorName)
|
||||||
{
|
{
|
||||||
clientVars.userName = authorName;
|
clientVars.userName = authorName;
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ function handleClientReady(client, message)
|
||||||
if(sessioninfos[client.id] !== undefined)
|
if(sessioninfos[client.id] !== undefined)
|
||||||
{
|
{
|
||||||
//This is a reconnect, so we don't have to send the client the ClientVars again
|
//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
|
//Save the revision in sessioninfos, we take the revision from the info the client send to us
|
||||||
sessioninfos[client.id].rev = message.client_rev;
|
sessioninfos[client.id].rev = message.client_rev;
|
||||||
|
@ -844,7 +844,7 @@ function handleClientReady(client, message)
|
||||||
};
|
};
|
||||||
|
|
||||||
//Add the authorname of this new User, if avaiable
|
//Add the authorname of this new User, if avaiable
|
||||||
if(authorName != null)
|
if(authorName)
|
||||||
{
|
{
|
||||||
messageToTheOtherUsers.data.userInfo.name = authorName;
|
messageToTheOtherUsers.data.userInfo.name = authorName;
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ function handleClientReady(client, message)
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
sessionAuthorColorId = value;
|
sessionAuthorColorId = value;
|
||||||
callback();
|
callback();
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
|
@ -875,7 +875,7 @@ function handleClientReady(client, message)
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
sessionAuthorName = value;
|
sessionAuthorName = value;
|
||||||
callback();
|
callback();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
],callback);
|
],callback);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue