node-red-contrib-afya-panic-button
Version:
the node reports PANIC or any fixed value when it is called Y times in X seconds
86 lines (79 loc) • 3.25 kB
HTML
<!-- /**
* PanicButton by Marcin Chuć
* e-mail: marcin ...change it to at... afya.pl
* (C) 2019
*/ -->
<script type="text/javascript">
Math.seed = Date.now();
RED.nodes.registerType('afya-panic-button', {
category: 'function',
color: '#FA42B2',
paletteLabel: 'panic button',
defaults: {
name: {
value: ""
},
variableName: {
value: "AFYA_" + Math.random().toString(36).substr(2, 5) + Date.now().toString().substr(-3),
required: true,
},
timeToClick: {
value: 10,
required: true,
validate: RED.validators.number()
},
howManyTimesToClick: {
value: 5,
required: true,
validate: RED.validators.number()
},
answerPanic: {
value: "panic",
required: true
},
answerDontPanic: {
value: "dont_panic",
required: true
},
},
inputs: 1,
outputs: 1,
icon: "alarm-light.png",
label: function() {
return this.name || this.answerPanic + " after " + this.howManyTimesToClick + " times in " + this.timeToClick + " s";
}
});
</script>
<script type="text/x-red" data-template-name="afya-panic-button">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-variableName"><i class="icon-bookmark"></i> Variable name</label>
<input type="text" id="node-input-variableName" placeholder="Your_Unique_Variable_Name">
</div>
<div class="form-row">
<label for="node-config-input-timeToClick"><i class="icon-clock"></i> Time to click/execute in seconds</label>
<input type="text" id="node-input-timeToClick">
</div>
<div class="form-row">
<label for="node-config-input-howManyTimesToClick"><i class="icon-calculator"></i> How many times to 'click'</label>
<input type="text" id="node-input-howManyTimesToClick">
</div>
<div class="form-row">
<label for="node-config-input-answerPanic"><i class="icon-bookmark"></i> Answer if panic</label>
<input type="text" id="node-input-answerPanic">
</div>
<div class="form-row">
<label for="node-config-input-answerDontPanic"><i class="icon-bookmark"></i> Answer if don't panic</label>
<input type="text" id="node-input-answerDontPanic">
</div>
</script>
<script type="text/x-red" data-help-name="afya-panic-button">
<p>A simple node that reports "panic" or any fixed value when it is called Y times in X seconds<br>
<b>
Please pay special attention to the 'variable name' because it is not created completely randomly (and should be for each node added), unless many nodes are to support 1 variable in the same flow.</b></p>
<p>Prosty węzeł który zgłasza "panic" lub dowolną ustaloną wartość kiedy w czasie X sekund zostanie wywołany Y razy<br>
<b>Proszę zwrócić szczególną uwagę na 'Variable name', gdyż nie tworzy się ona zupełnie randomowo (a powinna dla każdego dodanego węzła), chyba, że wiele węzłów ma obsługiwać 1 zmienną w tym samym flow.</b></p>
</script>