Permalink
Browse files

New changes passing JSlint as much as possible again

  • Loading branch information...
1 parent 31d1197 commit df876e37dfad8d759cfab73c6f0382d38f146db3 @christiaan christiaan committed Jun 1, 2010
View
@@ -84,7 +84,9 @@ exports.Client = Class({
_onClose: function(){
var self = this;
- if (this._heartbeatInterval) clearInterval(this._heartbeatInterval);
+ if (this._heartbeatInterval) {
+ clearInterval(this._heartbeatInterval);
+ }
this.connected = false;
this._disconnectTimeout = setTimeout(function(){
self._onDisconnect();
@@ -119,11 +121,11 @@ exports.Client = Class({
},
_verifyOrigin: function(origin){
- var parts = urlparse(origin);
- return this.listener.options.origins.indexOf('*:*') !== -1
- || this.listener.options.origins.indexOf(parts.host + ':' + parts.port) !== -1
- || this.listener.options.origins.indexOf(parts.host + ':*') !== -1
- || this.listener.options.origins.indexOf('*:' + parts.port) !== -1;
+ var parts = urlparse(origin), origins = this.listener.options.origins;
+ return origins.indexOf('*:*') !== -1 ||
+ origins.indexOf(parts.host + ':' + parts.port) !== -1 ||
+ origins.indexOf(parts.host + ':*') !== -1 ||
+ origins.indexOf('*:' + parts.port) !== -1;
}
});
@@ -31,14 +31,15 @@ exports.websocket = Client.extend({
if ('sec-websocket-key1' in this.request.headers){
headers.push(
'Sec-WebSocket-Origin: ' + this.request.headers.origin,
- 'Sec-WebSocket-Location: ws://' + this.request.headers.host + this.request.url
- );
+ 'Sec-WebSocket-Location: ws://' + this.request.headers.host + this.request.url);
}
this.connection.write(headers.concat('', '').join('\r\n'));
this.connection.addListener('end', function(){ self._onClose(); });
this.connection.addListener('data', function(data){ self._handle(data); });
- if (this._proveReception()) this._payload();
+ if (this._proveReception()) {
+ this._payload();
+ }
},
_handle: function(data){
@@ -12,11 +12,11 @@ exports['xhr-multipart'] = Client.extend({
_onConnect: function(req, res){
var self = this, body = '', headers = {};
// https://developer.mozilla.org/En/HTTP_Access_Control
- if (req.headers['origin'] && this._verifyOrigin(req.headers['origin'])) {
- headers['Access-Control-Allow-Origin'] = req.headers['origin'];
+ if (req.headers.origin && this._verifyOrigin(req.headers.origin)) {
+ headers['Access-Control-Allow-Origin'] = req.headers.origin;
headers['Access-Control-Allow-Credentials'] = 'true';
}
- if (typeof req.headers['access-control-request-method'] != 'undefined') {
+ if (typeof req.headers['access-control-request-method'] !== 'undefined') {
// CORS preflight message
headers['Access-Control-Allow-Methods'] = req.headers['access-control-request-method'];
res.writeHead(200, headers);
@@ -60,7 +60,7 @@ exports['xhr-multipart'] = Client.extend({
},
_write: function(message){
- this.response.write("Content-Type: text/plain" + (message.length == 1 && message.charCodeAt(0) == 6 ? "; charset=us-ascii" : "") + "\n\n");
+ this.response.write("Content-Type: text/plain" + (message.length === 1 && message.charCodeAt(0) === 6 ? "; charset=us-ascii" : "") + "\n\n");
this.response.write(message + "\n");
this.response.write("--socketio\n");
this.response.flush();
@@ -42,10 +42,11 @@ exports['xhr-polling'] = Client.extend({
}
var headers = {'Content-Type': 'text/plain', 'Content-Length': message.length};
// https://developer.mozilla.org/En/HTTP_Access_Control
- if (this.request.headers['origin'] && this._verifyOrigin(this.request.headers['origin'])) {
- headers['Access-Control-Allow-Origin'] = this.request.headers['origin'];
- if (this.request.headers['cookie'])
+ if (this.request.headers.origin && this._verifyOrigin(this.request.headers.origin)) {
+ headers['Access-Control-Allow-Origin'] = this.request.headersorigin;
+ if (this.request.headers.cookie) {
headers['Access-Control-Allow-Credentials'] = 'true';
+ }
}
this.response.writeHead(200, headers);
this.response.write(message);
View
@@ -58,7 +58,9 @@ io.listen(server, {
onClientMessage: function(message, client){
var msg = { message: [client.sessionId, message] };
buffer.push(msg);
- if (buffer.length > 15) buffer.shift();
+ if (buffer.length > 15) {
+ buffer.shift();
+ }
client.broadcast(json(msg));
}

0 comments on commit df876e3

Please sign in to comment.