|
6 | 6 | </script> |
7 | 7 |
|
8 | 8 | <script type="text/x-red" data-help-name="{{&nodeName}}"> |
9 | | - <p>A JavaScript function block to run against the messages being received by the node.</p> |
10 | | - <p>The messages are passed in as a JavaScript object called <code>msg</code>.</p> |
11 | | - <p>By convention it will have a <code>msg.payload</code> property containing |
12 | | - the body of the message.</p> |
13 | | - <p>The function is expected to return a message object (or multiple message objects), but can choose |
14 | | - to return nothing in order to halt a flow.</p> |
| 9 | + <p>Summary of the node.</p> |
| 10 | + <h3>Inputs</h3> |
| 11 | + <dl class="message-properties"> |
| 12 | + <dt>payload<span class="property-type">object</span></dt> |
| 13 | + <dd>Explanation of payload.</dd> |
| 14 | + <dt class="optional">topic <span class="property-type">string</span></dt> |
| 15 | + <dd>Explanation of topic.</dd> |
| 16 | + </dl> |
| 17 | + <h3>Outputs</h3> |
| 18 | + <dl class="message-properties"> |
| 19 | + <dt>payload<span class="property-type">object</span></dt> |
| 20 | + <dd>Explanation of payload.</dd> |
| 21 | + <dt class="optional">topic<span class="property-type">string</span></dt> |
| 22 | + <dd>Explanation of topic.</dd> |
| 23 | + </dl> |
15 | 24 | <h3>Details</h3> |
16 | | - <p>See the <a target="_blank" href="http://nodered.org/docs/writing-functions.html">online documentation</a> |
17 | | - for more information on writing functions.</p> |
18 | | - <h4>Sending messages</h4> |
19 | | - <p>The function can either return the messages it wants to pass on to the next nodes |
20 | | - in the flow, or can call <code>node.send(messages)</code>.</p> |
21 | | - <p>It can return/send:</p> |
22 | | - <ul> |
23 | | - <li>a single message object - passed to nodes connected to the first output</li> |
24 | | - <li>an array of message objects - passed to nodes connected to the corresponding outputs</li> |
25 | | - </ul> |
26 | | - <p>If any element of the array is itself an array of messages, multiple |
27 | | - messages are sent to the corresponding output.</p> |
28 | | - <p>If null is returned, either by itself or as an element of the array, no |
29 | | - message is passed on.</p> |
30 | | - <h4>Logging and Error Handling</h4> |
31 | | - <p>To log any information, or report an error, the following functions are available:</p> |
32 | | - <ul> |
33 | | - <li><code>node.log("Log message")</code></li> |
34 | | - <li><code>node.warn("Warning")</code></li> |
35 | | - <li><code>node.error("Error")</code></li> |
36 | | - </ul> |
37 | | - </p> |
38 | | - <p>The Catch node can also be used to handle errors. To invoke a Catch node, |
39 | | - pass <code>msg</code> as a second argument to <code>node.error</code>:</p> |
40 | | - <pre>node.error("Error",msg);</pre> |
| 25 | + <p>Explanation of the details.</p> |
| 26 | + <p><b>Note</b>: Note of the node.</p> |
41 | 27 | </script> |
42 | 28 |
|
43 | 29 | <script type="text/javascript"> |
|
46 | 32 | category: '{{&category}}', |
47 | 33 | defaults: { |
48 | 34 | name: {value:""}, |
49 | | - func: {value:"\nreturn msg;"}, |
50 | | - noerr: {value:0,required:true,validate:function(v) { return ((!v) || (v === 0)) ? true : false; }} |
51 | 35 | }, |
52 | 36 | inputs:1, |
53 | 37 | outputs: {{&outputs}}, |
54 | 38 | icon: "icon.png", |
55 | 39 | label: function() { |
56 | 40 | return this.name || '{{&nodeName}}'; |
57 | | - }, |
58 | | - oneditprepare: function() { |
59 | | - var that = this; |
60 | | -
|
61 | | - this.editor = RED.editor.createEditor({ |
62 | | - id: 'node-input-func-editor', |
63 | | - mode: 'ace/mode/javascript', |
64 | | - value: $("#node-input-func").val(), |
65 | | - globals: { |
66 | | - msg:true, |
67 | | - context:true, |
68 | | - RED: true, |
69 | | - util: true, |
70 | | - flow: true, |
71 | | - global: true, |
72 | | - console: true, |
73 | | - Buffer: true, |
74 | | - setTimeout: true, |
75 | | - clearTimeout: true, |
76 | | - setInterval: true, |
77 | | - clearInterval: true |
78 | | - } |
79 | | - }); |
80 | | -
|
81 | | - this.editor.focus(); |
82 | | - }, |
83 | | - oneditsave: function() { |
84 | | - var annot = this.editor.getSession().getAnnotations(); |
85 | | - this.noerr = 0; |
86 | | - $("#node-input-noerr").val(0); |
87 | | - for (var k=0; k < annot.length; k++) { |
88 | | - //console.log(annot[k].type,":",annot[k].text, "on line", annot[k].row); |
89 | | - if (annot[k].type === "error") { |
90 | | - $("#node-input-noerr").val(annot.length); |
91 | | - this.noerr = annot.length; |
92 | | - } |
93 | | - } |
94 | | - $("#node-input-func").val(this.editor.getValue()); |
95 | | - this.editor.destroy(); |
96 | | - delete this.editor; |
97 | | - }, |
98 | | - oneditcancel: function() { |
99 | | - this.editor.destroy(); |
100 | | - delete this.editor; |
101 | | - }, |
102 | | - oneditresize: function(size) { |
103 | | - var rows = $("#dialog-form>div:not(.node-text-editor-row)"); |
104 | | - var height = $("#dialog-form").height(); |
105 | | - for (var i=0; i<rows.size(); i++) { |
106 | | - height -= $(rows[i]).outerHeight(true); |
107 | | - } |
108 | | - var editorRow = $("#dialog-form>div.node-text-editor-row"); |
109 | | - height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))); |
110 | | - $(".node-text-editor").css("height",height+"px"); |
111 | | - this.editor.resize(); |
112 | 41 | } |
113 | 42 | }); |
114 | 43 | </script> |
0 commit comments