mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix Delay node milliseconds label to read ms.
(and add use strict)
This commit is contained in:
parent
dcc0adf2f7
commit
b67e70e09f
@ -54,7 +54,7 @@
|
||||
<div id="random-details" class="form-row">
|
||||
<label for="node-input-randomFirst"><i class="icon-time"></i> Between</label>
|
||||
<input type="text" id="node-input-randomFirst" placeholder="" style="directon:rtl; width:30px !important">
|
||||
<label for="node-input-randomLast" style="width:20px"> & </label>
|
||||
<label for="node-input-randomLast" style="width:20px"> & </label>
|
||||
<input type="text" id="node-input-randomLast" placeholder="" style="directon:rtl; width:30px !important">
|
||||
<select id="node-input-randomUnits" style="width:140px !important">
|
||||
<option value="milliseconds">Milliseconds</option>
|
||||
@ -101,6 +101,7 @@
|
||||
label: function() { // sets the default label contents
|
||||
if (this.pauseType == "delay") {
|
||||
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
||||
if (this.timeoutUnits == "milliseconds") { units = "ms"; }
|
||||
return this.name||"delay "+this.timeout+" " + units;
|
||||
} else if (this.pauseType == "rate") {
|
||||
var units = this.rateUnits ? this.rateUnits.charAt(0) : "s";
|
||||
@ -129,7 +130,7 @@
|
||||
$("#rate-details").show();
|
||||
$("#random-details").hide();
|
||||
} else if (this.pauseType == "random") {
|
||||
$("#delay-details").hide();
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").show();
|
||||
}
|
||||
@ -141,7 +142,7 @@
|
||||
}
|
||||
|
||||
if (!this.randomUnits) {
|
||||
$("#node-input-randomUnits option").filter(function() {
|
||||
$("#node-input-randomUnits option").filter(function() {
|
||||
return $(this).val() == 'seconds';
|
||||
}).attr('selected', true);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
//Simple node to introduce a pause into a flow
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
function random(n) {
|
||||
var wait = n.randomFirst + (n.diff * Math.random());
|
||||
if (n.buffer.length > 0) {
|
||||
@ -105,6 +106,9 @@ module.exports = function(RED) {
|
||||
if (!node.drop) {
|
||||
if ( node.intervalID !== -1) {
|
||||
node.buffer.push(msg);
|
||||
if (node.buffer.length > 0) {
|
||||
node.status({text:node.buffer.length});
|
||||
}
|
||||
if (node.buffer.length > 1000) {
|
||||
node.warn(this.name + " buffer exceeded 1000 messages");
|
||||
}
|
||||
@ -114,10 +118,12 @@ module.exports = function(RED) {
|
||||
if (node.buffer.length === 0) {
|
||||
clearInterval(node.intervalID);
|
||||
node.intervalID = -1;
|
||||
node.status({text:""});
|
||||
}
|
||||
|
||||
if (node.buffer.length > 0) {
|
||||
node.send(node.buffer.shift());
|
||||
node.status({text:node.buffer.length});
|
||||
}
|
||||
},node.rate);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user