Update node-red-nodes social nodes to use strict and pass jshint scan

This commit is contained in:
Dave C-J 2014-06-28 23:34:59 +01:00
parent 9b487098ae
commit 62956b0bb8
6 changed files with 462 additions and 453 deletions

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
module.exports = function(RED) {
"use strict";
var nma = require('nma');
var util = require('util');
@ -51,7 +52,7 @@ var querystring = require('querystring');
RED.httpAdmin.get('/nma/:id',function(req,res) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
} else {
res.send(JSON.stringify({}));
}
@ -70,7 +71,7 @@ RED.httpAdmin.post('/nma/:id',function(req,res) {
req.on('end', function(){
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.pushkey == "") {
if (newCreds.pushkey === "") {
delete credentials.pushkey;
} else {
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
@ -79,3 +80,4 @@ RED.httpAdmin.post('/nma/:id',function(req,res) {
res.send(200);
});
});
}

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
module.exports = function(RED) {
"use strict";
var growl = require('growl');
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
@ -37,3 +38,4 @@ function NotifyNode(n) {
}
RED.nodes.registerType("notify",NotifyNode);
}

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
module.exports = function(RED) {
"use strict";
var Prowl = require('node-prowl');
var util = require('util');
@ -32,8 +33,8 @@ function ProwlNode(n) {
RED.nodes.createNode(this,n);
this.title = n.title;
this.priority = parseInt(n.priority);
if (this.priority > 2) this.priority = 2;
if (this.priority < -2) this.priority = -2;
if (this.priority > 2) { this.priority = 2; }
if (this.priority < -2) { this.priority = -2; }
var credentials = RED.nodes.getCredentials(n.id);
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
else {
@ -54,7 +55,7 @@ function ProwlNode(n) {
if (node.pushkey) {
try {
node.prowl.push(msg.payload, titl, { priority: pri }, function(err, remaining) {
if (err) node.error(err);
if (err) { node.error(err); }
node.log( remaining + ' calls to Prowl api during current hour.' );
});
}
@ -74,12 +75,12 @@ var querystring = require('querystring');
RED.httpAdmin.get('/prowl/:id',function(req,res) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
}
else if (pushkeys && pushkeys.prowlkey) {
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true});
credentials = RED.nodes.getCredentials(req.params.id);
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=""),global:credentials.global}));;
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!==""),global:credentials.global}));
}
else {
res.send(JSON.stringify({}));
@ -99,7 +100,7 @@ RED.httpAdmin.post('/prowl/:id',function(req,res) {
req.on('end', function(){
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.pushkey == "") {
if (newCreds.pushkey === "") {
delete credentials.pushkey;
} else {
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
@ -108,3 +109,4 @@ RED.httpAdmin.post('/prowl/:id',function(req,res) {
res.send(200);
});
});
}

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
module.exports = function(RED) {
"use strict";
var PushBullet = require('pushbullet');
var util = require('util');
@ -57,7 +58,7 @@ function PushbulletNode(n) {
try {
if (!isNaN(dev)) { dev = Number(dev); }
node.pusher.note(dev, titl, msg.payload, function(err, response) {
if (err) node.error("Pushbullet error: "+err);
if (err) { node.error("Pushbullet error: "+err); }
//console.log(response);
});
}
@ -77,12 +78,12 @@ var querystring = require('querystring');
RED.httpAdmin.get('/pushbullet/:id',function(req,res) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
}
else if (pushkeys && pushkeys.pushbullet && pushkeys.deviceid) {
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.pushbullet,deviceid:pushkeys.deviceid,global:true});
credentials = RED.nodes.getCredentials(req.params.id);
res.send(JSON.stringify({deviceid:credentials.deviceid,global:credentials.global,hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));;
res.send(JSON.stringify({deviceid:credentials.deviceid,global:credentials.global,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
}
else {
res.send(JSON.stringify({}));
@ -102,12 +103,12 @@ RED.httpAdmin.post('/pushbullet/:id',function(req,res) {
req.on('end', function(){
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.deviceid == null || newCreds.deviceid == "") {
if (newCreds.deviceid === null || newCreds.deviceid === "") {
delete credentials.deviceid;
} else {
credentials.deviceid = newCreds.deviceid;
}
if (newCreds.pushkey == "") {
if (newCreds.pushkey === "") {
delete credentials.pushkey;
} else {
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
@ -116,3 +117,4 @@ RED.httpAdmin.post('/pushbullet/:id',function(req,res) {
res.send(200);
});
});
}

View File

@ -17,13 +17,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
module.exports = function(RED) {
"use strict";
var Pusher = require('pusher');
var PusherClient = require('pusher-client');
// Require main module
var RED = require(process.env.NODE_RED_HOME+"/red/red");
//node for subscribing to an event/channel
function PusherNode(n) {
// Create a RED node
@ -129,24 +127,24 @@ RED.httpAdmin.post('/pusher/:id',function(req,res) {
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.pusherappid == null || newCreds.pusherappid == "") {
if (newCreds.pusherappid === null || newCreds.pusherappid === "") {
delete credentials.pusherappid;
} else {
credentials.pusherappid = newCreds.pusherappid;
}
if (newCreds.pusherappkey == "") {
if (newCreds.pusherappkey === "") {
delete credentials.pusherappkey;
} else {
credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey;
}
if (newCreds.pusherappsecret == "") {
if (newCreds.pusherappsecret === "") {
delete credentials.pusherappsecret;
} else {
credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret;
}
if (newCreds.pusherappkey_sub == "") {
if (newCreds.pusherappkey_sub === "") {
delete credentials.pusherappkey_sub;
} else {
credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub;
@ -156,3 +154,4 @@ RED.httpAdmin.post('/pusher/:id',function(req,res) {
res.send(200);
});
});
}

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
var RED = require(process.env.NODE_RED_HOME+"/red/red");
module.exports = function(RED) {
"use strict";
var PushOver = require('pushover-notifications');
var util = require('util');
@ -59,7 +60,7 @@ function PushoverNode(n) {
};
//console.log("Sending",pushmsg);
pusher.send( pushmsg, function(err, response) {
if (err) node.error("Pushover Error: "+err);
if (err) { node.error("Pushover Error: "+err); }
//console.log(response);
});
}
@ -75,7 +76,7 @@ var querystring = require('querystring');
RED.httpAdmin.get('/pushover/:id',function(req,res) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
} else {
res.send(JSON.stringify({}));
}
@ -94,12 +95,12 @@ RED.httpAdmin.post('/pushover/:id',function(req,res) {
req.on('end', function(){
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.deviceid == null || newCreds.deviceid == "") {
if (newCreds.deviceid === null || newCreds.deviceid === "") {
delete credentials.deviceid;
} else {
credentials.deviceid = newCreds.deviceid;
}
if (newCreds.pushkey == "") {
if (newCreds.pushkey === "") {
delete credentials.pushkey;
} else {
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
@ -108,3 +109,4 @@ RED.httpAdmin.post('/pushover/:id',function(req,res) {
res.send(200);
});
});
}