mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Update node-red-nodes sample, analysis, storage and time nodes to use strict and pass jshint scan
This commit is contained in:
parent
43dfded402
commit
ebf950d818
@ -19,7 +19,8 @@
|
|||||||
// Sample Node-RED node file
|
// Sample Node-RED node file
|
||||||
|
|
||||||
// Require main module
|
// Require main module
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
// The main node definition - most things happen in here
|
// The main node definition - most things happen in here
|
||||||
function SampleNode(n) {
|
function SampleNode(n) {
|
||||||
@ -50,3 +51,4 @@ function SampleNode(n) {
|
|||||||
// Register the node by name. This must be called before overriding any of the
|
// Register the node by name. This must be called before overriding any of the
|
||||||
// Node functions.
|
// Node functions.
|
||||||
RED.nodes.registerType("sample",SampleNode);
|
RED.nodes.registerType("sample",SampleNode);
|
||||||
|
}
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var badwords = require('badwords');
|
var badwords = require('badwords');
|
||||||
if (badwords.length == 0 ) { return; }
|
if (badwords.length === 0 ) { return; }
|
||||||
var badwordsRegExp = require('badwords/regexp');
|
var badwordsRegExp = require('badwords/regexp');
|
||||||
|
|
||||||
function BadwordsNode(n) {
|
function BadwordsNode(n) {
|
||||||
@ -29,3 +30,4 @@ function BadwordsNode(n) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("badwords",BadwordsNode);
|
RED.nodes.registerType("badwords",BadwordsNode);
|
||||||
|
}
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var WordPos = require('wordpos');
|
var WordPos = require('wordpos');
|
||||||
var wordpos = new WordPos();
|
var wordpos = new WordPos();
|
||||||
|
|
||||||
@ -29,3 +30,4 @@ function WordPOSNode(n) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("wordpos",WordPOSNode);
|
RED.nodes.registerType("wordpos",WordPOSNode);
|
||||||
|
}
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var lvldb = require('level');
|
var lvldb = require('level');
|
||||||
|
|
||||||
function LevelNode(n) {
|
function LevelNode(n) {
|
||||||
@ -22,7 +23,7 @@ function LevelNode(n) {
|
|||||||
this.dbname = n.db;
|
this.dbname = n.db;
|
||||||
var node = this;
|
var node = this;
|
||||||
lvldb(this.dbname, function(err, db) {
|
lvldb(this.dbname, function(err, db) {
|
||||||
if (err) node.error(err);
|
if (err) { node.error(err); }
|
||||||
node.db = db;
|
node.db = db;
|
||||||
});
|
});
|
||||||
this.on('close', function() {
|
this.on('close', function() {
|
||||||
@ -52,7 +53,7 @@ function LevelDBNodeIn(n) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined");
|
if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -78,12 +79,12 @@ function LevelDBNodeOut(n) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.levelConfig.db.put(msg.topic, msg.payload, function(err) {
|
node.levelConfig.db.put(msg.topic, msg.payload, function(err) {
|
||||||
if (err) node.error(err);
|
if (err) { node.error(err); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined");
|
if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,3 +93,4 @@ function LevelDBNodeOut(n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("leveldb out",LevelDBNodeOut);
|
RED.nodes.registerType("leveldb out",LevelDBNodeOut);
|
||||||
|
}
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var reconnect = RED.settings.mysqlReconnectTime || 30000;
|
var reconnect = RED.settings.mysqlReconnectTime || 30000;
|
||||||
var mysqldb = require('mysql');
|
var mysqldb = require('mysql');
|
||||||
var querystring = require('querystring');
|
var querystring = require('querystring');
|
||||||
@ -22,7 +23,7 @@ var querystring = require('querystring');
|
|||||||
RED.httpAdmin.get('/MySQLdatabase/:id',function(req,res) {
|
RED.httpAdmin.get('/MySQLdatabase/:id',function(req,res) {
|
||||||
var credentials = RED.nodes.getCredentials(req.params.id);
|
var credentials = RED.nodes.getCredentials(req.params.id);
|
||||||
if (credentials) {
|
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 {
|
} else {
|
||||||
res.send(JSON.stringify({}));
|
res.send(JSON.stringify({}));
|
||||||
}
|
}
|
||||||
@ -41,12 +42,12 @@ RED.httpAdmin.post('/MySQLdatabase/:id',function(req,res) {
|
|||||||
req.on('end', function(){
|
req.on('end', function(){
|
||||||
var newCreds = querystring.parse(body);
|
var newCreds = querystring.parse(body);
|
||||||
var credentials = RED.nodes.getCredentials(req.params.id)||{};
|
var credentials = RED.nodes.getCredentials(req.params.id)||{};
|
||||||
if (newCreds.user == null || newCreds.user == "") {
|
if (newCreds.user == null || newCreds.user === "") {
|
||||||
delete credentials.user;
|
delete credentials.user;
|
||||||
} else {
|
} else {
|
||||||
credentials.user = newCreds.user;
|
credentials.user = newCreds.user;
|
||||||
}
|
}
|
||||||
if (newCreds.password == "") {
|
if (newCreds.password === "") {
|
||||||
delete credentials.password;
|
delete credentials.password;
|
||||||
} else {
|
} else {
|
||||||
credentials.password = newCreds.password||credentials.password;
|
credentials.password = newCreds.password||credentials.password;
|
||||||
@ -65,15 +66,15 @@ function MySQLNode(n) {
|
|||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.connecting = false;
|
this.connecting = false;
|
||||||
|
|
||||||
if (n.user) {
|
|
||||||
var credentials = {};
|
var credentials = {};
|
||||||
|
if (n.user) {
|
||||||
credentials.user = n.user;
|
credentials.user = n.user;
|
||||||
credentials.password = n.pass;
|
credentials.password = n.pass;
|
||||||
RED.nodes.addCredentials(n.id,credentials);
|
RED.nodes.addCredentials(n.id,credentials);
|
||||||
this.user = n.user;
|
this.user = n.user;
|
||||||
this.password = n.pass;
|
this.password = n.pass;
|
||||||
} else {
|
} else {
|
||||||
var credentials = RED.nodes.getCredentials(n.id);
|
credentials = RED.nodes.getCredentials(n.id);
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
this.user = credentials.user;
|
this.user = credentials.user;
|
||||||
this.password = credentials.password;
|
this.password = credentials.password;
|
||||||
@ -125,7 +126,7 @@ function MySQLNode(n) {
|
|||||||
if (this.tick) { clearTimeout(this.tick); }
|
if (this.tick) { clearTimeout(this.tick); }
|
||||||
if (this.connection) {
|
if (this.connection) {
|
||||||
node.connection.end(function(err) {
|
node.connection.end(function(err) {
|
||||||
if (err) node.error(err);
|
if (err) { node.error(err); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -153,7 +154,7 @@ function MysqlDBNodeIn(n) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (typeof msg.topic !== 'string') node.error("msg.topic : the query is not defined as a string");
|
if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -193,3 +194,4 @@ RED.nodes.registerType("mysql",MysqlDBNodeIn);
|
|||||||
//}
|
//}
|
||||||
//}
|
//}
|
||||||
//RED.nodes.registerType("mysql out",MysqlDBNodeOut);
|
//RED.nodes.registerType("mysql out",MysqlDBNodeOut);
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var SunCalc = require('suncalc');
|
var SunCalc = require('suncalc');
|
||||||
|
|
||||||
function SunNode(n) {
|
function SunNode(n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user