mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
80 lines
3.5 KiB
HTML
80 lines
3.5 KiB
HTML
|
|
<script type="text/x-red" data-template-name="html">
|
|
<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="html.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="html.label.output"></span></label>
|
|
<select id="node-input-ret" style="width:70%">
|
|
<option value="html" data-i18n="html.output.html"></option>
|
|
<option value="text" data-i18n="html.output.text"></option>
|
|
<option value="attr" data-i18n="html.output.attr"></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="html.format.single"></option>
|
|
<option value="multi" data-i18n="html.format.multi"></option>
|
|
</select>
|
|
</div>
|
|
<br/>
|
|
<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" style="width:70%" data-i18n="[placeholder]common.label.name">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="html">
|
|
<p>Extracts elements from an html document held in <code>msg.payload</code> using a CSS selector.</p>
|
|
<h3>Inputs</h3>
|
|
<dl class="message-properties">
|
|
<dt>payload <span class="property-type">string</span></dt>
|
|
<dd>the html string from which to extract elements.</dd>
|
|
<dt class="optional">select <span class="property-type">string</span></dt>
|
|
<dd>if not configured in the edit panel the selector can be set as a property of msg.</dd>
|
|
</dl>
|
|
<h3>Output</h3>
|
|
<dl class="message-properties">
|
|
<dt>payload <span class="property-type">array | string</span></dt>
|
|
<dd>the result can be either a single message with a payload containing an array of the matched elements, or multiple
|
|
messages that each contain a matched element. If multiple messages are sent they will also have <code>parts</code> set.</dd>
|
|
</dl>
|
|
<h3>Details</h3>
|
|
<p>This node supports a combination of CSS and jQuery selectors. See the
|
|
<a href="https://github.com/fb55/CSSselect#user-content-supported-selectors" target="_blank">css-select documentation</a> for more information
|
|
on the supported syntax.</p>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('html',{
|
|
category: 'function',
|
|
color:"#DEBD5C",
|
|
defaults: {
|
|
name: {value:""},
|
|
property: {value:"payload"},
|
|
tag: {value:""},
|
|
ret: {value:"html"},
|
|
as: {value:"single"}
|
|
},
|
|
inputs:1,
|
|
outputs:1,
|
|
icon: "parser-html.png",
|
|
label: function() {
|
|
return this.name||this.tag||"html";
|
|
},
|
|
labelStyle: function() {
|
|
return this.name?"node_label_italic":"";
|
|
},
|
|
oneditprepare: function() {
|
|
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
|
}
|
|
});
|
|
</script>
|