/
html2.html
89 lines (82 loc) · 3.71 KB
/
html2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<script type="text/html" data-template-name="html2">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" style="width:70%" data-i18n="[placeholder]node-red:common.label.name">
</div>
<br/>
<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>
<div class="form-row">
<label for="node-input-tag"><i class="fa fa-filter"></i> <span data-i18n="html2.label.select"></span></label>
<input type="text" id="node-input-tag" placeholder="h1">
</div>
<div class="form-row">
<label for="node-input-ret"><i class="fa fa-sign-out"></i> <span data-i18n="html2.label.output"></span></label>
<select id="node-input-ret" style="width:70%">
<option value="html" data-i18n="html2.output.html"></option>
<option value="text" data-i18n="html2.output.text"></option>
<option value="attr" data-i18n="html2.output.attr"></option>
<option value="compl" data-i18n="html2.output.compl"></option>
<!-- <option value="val">return the value from a form element</option> -->
</select>
</div>
<div class="form-row">
<label for="node-input-as"> </label>
<select id="node-input-as" style="width:70%">
<option value="single" data-i18n="html2.format.single"></option>
<option value="multi" data-i18n="html2.format.multi"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-outproperty"> </label>
<span data-i18n="html2.label.in" style="padding-left:8px; padding-right:2px; vertical-align:-1px;"></span>
<input type="text" id="node-input-outproperty" style="width:64%">
</div>
<div id='html-prefix-row' class="form-row" style="display: none;">
<label for="node-input-chr" style="width: 230px;"><i class="fa fa-tag"></i> <span data-i18n="html2.label.prefix"></span></label>
<input type="text" id="node-input-chr" style="text-align:center; width: 40px;" placeholder="_">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('html2',{
category: 'parser',
color:"#DEBD5C",
defaults: {
name: {value:""},
property: {value:"payload", required: true },
outproperty: {value:"payload", required: true },
tag: {value:""},
ret: {value:"html"},
as: {value:"single"},
chr: { value: "_" }
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-code",
label: function() {
return this.name||this.tag||"html2";
},
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']});
if (this.outproperty === undefined) {
$("#node-input-outproperty").val("payload");
}
$("#node-input-outproperty").typedInput({default:'msg',types:['msg']});
$('#node-input-ret').on( 'change', () => {
if ( $('#node-input-ret').val() == "compl" ) {
$('#html-prefix-row').show()
} else {
$('#html-prefix-row').hide()
}
});
}
});
</script>