mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Changed code to allow for default values to be used
This commit is contained in:
parent
18c3aa737e
commit
78bb05cc04
@ -13,18 +13,19 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
|
|
||||||
if (node.low === "") {
|
if (node.low) { // if the the node has a value use it
|
||||||
tmp.low = 1;
|
tmp.low = node.low
|
||||||
if ('from' in msg) {
|
} else { // if 'from' in the msg, use it or default to 1
|
||||||
tmp.low = msg.from}
|
tmp.low = ('from' in msg) ? msg.from : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.high === "") {
|
if (node.high) { // if the the node has a value use it
|
||||||
tmp.high = 10;
|
tmp.high = node.high
|
||||||
if ('to' in msg) {tmp.high = msg.to}
|
} else { // if 'to' in the msg, use it or default to 1
|
||||||
|
tmp.high = ('to' in msg) ? msg.to : 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if tmp.low or tmp.high is not a number flag an error and do not send out a msg
|
// if tmp.low or high are not numbers, send an error msg
|
||||||
if ( (isNaN(tmp.low)) || (isNaN(tmp.high)) ) {
|
if ( (isNaN(tmp.low)) || (isNaN(tmp.high)) ) {
|
||||||
this.error({node:"random",text:"one of the input values is not a number"})
|
this.error({node:"random",text:"one of the input values is not a number"})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user