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