2014-10-27 21:26:49 +01:00
|
|
|
|
|
|
|
<script type="text/x-red" data-template-name="random">
|
2018-01-30 22:42:14 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
|
|
|
|
<input type="text" id="node-input-property" style="width:70%;"/>
|
|
|
|
</div>
|
2014-10-27 21:26:49 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-inte"><i class="fa fa-random"></i> Generate</label>
|
2018-01-30 22:42:14 +01:00
|
|
|
<select type="text" id="node-input-inte" style="width:70%;">
|
2014-10-27 21:26:49 +01:00
|
|
|
<option value="true">a whole number - integer</option>
|
|
|
|
<option value="false">a real number - floating point</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-low"><i class="fa fa-arrow-down"></i> From</label>
|
2018-01-30 22:42:14 +01:00
|
|
|
<input type="text" id="node-input-low" placeholder="lowest number" style="width:70%;">
|
2014-10-27 21:26:49 +01:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-high"><i class="fa fa-arrow-up"></i> To</label>
|
2018-01-30 22:42:14 +01:00
|
|
|
<input type="text" id="node-input-high" placeholder="highest number" style="width:70%;">
|
2014-10-27 21:26:49 +01:00
|
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
2018-01-30 22:42:14 +01:00
|
|
|
<input type="text" id="node-input-name" placeholder="Name" style="width:70%;">
|
2014-10-27 21:26:49 +01:00
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="random">
|
|
|
|
<p>Generates a random number between a low and high value.</p>
|
2018-09-24 20:40:33 +02:00
|
|
|
<p>If you return an integer it can <i>include</i> both the low and high values.
|
|
|
|
<code>min <= n <= max</code></p>
|
|
|
|
<p>If you return a floating point value it will be from the low value, up to, but
|
|
|
|
not including the high value. <code>min <= n < max</code></p>
|
2014-10-27 21:26:49 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('random',{
|
|
|
|
category: 'function',
|
|
|
|
color:"#E2D96E",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
|
|
|
low: {value:"1"},
|
2016-12-27 22:25:57 +01:00
|
|
|
high: {value:"10"},
|
2018-01-30 22:42:14 +01:00
|
|
|
inte: {value:"true"},
|
|
|
|
property: {value:"payload",required:true}
|
2014-10-27 21:26:49 +01:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
|
|
|
icon: "debug.png",
|
|
|
|
label: function() {
|
|
|
|
return this.name||"random";
|
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
2018-01-30 22:42:14 +01:00
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
if (this.property === undefined) {
|
|
|
|
$("#node-input-property").val("payload");
|
|
|
|
}
|
|
|
|
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
2014-10-27 21:26:49 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|