Apply consistent style to node-red-nodes

(not updating npm for this yet - just whitespace)
This commit is contained in:
dceejay
2015-05-11 19:25:39 +01:00
parent 84f61a0466
commit f497b57b7d
18 changed files with 278 additions and 273 deletions

View File

@@ -35,38 +35,38 @@ module.exports = function(RED) {
if (blink1) {
var r,g,b;
try {
if (p1.test(msg.payload)) {
// if it is a hex colour string
r = parseInt(msg.payload.slice(1,3),16);
g = parseInt(msg.payload.slice(3,5),16);
b = parseInt(msg.payload.slice(5),16);
if (node.fade === 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
else if (p2.test(msg.payload)) {
// if it is a r,g,b triple
var rgb = msg.payload.split(',');
if (node.fade === 0) { blink1.setRGB(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
else { blink1.fadeToRGB(node.fade, parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
}
else {
// you can add fancy colours by name here if you want...
// these are the @cheerlight ones.
var colors = {"red":"#FF0000","green":"#00FF00","blue":"#0000FF","cyan":"#00FFFF",
"white":"#FFFFFF","warmwhite":"#FDF5E6","oldlace":"#FDF5E6","purple":"#800080","magenta":"#FF00FF",
"yellow":"#FFFF00","amber":"#FFD200","orange":"#FFA500","black":"#000000","pink":"#FF69B4"}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
r = parseInt(c.slice(1,3),16);
g = parseInt(c.slice(3,5),16);
b = parseInt(c.slice(5),16);
if (p1.test(msg.payload)) {
// if it is a hex colour string
r = parseInt(msg.payload.slice(1,3),16);
g = parseInt(msg.payload.slice(3,5),16);
b = parseInt(msg.payload.slice(5),16);
if (node.fade === 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
else {
node.warn("Blink1 : invalid msg : "+msg.payload);
else if (p2.test(msg.payload)) {
// if it is a r,g,b triple
var rgb = msg.payload.split(',');
if (node.fade === 0) { blink1.setRGB(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
else { blink1.fadeToRGB(node.fade, parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
}
else {
// you can add fancy colours by name here if you want...
// these are the @cheerlight ones.
var colors = {"red":"#FF0000","green":"#00FF00","blue":"#0000FF","cyan":"#00FFFF",
"white":"#FFFFFF","warmwhite":"#FDF5E6","oldlace":"#FDF5E6","purple":"#800080","magenta":"#FF00FF",
"yellow":"#FFFF00","amber":"#FFD200","orange":"#FFA500","black":"#000000","pink":"#FF69B4"}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
r = parseInt(c.slice(1,3),16);
g = parseInt(c.slice(3,5),16);
b = parseInt(c.slice(5),16);
if (node.fade === 0) { blink1.setRGB( r, g, b ); }
else { blink1.fadeToRGB(node.fade, r, g, b ); }
}
else {
node.warn("Blink1 : invalid msg : "+msg.payload);
}
}
}
} catch (e) { node.error("Blink1 : error"); blink1 = null; }
}
else {