mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
add output property select to HTML parse node (#1701)
This commit is contained in:
committed by
Nick O'Leary
parent
e8a637498d
commit
3190de873e
@@ -2,7 +2,7 @@
|
||||
<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%;"/>
|
||||
<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>
|
||||
@@ -24,6 +24,10 @@
|
||||
<option value="multi" data-i18n="html.format.multi"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-outproperty"> </label>
|
||||
<span data-i18n="html.label.in" style="padding-left:8px; padding-right:2px; vertical-align:-1px;"></span> <input type="text" id="node-input-outproperty" style="width:64%">
|
||||
</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>
|
||||
@@ -59,6 +63,7 @@
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
property: {value:"payload"},
|
||||
outproperty: {value:"payload"},
|
||||
tag: {value:""},
|
||||
ret: {value:"html"},
|
||||
as: {value:"single"}
|
||||
@@ -74,6 +79,7 @@
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
||||
$("#node-input-outproperty").typedInput({default:'msg',types:['msg']});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@@ -21,6 +21,7 @@ module.exports = function(RED) {
|
||||
function CheerioNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.property = n.property||"payload";
|
||||
this.outproperty = n.outproperty||this.property||"payload";
|
||||
this.tag = n.tag;
|
||||
this.ret = n.ret || "html";
|
||||
this.as = n.as || "single";
|
||||
@@ -48,7 +49,7 @@ module.exports = function(RED) {
|
||||
/* istanbul ignore else */
|
||||
if (pay2) {
|
||||
var new_msg = RED.util.cloneMessage(msg);
|
||||
RED.util.setMessageProperty(new_msg,node.property,pay2);
|
||||
RED.util.setMessageProperty(new_msg,node.outproperty,pay2);
|
||||
new_msg.parts = {
|
||||
id: msg._msgid,
|
||||
index: index,
|
||||
@@ -68,7 +69,7 @@ module.exports = function(RED) {
|
||||
index++;
|
||||
});
|
||||
if (node.as === "single") { // Always return an array - even if blank
|
||||
RED.util.setMessageProperty(msg,node.property,pay);
|
||||
RED.util.setMessageProperty(msg,node.outproperty,pay);
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user