mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Update node-red-nodes social nodes to use strict and pass jshint scan
This commit is contained in:
parent
9b487098ae
commit
62956b0bb8
@ -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 nma = require('nma');
|
var nma = require('nma');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ var querystring = require('querystring');
|
|||||||
RED.httpAdmin.get('/nma/:id',function(req,res) {
|
RED.httpAdmin.get('/nma/: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({hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
|
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
|
||||||
} else {
|
} else {
|
||||||
res.send(JSON.stringify({}));
|
res.send(JSON.stringify({}));
|
||||||
}
|
}
|
||||||
@ -70,7 +71,7 @@ RED.httpAdmin.post('/nma/: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.pushkey == "") {
|
if (newCreds.pushkey === "") {
|
||||||
delete credentials.pushkey;
|
delete credentials.pushkey;
|
||||||
} else {
|
} else {
|
||||||
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
||||||
@ -79,3 +80,4 @@ RED.httpAdmin.post('/nma/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
@ -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 growl = require('growl');
|
var growl = require('growl');
|
||||||
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
|
var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png";
|
||||||
|
|
||||||
@ -37,3 +38,4 @@ function NotifyNode(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("notify",NotifyNode);
|
RED.nodes.registerType("notify",NotifyNode);
|
||||||
|
}
|
||||||
|
@ -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 Prowl = require('node-prowl');
|
var Prowl = require('node-prowl');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
@ -32,8 +33,8 @@ function ProwlNode(n) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.title = n.title;
|
this.title = n.title;
|
||||||
this.priority = parseInt(n.priority);
|
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);
|
var credentials = RED.nodes.getCredentials(n.id);
|
||||||
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
|
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
|
||||||
else {
|
else {
|
||||||
@ -54,7 +55,7 @@ function ProwlNode(n) {
|
|||||||
if (node.pushkey) {
|
if (node.pushkey) {
|
||||||
try {
|
try {
|
||||||
node.prowl.push(msg.payload, titl, { priority: pri }, function(err, remaining) {
|
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.' );
|
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) {
|
RED.httpAdmin.get('/prowl/: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({hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
|
res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
|
||||||
}
|
}
|
||||||
else if (pushkeys && pushkeys.prowlkey) {
|
else if (pushkeys && pushkeys.prowlkey) {
|
||||||
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true});
|
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true});
|
||||||
credentials = RED.nodes.getCredentials(req.params.id);
|
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 {
|
else {
|
||||||
res.send(JSON.stringify({}));
|
res.send(JSON.stringify({}));
|
||||||
@ -99,7 +100,7 @@ RED.httpAdmin.post('/prowl/: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.pushkey == "") {
|
if (newCreds.pushkey === "") {
|
||||||
delete credentials.pushkey;
|
delete credentials.pushkey;
|
||||||
} else {
|
} else {
|
||||||
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
||||||
@ -108,3 +109,4 @@ RED.httpAdmin.post('/prowl/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
@ -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 PushBullet = require('pushbullet');
|
var PushBullet = require('pushbullet');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ function PushbulletNode(n) {
|
|||||||
try {
|
try {
|
||||||
if (!isNaN(dev)) { dev = Number(dev); }
|
if (!isNaN(dev)) { dev = Number(dev); }
|
||||||
node.pusher.note(dev, titl, msg.payload, function(err, response) {
|
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);
|
//console.log(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -77,12 +78,12 @@ var querystring = require('querystring');
|
|||||||
RED.httpAdmin.get('/pushbullet/:id',function(req,res) {
|
RED.httpAdmin.get('/pushbullet/: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({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) {
|
else if (pushkeys && pushkeys.pushbullet && pushkeys.deviceid) {
|
||||||
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.pushbullet,deviceid:pushkeys.deviceid,global:true});
|
RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.pushbullet,deviceid:pushkeys.deviceid,global:true});
|
||||||
credentials = RED.nodes.getCredentials(req.params.id);
|
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 {
|
else {
|
||||||
res.send(JSON.stringify({}));
|
res.send(JSON.stringify({}));
|
||||||
@ -102,12 +103,12 @@ RED.httpAdmin.post('/pushbullet/: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.deviceid == null || newCreds.deviceid == "") {
|
if (newCreds.deviceid === null || newCreds.deviceid === "") {
|
||||||
delete credentials.deviceid;
|
delete credentials.deviceid;
|
||||||
} else {
|
} else {
|
||||||
credentials.deviceid = newCreds.deviceid;
|
credentials.deviceid = newCreds.deviceid;
|
||||||
}
|
}
|
||||||
if (newCreds.pushkey == "") {
|
if (newCreds.pushkey === "") {
|
||||||
delete credentials.pushkey;
|
delete credentials.pushkey;
|
||||||
} else {
|
} else {
|
||||||
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
||||||
@ -116,3 +117,4 @@ RED.httpAdmin.post('/pushbullet/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
@ -17,13 +17,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
var Pusher = require('pusher');
|
var Pusher = require('pusher');
|
||||||
var PusherClient = require('pusher-client');
|
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
|
//node for subscribing to an event/channel
|
||||||
function PusherNode(n) {
|
function PusherNode(n) {
|
||||||
// Create a RED node
|
// Create a RED node
|
||||||
@ -129,24 +127,24 @@ RED.httpAdmin.post('/pusher/:id',function(req,res) {
|
|||||||
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.pusherappid == null || newCreds.pusherappid == "") {
|
if (newCreds.pusherappid === null || newCreds.pusherappid === "") {
|
||||||
delete credentials.pusherappid;
|
delete credentials.pusherappid;
|
||||||
} else {
|
} else {
|
||||||
credentials.pusherappid = newCreds.pusherappid;
|
credentials.pusherappid = newCreds.pusherappid;
|
||||||
}
|
}
|
||||||
if (newCreds.pusherappkey == "") {
|
if (newCreds.pusherappkey === "") {
|
||||||
delete credentials.pusherappkey;
|
delete credentials.pusherappkey;
|
||||||
} else {
|
} else {
|
||||||
credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey;
|
credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCreds.pusherappsecret == "") {
|
if (newCreds.pusherappsecret === "") {
|
||||||
delete credentials.pusherappsecret;
|
delete credentials.pusherappsecret;
|
||||||
} else {
|
} else {
|
||||||
credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret;
|
credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCreds.pusherappkey_sub == "") {
|
if (newCreds.pusherappkey_sub === "") {
|
||||||
delete credentials.pusherappkey_sub;
|
delete credentials.pusherappkey_sub;
|
||||||
} else {
|
} else {
|
||||||
credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub;
|
credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub;
|
||||||
@ -156,3 +154,4 @@ RED.httpAdmin.post('/pusher/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
@ -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 PushOver = require('pushover-notifications');
|
var PushOver = require('pushover-notifications');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ function PushoverNode(n) {
|
|||||||
};
|
};
|
||||||
//console.log("Sending",pushmsg);
|
//console.log("Sending",pushmsg);
|
||||||
pusher.send( pushmsg, function(err, response) {
|
pusher.send( pushmsg, function(err, response) {
|
||||||
if (err) node.error("Pushover Error: "+err);
|
if (err) { node.error("Pushover Error: "+err); }
|
||||||
//console.log(response);
|
//console.log(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,7 +76,7 @@ var querystring = require('querystring');
|
|||||||
RED.httpAdmin.get('/pushover/:id',function(req,res) {
|
RED.httpAdmin.get('/pushover/: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({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));
|
res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
|
||||||
} else {
|
} else {
|
||||||
res.send(JSON.stringify({}));
|
res.send(JSON.stringify({}));
|
||||||
}
|
}
|
||||||
@ -94,12 +95,12 @@ RED.httpAdmin.post('/pushover/: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.deviceid == null || newCreds.deviceid == "") {
|
if (newCreds.deviceid === null || newCreds.deviceid === "") {
|
||||||
delete credentials.deviceid;
|
delete credentials.deviceid;
|
||||||
} else {
|
} else {
|
||||||
credentials.deviceid = newCreds.deviceid;
|
credentials.deviceid = newCreds.deviceid;
|
||||||
}
|
}
|
||||||
if (newCreds.pushkey == "") {
|
if (newCreds.pushkey === "") {
|
||||||
delete credentials.pushkey;
|
delete credentials.pushkey;
|
||||||
} else {
|
} else {
|
||||||
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
credentials.pushkey = newCreds.pushkey||credentials.pushkey;
|
||||||
@ -108,3 +109,4 @@ RED.httpAdmin.post('/pushover/:id',function(req,res) {
|
|||||||
res.send(200);
|
res.send(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user