2014-04-29 18:01:30 +02:00
|
|
|
|
2020-01-15 03:40:48 +01:00
|
|
|
<script type="text/html" data-template-name="json">
|
2017-05-23 10:35:37 +02:00
|
|
|
<div class="form-row">
|
2018-01-26 08:31:48 +01:00
|
|
|
<label for="node-input-action"><i class="fa fa-dot-circle-o"></i> <span data-i18n="json.label.action"></span></label>
|
2018-01-15 00:19:01 +01:00
|
|
|
<select style="width:70%" id="node-input-action">
|
|
|
|
<option value="" data-i18n="json.label.actions.toggle"></option>
|
|
|
|
<option value="str" data-i18n="json.label.actions.str"></option>
|
|
|
|
<option value="obj" data-i18n="json.label.actions.obj"></option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2018-01-26 08:31:48 +01:00
|
|
|
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="json.label.property"></span></label>
|
2018-01-16 11:59:44 +01:00
|
|
|
<input type="text" id="node-input-property" style="width:70%;"/>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
2018-01-15 00:19:01 +01:00
|
|
|
</div>
|
|
|
|
<hr align="middle"/>
|
|
|
|
<div class="form-row node-json-to-json-options">
|
2019-05-23 17:39:56 +02:00
|
|
|
<label style="width:100%;"><span data-i18n="json.label.o2j"></span></label>
|
2017-05-23 15:18:09 +02:00
|
|
|
</div>
|
2018-01-15 00:19:01 +01:00
|
|
|
<div class="form-row node-json-to-json-options" style="padding-left: 20px;">
|
2022-02-26 11:10:17 +01:00
|
|
|
<input style="width:20px; vertical-align:top; margin-right: 5px;" type="checkbox" id="node-input-pretty"><label style="width: auto;" for="node-input-pretty" data-i18n="json.label.pretty"></label>
|
2017-05-23 10:35:37 +02:00
|
|
|
</div>
|
2014-04-29 18:01:30 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('json',{
|
2019-06-19 15:31:03 +02:00
|
|
|
category: 'parser',
|
2014-04-29 18:01:30 +02:00
|
|
|
color:"#DEBD5C",
|
|
|
|
defaults: {
|
2017-05-23 10:35:37 +02:00
|
|
|
name: {value:""},
|
2022-02-14 02:40:49 +01:00
|
|
|
property: {value:"payload",required:true,
|
|
|
|
label:RED._("node-red:json.label.property")},
|
2018-01-16 11:59:44 +01:00
|
|
|
action: {value:""},
|
2017-07-04 14:44:37 +02:00
|
|
|
pretty: {value:false}
|
2014-04-29 18:01:30 +02:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2019-06-21 13:36:20 +02:00
|
|
|
icon: "parser-json.svg",
|
2014-04-29 18:01:30 +02:00
|
|
|
label: function() {
|
|
|
|
return this.name||"json";
|
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
2018-01-15 00:19:01 +01:00
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
if (this.property === undefined) {
|
|
|
|
$("#node-input-property").val("payload");
|
|
|
|
}
|
|
|
|
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
2019-04-29 12:50:15 +02:00
|
|
|
$("#node-input-action").on("change", function() {
|
2018-01-15 00:19:01 +01:00
|
|
|
if (this.value === "" || this.value === "str") {
|
|
|
|
$(".node-json-to-json-options").show();
|
|
|
|
} else {
|
|
|
|
$(".node-json-to-json-options").hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#node-input-action").change();
|
2014-04-29 18:01:30 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|