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,
"disallowMixedSpacesAndTabs": true,
"disallowMultipleSpaces": {"allowEOLComments": true},
"requireSpaceBeforeBlockStatements": 1,
//"requireSemicolons": true,
//"validateParameterSeparator": ", ",
"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_uuid = n.ble_uuid;
this.on("input", function(msg){
this.on("input", function(msg) {
noble.startScanning();
});

View File

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

View File

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

View File

@ -50,7 +50,7 @@ module.exports = function(RED) {
if (dweetio == null) { dweetio = new DweetClient(); }
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
if (dweet.content.hasOwnProperty("payload")) {
dweet.payload=dweet.content.payload;

View File

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