mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
64 lines
2.7 KiB
HTML
64 lines
2.7 KiB
HTML
|
|
<script type="text/html" data-template-name="json">
|
|
<div class="form-row">
|
|
<label for="node-input-action"><i class="fa fa-dot-circle-o"></i> <span data-i18n="json.label.action"></span></label>
|
|
<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">
|
|
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="json.label.property"></span></label>
|
|
<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">
|
|
</div>
|
|
<hr align="middle"/>
|
|
<div class="form-row node-json-to-json-options">
|
|
<label style="width:100%;"><span data-i18n="json.label.o2j"></span></label>
|
|
</div>
|
|
<div class="form-row node-json-to-json-options" style="padding-left: 20px;">
|
|
<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>
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('json',{
|
|
category: 'parser',
|
|
color:"#DEBD5C",
|
|
defaults: {
|
|
name: {value:""},
|
|
property: {value:"payload",required:true,
|
|
label:RED._("node-red:json.label.property")},
|
|
action: {value:""},
|
|
pretty: {value:false}
|
|
},
|
|
inputs:1,
|
|
outputs:1,
|
|
icon: "parser-json.svg",
|
|
label: function() {
|
|
return this.name||"json";
|
|
},
|
|
labelStyle: function() {
|
|
return this.name?"node_label_italic":"";
|
|
},
|
|
oneditprepare: function() {
|
|
if (this.property === undefined) {
|
|
$("#node-input-property").val("payload");
|
|
}
|
|
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
|
$("#node-input-action").on("change", function() {
|
|
if (this.value === "" || this.value === "str") {
|
|
$(".node-json-to-json-options").show();
|
|
} else {
|
|
$(".node-json-to-json-options").hide();
|
|
}
|
|
});
|
|
$("#node-input-action").change();
|
|
}
|
|
});
|
|
</script>
|