Browse Source

formatting and whitespace fixes

bug-decimal-undefined
John Robinson 4 years ago
parent
commit
bddd710d74
No known key found for this signature in database
3 changed files with 18 additions and 18 deletions
  1. +3
    -3
      boolean-logic-ultimate/BlinkerUltimate.js
  2. +13
    -13
      boolean-logic-ultimate/FilterUltimate.js
  3. +2
    -2
      boolean-logic-ultimate/InterruptFlowUltimate.js

+ 3
- 3
boolean-logic-ultimate/BlinkerUltimate.js View File

} }
} }
if (msg.hasOwnProperty("payload")) { if (msg.hasOwnProperty("payload")) {
// 06/11/2019
// 06/11/2019
if (ToBoolean(msg.payload) === true) { if (ToBoolean(msg.payload) === true) {
if (node.tBlinker !== null) clearInterval(node.tBlinker); if (node.tBlinker !== null) clearInterval(node.tBlinker);
node.tBlinker = setInterval(handleTimer, node.blinkfrequency); // Start the timer that handles the queue of telegrams node.tBlinker = setInterval(handleTimer, node.blinkfrequency); // Start the timer that handles the queue of telegrams
node.curPayload = false; node.curPayload = false;
} }
} }
}); });


node.on('close', function () { node.on('close', function () {




RED.nodes.registerType("BlinkerUltimate", BlinkerUltimate); RED.nodes.registerType("BlinkerUltimate", BlinkerUltimate);
}
}

+ 13
- 13
boolean-logic-ultimate/FilterUltimate.js View File

if (msg.hasOwnProperty("topic")){ if (msg.hasOwnProperty("topic")){
sTopic = (msg.topic === "" ? sTopic : msg.topic); sTopic = (msg.topic === "" ? sTopic : msg.topic);
} }
if (typeof msg.payload !== "undefined") { if (typeof msg.payload !== "undefined") {
var bRes = ToBoolean(msg.payload); var bRes = ToBoolean(msg.payload);
if (typeof bRes === "undefined") return; if (typeof bRes === "undefined") return;
// 24/01/2020 Clone input message and replace only relevant topics // 24/01/2020 Clone input message and replace only relevant topics
var msgTrue = RED.util.cloneMessage(msg);
var msgTrue = RED.util.cloneMessage(msg);
msgTrue.topic = sTopic; msgTrue.topic = sTopic;
msgTrue.payload = true; msgTrue.payload = true;
var msgFalse = RED.util.cloneMessage(msg);
var msgFalse = RED.util.cloneMessage(msg);
msgFalse.topic = sTopic; msgFalse.topic = sTopic;
msgFalse.payload = false; msgFalse.payload = false;
if (bRes === true) { if (bRes === true) {
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" }); setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true" });
node.send([msgTrue, null]); node.send([msgTrue, null]);
return; return;
} }
}); });
function setNodeStatus({fill, shape, text}) function setNodeStatus({fill, shape, text})
{ {
var dDate = new Date(); var dDate = new Date();
node.status({fill: fill,shape: shape,text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")"}) node.status({fill: fill,shape: shape,text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")"})
} }


function ToBoolean( value ) { function ToBoolean( value ) {
var res = false; var res = false;
if (typeof value === 'boolean') { if (typeof value === 'boolean') {
res = value; res = value;
}
}
else if( typeof value === 'number' || typeof value === 'string' ) { else if( typeof value === 'number' || typeof value === 'string' ) {
// Is it formated as a decimal number? // Is it formated as a decimal number?
if( decimal.test( value ) ) { if( decimal.test( value ) ) {
res = value.toLowerCase() === "true"; res = value.toLowerCase() === "true";
} }
} }
return res; return res;
}; };
}
}


RED.nodes.registerType("FilterUltimate",FilterUltimate); RED.nodes.registerType("FilterUltimate",FilterUltimate);
}
}

+ 2
- 2
boolean-logic-ultimate/InterruptFlowUltimate.js View File

this.on('input', function (msg) { this.on('input', function (msg) {
var sIncomingTopic = ""; var sIncomingTopic = "";
if (msg.hasOwnProperty("topic")) { if (msg.hasOwnProperty("topic")) {
// 06/11/2019
// 06/11/2019
sIncomingTopic = msg.topic.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ''); // Cut unwanted Characters sIncomingTopic = msg.topic.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ''); // Cut unwanted Characters
if (sIncomingTopic == node.sTriggerTopic) { if (sIncomingTopic == node.sTriggerTopic) {
if (msg.hasOwnProperty("play")) { if (msg.hasOwnProperty("play")) {




RED.nodes.registerType("InterruptFlowUltimate", InterruptFlowUltimate); RED.nodes.registerType("InterruptFlowUltimate", InterruptFlowUltimate);
}
}

Loading…
Cancel
Save