mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
yet more JShint cleaning.
This commit is contained in:
parent
252135532d
commit
4770a06679
@ -30,7 +30,7 @@ module.exports = function(RED) {
|
||||
var urlencParser = express.urlencoded();
|
||||
|
||||
function rawBodyParser(req, res, next) {
|
||||
if (req._body) return next();
|
||||
if (req._body) { return next(); }
|
||||
req.body = "";
|
||||
req._body = true;
|
||||
getBody(req, {
|
||||
@ -38,7 +38,7 @@ module.exports = function(RED) {
|
||||
length: req.headers['content-length'],
|
||||
encoding: 'utf8'
|
||||
}, function (err, buf) {
|
||||
if (err) return next(err);
|
||||
if (err) { return next(err); }
|
||||
req.body = buf;
|
||||
next();
|
||||
});
|
||||
@ -95,10 +95,10 @@ module.exports = function(RED) {
|
||||
}
|
||||
}
|
||||
if (RED.settings.httpNodeCors) {
|
||||
var routes = RED.httpNode.routes['options'];
|
||||
for (var i = 0; i<routes.length; i++) {
|
||||
if (routes[i].path == this.url) {
|
||||
routes.splice(i,1);
|
||||
var route = RED.httpNode.route['options'];
|
||||
for (var j = 0; j<route.length; j++) {
|
||||
if (route[j].path == this.url) {
|
||||
route.splice(j,1);
|
||||
//break;
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ module.exports = function(RED) {
|
||||
opts.method = method;
|
||||
opts.headers = {};
|
||||
if (msg.headers) {
|
||||
for (var v in msg.headers) {
|
||||
for (var v = 0; v < msg.headers.length; v++) {
|
||||
opts.headers[v.toLowerCase()] = msg.headers[v];
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ module.exports = function(RED) {
|
||||
RED.httpAdmin.get('/http-request/:id',function(req,res) {
|
||||
var credentials = RED.nodes.getCredentials(req.params.id);
|
||||
if (credentials) {
|
||||
res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")}));
|
||||
res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")}));
|
||||
} else {
|
||||
res.send(JSON.stringify({}));
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ module.exports = function(RED) {
|
||||
// Workaround https://github.com/einaros/ws/pull/253
|
||||
// Remove listeners from RED.server
|
||||
var listener = null;
|
||||
for(var event in node._serverListeners){
|
||||
for (var event = 0; event < node._serverListeners.length; event++) {
|
||||
listener = node._serverListeners[event];
|
||||
if(typeof listener === "function"){
|
||||
RED.server.removeListener(event,listener);
|
||||
@ -115,16 +115,20 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
WebSocketListenerNode.prototype.broadcast = function(data){
|
||||
for(var i in this.server.clients){
|
||||
for (var i = 0; i < this.server.clients.length; i++) {
|
||||
this.server.clients[i].send(data);
|
||||
}
|
||||
}
|
||||
|
||||
WebSocketListenerNode.prototype.send = function(id,data){
|
||||
WebSocketListenerNode.prototype.send = function(id,data) {
|
||||
var session = this._clients[id];
|
||||
if (session) {
|
||||
try {
|
||||
session.send(data);
|
||||
}
|
||||
catch(e) { // swallow any errors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function WebSocketInNode(n) {
|
||||
@ -167,7 +171,7 @@ module.exports = function(RED) {
|
||||
node.serverConfig.send(msg._session.id,payload);
|
||||
} else {
|
||||
node.serverConfig.broadcast(payload,function(error){
|
||||
if(!!error){
|
||||
if (!!error) {
|
||||
node.warn("An error occurred while sending:" + inspect(error));
|
||||
}
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ module.exports = function(RED) {
|
||||
RED.nodes.createNode(this,n);
|
||||
|
||||
this.files = n.files.split(",");
|
||||
for (var f in this.files) {
|
||||
for (var f =0; f < this.files.length; f++) {
|
||||
this.files[f] = this.files[f].trim();
|
||||
}
|
||||
this.p = (this.files.length == 1) ? this.files[0] : JSON.stringify(this.files);
|
||||
|
@ -61,7 +61,7 @@ module.exports = function(RED) {
|
||||
if (typeof payload === "object") {
|
||||
payload = JSON.stringify(payload);
|
||||
} else {
|
||||
payload = new String(payload);
|
||||
payload = payload.toString();
|
||||
}
|
||||
payload += node.addCh;
|
||||
} else if (node.addCh !== "") {
|
||||
@ -115,15 +115,16 @@ module.exports = function(RED) {
|
||||
this.serialConfig.newline
|
||||
);
|
||||
|
||||
var splitc;
|
||||
if (node.serialConfig.newline.substr(0,2) == "0x") {
|
||||
var splitc = new Buffer([parseInt(node.serialConfig.newline)]);
|
||||
splitc = new Buffer([parseInt(node.serialConfig.newline)]);
|
||||
} else {
|
||||
var splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"));
|
||||
splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"));
|
||||
}
|
||||
|
||||
this.port.on('data', function(msg) {
|
||||
// single char buffer
|
||||
if ((node.serialConfig.newline == 0)||(node.serialConfig.newline == "")) {
|
||||
if ((node.serialConfig.newline === 0)||(node.serialConfig.newline === "")) {
|
||||
if (node.serialConfig.bin !== "bin") { node.send({"payload": String.fromCharCode(msg)}); }
|
||||
else { node.send({"payload": new Buffer([msg])}); }
|
||||
}
|
||||
@ -222,7 +223,7 @@ module.exports = function(RED) {
|
||||
parity: parity,
|
||||
stopbits: stopbits,
|
||||
parser: serialp.parsers.raw
|
||||
},true, function(err, results) { if (err) obj.serial.emit('error',err); });
|
||||
},true, function(err, results) { if (err) { obj.serial.emit('error',err); } });
|
||||
//}
|
||||
//else {
|
||||
// obj.serial = new serialp.SerialPort(port,{
|
||||
@ -267,6 +268,9 @@ module.exports = function(RED) {
|
||||
// obj._emitter.emit('data',d);
|
||||
//}
|
||||
});
|
||||
obj.serial.on("disconnect",function() {
|
||||
node.warn("Serial Port gone away.");
|
||||
});
|
||||
}
|
||||
setupSerial();
|
||||
return obj;
|
||||
@ -285,7 +289,8 @@ module.exports = function(RED) {
|
||||
util.log("[serial] serial port closed");
|
||||
done();
|
||||
});
|
||||
} catch(err) { };
|
||||
}
|
||||
catch(err) { }
|
||||
delete connections[port];
|
||||
} else {
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user