1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

slightly nicer jscs style updates to several nodes

again not pushed to npm - still just whitespace.
This commit is contained in:
dceejay 2015-05-11 20:04:51 +01:00
parent f497b57b7d
commit 64d3b11fd9
6 changed files with 28 additions and 27 deletions

View File

@ -5,6 +5,7 @@
"requireCurlyBraces": true, "requireCurlyBraces": true,
"disallowMixedSpacesAndTabs": true, "disallowMixedSpacesAndTabs": true,
"disallowMultipleSpaces": {"allowEOLComments": true}, "disallowMultipleSpaces": {"allowEOLComments": true},
"requireSpaceBeforeBlockStatements": 1,
//"requireSemicolons": true, //"requireSemicolons": true,
//"validateParameterSeparator": ", ", //"validateParameterSeparator": ", ",
"requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"] "requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"]

View File

@ -37,7 +37,7 @@ function BleScan(n) {
this.ble_name = n.ble_name; this.ble_name = n.ble_name;
this.ble_uuid = n.ble_uuid; this.ble_uuid = n.ble_uuid;
this.on("input", function(msg){ this.on("input", function(msg) {
noble.startScanning(); noble.startScanning();
}); });

View File

@ -41,27 +41,27 @@ function sensorTagNode(n) {
if ( typeof node.stag == "undefined") { if ( typeof node.stag == "undefined") {
//console.log("starting"); //console.log("starting");
SensorTag.discover(function(sensorTag){ SensorTag.discover(function(sensorTag) {
node.stag = sensorTag; node.stag = sensorTag;
sensorTag.connect(function(){ sensorTag.connect(function() {
//console.log("connected"); //console.log("connected");
sensorTag.discoverServicesAndCharacteristics(function(){ sensorTag.discoverServicesAndCharacteristics(function() {
sensorTag.enableIrTemperature(function(){}); sensorTag.enableIrTemperature(function() {});
sensorTag.on('irTemperatureChange', sensorTag.on('irTemperatureChange',
function(objectTemperature, ambientTemperature){ function(objectTemperature, ambientTemperature) {
var msg = {'topic': node.topic + '/temperature'}; var msg = {'topic': node.topic + '/temperature'};
msg.payload = {'object': objectTemperature.toFixed(1), msg.payload = {'object': objectTemperature.toFixed(1),
'ambient':ambientTemperature.toFixed(1) 'ambient':ambientTemperature.toFixed(1)
}; };
node.send(msg); node.send(msg);
}); });
sensorTag.enableBarometricPressure(function(){}); sensorTag.enableBarometricPressure(function() {});
sensorTag.on('barometricPressureChange', function(pressure){ sensorTag.on('barometricPressureChange', function(pressure) {
var msg = {'topic': node.topic + '/pressure'}; var msg = {'topic': node.topic + '/pressure'};
msg.payload = {'pres': pressure.toFixed(1)}; msg.payload = {'pres': pressure.toFixed(1)};
node.send(msg); node.send(msg);
}); });
sensorTag.enableHumidity(function(){}); sensorTag.enableHumidity(function() {});
sensorTag.on('humidityChange', function(temp, humidity) { sensorTag.on('humidityChange', function(temp, humidity) {
var msg = {'topic': node.topic + '/humidity'}; var msg = {'topic': node.topic + '/humidity'};
msg.payload = {'temp': temp.toFixed(1), msg.payload = {'temp': temp.toFixed(1),
@ -69,25 +69,25 @@ function sensorTagNode(n) {
}; };
node.send(msg); node.send(msg);
}); });
sensorTag.enableAccelerometer(function(){}); sensorTag.enableAccelerometer(function() {});
sensorTag.on('accelerometerChange', function(x,y,z){ sensorTag.on('accelerometerChange', function(x,y,z) {
var msg = {'topic': node.topic + '/accelerometer'}; var msg = {'topic': node.topic + '/accelerometer'};
msg.payload = {'x': x, 'y': y, 'z': z}; msg.payload = {'x': x, 'y': y, 'z': z};
node.send(msg); node.send(msg);
}); });
sensorTag.enableMagnetometer(function() {}); sensorTag.enableMagnetometer(function() {});
sensorTag.on('magnetometerChange', function(x,y,z){ sensorTag.on('magnetometerChange', function(x,y,z) {
var msg = {'topic': node.topic + '/magnetometer'}; var msg = {'topic': node.topic + '/magnetometer'};
msg.payload = {'x': x, 'y': y, 'z': z}; msg.payload = {'x': x, 'y': y, 'z': z};
node.send(msg); node.send(msg);
}); });
sensorTag.enableGyroscope(function(){}); sensorTag.enableGyroscope(function() {});
sensorTag.on('gyroscopeChange', function(x,y,z){ sensorTag.on('gyroscopeChange', function(x,y,z) {
var msg = {'topic': node.topic + '/gyroscope'}; var msg = {'topic': node.topic + '/gyroscope'};
msg.payload = {'x': x, 'y': y, 'z': z}; msg.payload = {'x': x, 'y': y, 'z': z};
node.send(msg); node.send(msg);
}); });
sensorTag.on('simpleKeyChange', function(left, right){ sensorTag.on('simpleKeyChange', function(left, right) {
var msg = {'topic': node.topic + '/keys'}; var msg = {'topic': node.topic + '/keys'};
msg.payload = {'left': left, 'right': right}; msg.payload = {'left': left, 'right': right};
node.send(msg); node.send(msg);
@ -104,21 +104,21 @@ function sensorTagNode(n) {
function enable(node) { function enable(node) {
if (node.temperature) { if (node.temperature) {
node.stag.notifyIrTemperature(function(){}); node.stag.notifyIrTemperature(function() {});
} else { } else {
node.stag.unnotifyIrTemperature(function(){}); node.stag.unnotifyIrTemperature(function() {});
} }
if (node.pressure) { if (node.pressure) {
node.stag.notifyBarometricPressure(function(){}); node.stag.notifyBarometricPressure(function() {});
} else { } else {
node.stag.unnotifyBarometricPressure(function(){}); node.stag.unnotifyBarometricPressure(function() {});
} }
if (node.humidity) { if (node.humidity) {
node.stag.notifyHumidity(function() {}); node.stag.notifyHumidity(function() {});
} else { } else {
node.stag.unnotifyHumidity(function() {}); node.stag.unnotifyHumidity(function() {});
} }
if (node.accelerometer){ if (node.accelerometer) {
node.stag.notifyAccelerometer(function() {}); node.stag.notifyAccelerometer(function() {});
} else { } else {
node.stag.unnotifyAccelerometer(function() {}); node.stag.unnotifyAccelerometer(function() {});

View File

@ -43,17 +43,17 @@ module.exports = function(RED) {
else { http = require("http"); } else { http = require("http"); }
this.on("input", function(msg) { this.on("input", function(msg) {
this.url = this.baseurl + '/input/post.json?'; this.url = this.baseurl + '/input/post.json?';
if (msg.payload.indexOf(':') > -1){ if (msg.payload.indexOf(':') > -1) {
this.url += 'json={' + msg.payload + '}'; this.url += 'json={' + msg.payload + '}';
} else { } else {
this.url += 'csv='+msg.payload; this.url += 'csv='+msg.payload;
} }
this.url += '&apikey='+this.apikey; this.url += '&apikey='+this.apikey;
var nodegroup = this.nodegroup || msg.nodegroup; var nodegroup = this.nodegroup || msg.nodegroup;
if (nodegroup !== ""){ if (nodegroup !== "") {
this.url += '&node=' + nodegroup; this.url += '&node=' + nodegroup;
} }
if (typeof msg.time !== 'undefined'){ if (typeof msg.time !== 'undefined') {
this.url += '&time=' + msg.time; this.url += '&time=' + msg.time;
} }
node.log("[emoncms] "+this.url); node.log("[emoncms] "+this.url);

View File

@ -50,7 +50,7 @@ module.exports = function(RED) {
if (dweetio == null) { dweetio = new DweetClient(); } if (dweetio == null) { dweetio = new DweetClient(); }
var node = this; var node = this;
dweetio.listen_for(node.thing, function(dweet){ dweetio.listen_for(node.thing, function(dweet) {
// This will be called anytime there is a new dweet for my-thing // This will be called anytime there is a new dweet for my-thing
if (dweet.content.hasOwnProperty("payload")) { if (dweet.content.hasOwnProperty("payload")) {
dweet.payload=dweet.content.payload; dweet.payload=dweet.content.payload;

View File

@ -93,7 +93,7 @@ module.exports = function(RED) {
try { try {
resolve(res.pushes[0].modified); resolve(res.pushes[0].modified);
} }
catch(ex){ catch(ex) {
self.warn('Unable to get history.'); self.warn('Unable to get history.');
resolve(0); resolve(0);
} }
@ -329,7 +329,7 @@ module.exports = function(RED) {
try { try {
this.deviceid = this.credentials.deviceid; this.deviceid = this.credentials.deviceid;
} }
catch(err){} catch(err) {}
} }
if (configNode) { if (configNode) {
@ -390,7 +390,7 @@ module.exports = function(RED) {
PushbulletOut.prototype.pushMsg = function(pushtype, deviceid, title, msg) { PushbulletOut.prototype.pushMsg = function(pushtype, deviceid, title, msg) {
var self = this; var self = this;
if (this.pusher) { if (this.pusher) {
var handleErr = function(msg){ var handleErr = function(msg) {
return function(err) { return function(err) {
if (err) { if (err) {
self.error(msg); self.error(msg);