node-red-contrib-boolean-logic-ultimate
Version:
A set of Node-RED enhanced boolean logic and utility nodes, flow interruption, blinker, invert, filter, toggle etc.., with persistent values after reboot. Compatible also with Homeassistant values.
133 lines (118 loc) • 5.16 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('InjectUltimate', {
category: 'common',
color: '#ff8080',
defaults: {
name: {
value: "Inject",
},
topic: {
value: "1",
},
curVal: {
value: true,
},
outputJSON: { value: '{ \n\t"payload":"hello",\n\t"topic":"1"\n}' },
},
inputs: 0,
outputs: 4,
outputLabels: ["True", "False", "Toggle", "JSON"],
icon: "inject.svg",
button: {
onclick: function () {
// Called when the button is clicked
if (this.changed) {
return RED.notify(RED._("notification.warning", { message: RED._("notification.warnings.undeployedChanges") }), "warning");
}
var node = this;
$.ajax({
url: "InjectUltimate/" + this.id,
type: "POST",
success: function (resp) {
RED.notify(node._("inject.success", { label: label }), { type: "success", id: "inject" });
},
error: function (jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 404) {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.not-deployed") }), "error");
} else if (jqXHR.status == 500) {
RED.notify(node._("common.notification.error", { message: node._("inject.errors.failed") }), "error");
} else if (jqXHR.status == 0) {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.no-response") }), "error");
} else {
RED.notify(node._("common.notification.error", { message: node._("common.notification.errors.unexpected", { status: jqXHR.status, message: textStatus }) }), "error");
}
}
});
},
enabled: function () {
return !this.changed
}
},
label:
function () {
return this.name + " " + this.topic;
},
oneditprepare: function () {
var node = this;
if (node.outputJSON === undefined || node.outputJSON === '') node.outputJSON = '{ \n\t"payload":"hello",\n\t"topic":"1"\n}';
node.editor = RED.editor.createEditor({
id: 'node-input-editoroutputJSON',
mode: 'ace/mode/json',
value: node.outputJSON
});
if ($("#node-input-payloadPropName").val() === "") $("#node-input-payloadPropName").val("payload");
},
oneditsave: function () {
var node = this;
node.outputJSON = node.editor.getValue();
node.editor.destroy();
delete node.editor;
},
oneditcancel: function () {
var node = this;
node.editor.destroy();
delete node.editor;
},
paletteLabel: function () {
return "Inject";
}
});
</script>
<script type="text/html" data-template-name="InjectUltimate">
<div class="form-row">
<b>Inject Ultimate</b>    <span style="color:red"><i class="fa fa-question-circle"></i> <a target="_blank" href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate"><u>Help online</u></a></span>
   <span style="color:red"><i class="fa fa-youtube-play"></i> <a target="_blank" href="https://youtu.be/sYc6L5QQrTw"><u>Youtube Sample</u></a></span>
<br/>
<br/>
</div>
<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-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row" >
<label style="width:300px;" for="node-input-outputJSON"><i class="fa fa-tasks"></i> JSON</label>
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-editoroutputJSON"></div>
</div>
</script>
<script type="text/markdown" data-help-name="InjectUltimate">
<p>The pourpose of this node is to send a msg to all output pins at once.</p>
**Configuration**
|Property|Description|
|--|--|
| Name | Node name.|
| Topic | The msg output topic. It can be overridden by the JSON field, but only in the output pin #4.|
| JSON | The pin #4 will output this JSON message.|
### Output
- pin1 : true
- pin2 : false
- pin3 : toggle
- pin4 : json object
<br/>
<br/>
[SEE THE README FOR FULL HELP AND SAMPLES](https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate)
[Find it useful?](https://www.paypal.me/techtoday)
</script>