diff --git a/nodes/core/89-delay.html b/nodes/core/89-delay.html
index 7d8892f8c..82a443c4a 100644
--- a/nodes/core/89-delay.html
+++ b/nodes/core/89-delay.html
@@ -27,11 +27,26 @@
+
+
+
+
@@ -57,16 +72,20 @@
name: {value:""}, // along with default values.
pauseType: {value:"delay", required:true},
timeout: {value:"5", required:true, validate:RED.validators.number()},
- rate: {value:"1", required:true, validate:RED.validators.number()}
+ timeoutUnits: {value:"seconds"},
+ rate: {value:"1", required:true, validate:RED.validators.number()},
+ rateUnits: {value: "second"}
},
inputs:1, // set the number of inputs - only 0 or 1
outputs:1, // set the number of outputs - 0 to n
icon: "arrow-in.png", // set the icon (held in public/icons)
label: function() { // sets the default label contents
if (this.pauseType == "delay") {
- return this.name||"delay "+this.timeout+" s";
+ var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
+ return this.name||"delay "+this.timeout+" " + units;
} else if (this.pauseType == "rate") {
- return this.name||"limit "+this.rate+" msg/s";
+ var units = this.rateUnits ? this.rateUnits.charAt(0) : "s";
+ return this.name||"limit "+this.rate+" msg/"+ units;
}
return "foo";
},
@@ -82,6 +101,12 @@
$("#rate-details").show();
}
+ if (!this.timeoutUnits) {
+ $("#node-input-timeoutUnits option").filter(function() {
+ return $(this).val() == 'seconds';
+ }).attr('selected', true);
+ }
+
$("#node-input-pauseType").on("change",function() {
if (this.value == "delay") {
$("#delay-details").show();
diff --git a/nodes/core/89-delay.js b/nodes/core/89-delay.js
index b4ec3fcbe..e2f819e5a 100644
--- a/nodes/core/89-delay.js
+++ b/nodes/core/89-delay.js
@@ -24,8 +24,34 @@ function DelayNode(n) {
RED.nodes.createNode(this,n);
this.pauseType = n.pauseType;
- this.timeout = n.timeout * 1000;
- this.rate = 1000/n.rate;
+ this.timeoutUnits = n.timeoutUnits;
+ this.rateUnits = n.rateUnits;
+
+ if (n.timeoutUnits == "milliseconds") {
+ this.timeout = n.timout;
+ } else if (n.timeoutUnits == "seconds") {
+ this.timeout = n.timeout * 1000;
+ } else if (n.timeoutUnits == "minutes") {
+ this.timeout = n.timeout * (60 * 1000);
+ } else if (n.timeoutUnits == "hours") {
+ this.timeout = n.timeout * (60 * 60 * 1000);
+ } else if (n.timeoutUnits == "days") {
+ this.timeout = n.timeout * (24 * 60 * 60 * 1000);
+ }
+
+ if (n.rateUnits == "second") {
+ this.rate = 1000/n.rate;
+ } else if (n.rateUnits == "minute") {
+ this.rate = (60 * 1000)/n.rate;
+ } else if (n.rateUnits == "hour") {
+ this.rate = (60 * 60 * 1000)/n.rate;
+ } else if (n.rateUnits == "day") {
+ this.rate = (24 * 60 * 60 * 1000)/n.rate;
+ }
+
+ console.log(this.timeoutUnits + " - " + n.timeout + " = " + this.timeout);
+ console.log(this.rateUnits + " - " + n.rate + " = " + this.rate);
+
this.name = n.name;
this.idList = [];
this.buffer = [];