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

load of tiny listing fixes, undef, unused, etc

This commit is contained in:
Dave Conway-Jones 2016-04-09 18:00:14 +01:00
parent 37ba29484a
commit 48bcd3c7df
22 changed files with 532 additions and 535 deletions

View File

@ -7,10 +7,10 @@
"disallowMultipleSpaces": {"allowEOLComments": true}, "disallowMultipleSpaces": {"allowEOLComments": true},
"disallowKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": [],
"requireSpaceBeforeBlockStatements": 1, "requireSpaceBeforeBlockStatements": 1,
"requireSpaceBeforeObjectValues": false, //"requireSpaceBeforeObjectValues": false,
//"requireSemicolons": true, //"requireSemicolons": true,
//"validateParameterSeparator": ", ", //"validateParameterSeparator": ", ",
//"validateQuoteMarks": false,
"requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"], "requireSpaceAfterKeywords": ["do","for","if","else","switch","case","try","while"],
"maximumLineLength": 255, "maximumLineLength": 255
"validateQuoteMarks": false
} }

View File

@ -1,4 +1,8 @@
{ {
"predef": [ "RED" ],
"node": true,
"browser": true,
"jquery": true,
"asi": true, // allow missing semicolons "asi": true, // allow missing semicolons
"curly": true, // require braces "curly": true, // require braces
"eqnull": true, // ignore ==null "eqnull": true, // ignore ==null
@ -9,5 +13,6 @@
//"unused": true, // Check for unused functions and variables //"unused": true, // Check for unused functions and variables
"loopfunc": true, // allow functions to be defined in loops "loopfunc": true, // allow functions to be defined in loops
//"expr": true, // allow ternery operator syntax... //"expr": true, // allow ternery operator syntax...
"sub": true // don't warn that foo['bar'] should be written as foo.bar "sub": true, // don't warn that foo['bar'] should be written as foo.bar
"undef": true // warn about undefined variables
} }

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pilcd", "name" : "node-red-node-pilcd",
"version" : "0.0.4", "version" : "0.0.5",
"description" : "A Node-RED node for Raspberry Pi to write to HD44780 style LCD panels.", "description" : "A Node-RED node for Raspberry Pi to write to HD44780 style LCD panels.",
"dependencies" : { "dependencies" : {
}, },

View File

@ -43,7 +43,6 @@ module.exports = function(RED) {
var node = this; var node = this;
function inputlistener(msg) { function inputlistener(msg) {
var out = msg.payload.toString();
if (RED.settings.verbose) { node.log("inp: " + msg.payload); } if (RED.settings.verbose) { node.log("inp: " + msg.payload); }
if (node.child !== null) { node.child.stdin.write(msg.payload + "\n"); } if (node.child !== null) { node.child.stdin.write(msg.payload + "\n"); }
else { node.warn("Command not running"); } else { node.warn("Command not running"); }
@ -90,7 +89,6 @@ module.exports = function(RED) {
} }
node.on("close", function(done) { node.on("close", function(done) {
delete pinsInUse[node.pin];
if (node.child != null) { if (node.child != null) {
node.child.stdin.write("c:lose" + node.pin); node.child.stdin.write("c:lose" + node.pin);
node.child.kill('SIGKILL'); node.child.kill('SIGKILL');

View File

@ -27,8 +27,7 @@ module.exports = function(RED) {
var devices = HID.devices(0x16c0,0x05df); var devices = HID.devices(0x16c0,0x05df);
for (var i=0; i< devices.length; i++) { for (var i=0; i< devices.length; i++) {
if (devices[i].product == 'DigiUSB') { if (devices[i].product == 'DigiUSB') {
path = devices[i].path; node.log("found: " + devices[i].path);
node.log("found: " + path);
try { try {
device = new HID.HID(devices[i].path); device = new HID.HID(devices[i].path);
break; break;

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-digirgb", "name" : "node-red-node-digirgb",
"version" : "0.0.5", "version" : "0.0.6",
"description" : "A Node-RED node to control a Digispark RGB LED", "description" : "A Node-RED node to control a Digispark RGB LED",
"dependencies" : { "dependencies" : {
"node-hid" : "0.4.*" "node-hid" : "0.4.*"

View File

@ -167,7 +167,8 @@ var colours = {
'amber':'#FFD200' 'amber':'#FFD200'
}; };
var p1 = /^\#[A-Fa-f0-9]{6}$/ var p1 = /^\#[A-Fa-f0-9]{6}$/;
var r, g, b;
module.exports.getRGB = function(col,rgb) { module.exports.getRGB = function(col,rgb) {
col = col.toString().toLowerCase(); col = col.toString().toLowerCase();

View File

@ -51,7 +51,7 @@ module.exports = function(RED) {
if (this.wipe < 0) { this.wipe = 0; } if (this.wipe < 0) { this.wipe = 0; }
var node = this; var node = this;
var needle = "255,255,255"; var needle = "255,255,255";
var p1 = /^\#[A-Fa-f0-9]{6}$/ //var p1 = /^\#[A-Fa-f0-9]{6}$/
var p2 = /^[0-9]+,[0-9]+,[0-9]+$/ var p2 = /^[0-9]+,[0-9]+,[0-9]+$/
var p3 = /^[0-9]+,[0-9]+,[0-9]+,[0-9]+$/ var p3 = /^[0-9]+,[0-9]+,[0-9]+,[0-9]+$/
var p4 = /^[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+$/ var p4 = /^[0-9]+,[0-9]+,[0-9]+,[0-9]+,[0-9]+$/
@ -125,7 +125,7 @@ module.exports = function(RED) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); } if (RED.settings.verbose) { node.log("err: "+data+" :"); }
}); });
node.child.on('close', function (code) { node.child.on('close', function () {
node.child = null; node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) { if (node.done) {

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pi-neopixel", "name" : "node-red-node-pi-neopixel",
"version" : "0.0.11", "version" : "0.0.12",
"description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.", "description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.",
"dependencies" : { "dependencies" : {
}, },

View File

@ -18,14 +18,14 @@
* limitations under the License. * limitations under the License.
**/ **/
//might need to modify accordingly module.exports = function(RED) {
var RED = require(process.env.NODE_RED_HOME+"/red/red"); "use strict";
//import noble //import noble
var noble = require('noble'); var noble = require('noble');
// The main node definition - most things happen in here // The main node definition - most things happen in here
function BleScan(n) { function BleScan(n) {
// Create a RED node // Create a RED node
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
@ -66,8 +66,8 @@ function BleScan(n) {
try { noble.stopScanning(); } try { noble.stopScanning(); }
catch (err) { console.log(err); } catch (err) { console.log(err); }
}); });
}
// Register the node by name. This must be called before overriding any of the
// Node functions.
RED.nodes.registerType("scanBLE", BleScan);
} }
// Register the node by name. This must be called before overriding any of the
// Node functions.
RED.nodes.registerType("scanBLE", BleScan);

View File

@ -168,6 +168,7 @@ var colours = {
}; };
var hexColour = /^#([0-9A-F][0-9A-F][0-9A-F]){1,2}$/i; var hexColour = /^#([0-9A-F][0-9A-F][0-9A-F]){1,2}$/i;
var r, g, b;
module.exports.getRGB = function(col,rgb) { module.exports.getRGB = function(col,rgb) {
if (!col) { if (!col) {

View File

@ -168,6 +168,7 @@ var colours = {
}; };
var hexColour = /^#([0-9A-F][0-9A-F][0-9A-F]){1,2}$/i; var hexColour = /^#([0-9A-F][0-9A-F][0-9A-F]){1,2}$/i;
var r, g, b;
module.exports.getRGB = function(col,rgb) { module.exports.getRGB = function(col,rgb) {
if (!col) { if (!col) {

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pi-unicorn-hat", "name" : "node-red-node-pi-unicorn-hat",
"version" : "0.0.12", "version" : "0.0.13",
"description" : "A Node-RED node to output to a Raspberry Pi Unicorn HAT from Pimorini.", "description" : "A Node-RED node to output to a Raspberry Pi Unicorn HAT from Pimorini.",
"dependencies" : { "dependencies" : {
"pngjs": "2.2.*" "pngjs": "2.2.*"

View File

@ -93,7 +93,7 @@ module.exports = function(RED) {
function inputlistener(msg) { function inputlistener(msg) {
if (typeof msg.payload === "string") { if (typeof msg.payload === "string") {
var a,b,c,d,e,i,j,x,y; var a,b,i,j,x,y;
msg.payload = msg.payload.replace('"',''); msg.payload = msg.payload.replace('"','');
var s = msg.payload.toUpperCase().split(","); var s = msg.payload.toUpperCase().split(",");
var doDraw = true; var doDraw = true;
@ -235,7 +235,7 @@ module.exports = function(RED) {
if (RED.settings.verbose) { node.log("err: "+data+" :"); } if (RED.settings.verbose) { node.log("err: "+data+" :"); }
}); });
node.child.on('close', function (code) { node.child.on('close', function () {
node.child = null; node.child = null;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); } if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) { if (node.done) {
@ -253,7 +253,7 @@ module.exports = function(RED) {
node.on("close", function(done) { node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:"closed"}); node.status({fill:"grey",shape:"ring",text:"closed"});
if (node.tout) { clearTimeout(tout); } if (node.tout) { clearTimeout(node.tout); }
if (node.child != null) { if (node.child != null) {
node.done = done; node.done = done;
node.child.kill('SIGKILL'); node.child.kill('SIGKILL');

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-snmp", "name" : "node-red-node-snmp",
"version" : "0.0.5", "version" : "0.0.6",
"description" : "A Node-RED node that looks for SNMP oids.", "description" : "A Node-RED node that looks for SNMP oids.",
"dependencies" : { "dependencies" : {
"net-snmp" : "1.1.13" "net-snmp" : "1.1.13"

View File

@ -65,6 +65,7 @@ module.exports = function(RED) {
this.oids = n.oids.replace(/\s/g,""); this.oids = n.oids.replace(/\s/g,"");
this.session = snmp.createSession (this.host, this.community, {version: this.version}); this.session = snmp.createSession (this.host, this.community, {version: this.version});
var node = this; var node = this;
var msg;
var maxRepetitions = 20; var maxRepetitions = 20;
function sortInt (a, b) { function sortInt (a, b) {
@ -101,7 +102,8 @@ module.exports = function(RED) {
node.send(msg); node.send(msg);
} }
} }
this.on("input",function(msg) { this.on("input",function(m) {
msg = m;
var oids = node.oids || msg.oid; var oids = node.oids || msg.oid;
if (oids) { if (oids) {
msg.oid = oids; msg.oid = oids;

View File

@ -23,8 +23,8 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.title = n.title; this.title = n.title;
var node = this; var node = this;
this.on("input",function(msg) { node.on("input",function(msg) {
var titl = this.title || msg.topic; var titl = node.title || msg.topic;
if (typeof(msg.payload) == 'object') { if (typeof(msg.payload) == 'object') {
msg.payload = JSON.stringify(msg.payload); msg.payload = JSON.stringify(msg.payload);
} }

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-notify", "name" : "node-red-node-notify",
"version" : "0.0.3", "version" : "0.0.4",
"description" : "A Node-RED node to send local popup Notify alerts", "description" : "A Node-RED node to send local popup Notify alerts",
"dependencies" : { "dependencies" : {
"growl" : "1.8.1" "growl" : "1.8.1"

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pusher", "name" : "node-red-node-pusher",
"version" : "0.0.4", "version" : "0.0.5",
"description" : "A Node-RED node to send and receive messages using Pusher.com", "description" : "A Node-RED node to send and receive messages using Pusher.com",
"dependencies" : { "dependencies" : {
"pusher": "1.0.5", "pusher": "1.0.5",

View File

@ -39,7 +39,7 @@ module.exports = function(RED) {
//create a subscription to the channel and event defined by user //create a subscription to the channel and event defined by user
var socket = new PusherClient(''+this.appkey); var socket = new PusherClient(''+this.appkey);
var my_channel = socket.subscribe(''+this.channel); node.channel = socket.subscribe(''+this.channel);
socket.bind(''+this.eventname, socket.bind(''+this.eventname,
function(data) { function(data) {
var msg = {topic:this.eventname}; var msg = {topic:this.eventname};
@ -60,7 +60,6 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
var node = this; var node = this;
var credentials = this.credentials; var credentials = this.credentials;
if ((credentials) && (credentials.hasOwnProperty("pusherappid"))) { this.appid = credentials.pusherappid; } if ((credentials) && (credentials.hasOwnProperty("pusherappid"))) { this.appid = credentials.pusherappid; }
@ -80,25 +79,16 @@ module.exports = function(RED) {
secret: this.appsecret secret: this.appsecret
}); });
this.on("input", function(msg) { node.on("input", function(msg) {
pusher.trigger(this.channel, this.eventname, { pusher.trigger(this.channel, this.eventname, {
"payload": msg.payload "payload": msg.payload
}); });
}); });
this.on("close", function() { node.on("close", function() {
}); });
} }
//debugging on the output:
var displayResult = function(result) {
node.log(result);
};
var displayError = function(err) {
node.log("Error: "+err);
};
RED.nodes.registerType("pusher in",PusherNode,{ RED.nodes.registerType("pusher in",PusherNode,{
credentials: { credentials: {
pusherappkey_sub: "text" pusherappkey_sub: "text"

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-timeswitch", "name" : "node-red-node-timeswitch",
"version" : "0.0.4", "version" : "0.0.5",
"description" : "A Node-RED node to provide a simple timeswitch to schedule daily on/off events.", "description" : "A Node-RED node to provide a simple timeswitch to schedule daily on/off events.",
"dependencies" : { "dependencies" : {
"suncalc": "1.6.0" "suncalc": "1.6.0"

View File

@ -370,7 +370,7 @@
url: "timeswitch/"+this.id, url: "timeswitch/"+this.id,
type:"POST", type:"POST",
success: function(resp) { success: function(resp) {
RED.notify("Successfully injected: "+label,"success"); RED.notify("Successfully injected: ","success");
}, },
error: function(jqXHR,textStatus,errorThrown) { error: function(jqXHR,textStatus,errorThrown) {
if (jqXHR.status === 404) { if (jqXHR.status === 404) {