|
88 | 88 | </script>
|
89 | 89 |
|
90 | 90 | <script type="text/x-red" data-template-name="cloudant out">
|
91 |
| - |
92 | 91 | <div class="form-row">
|
93 | 92 | <label for="node-input-service"><i class="fa fa-folder-close"></i> Service</label>
|
94 | 93 | <select id="node-input-service">
|
|
136 | 135 | else $(".node-input-payonly").show();
|
137 | 136 | });
|
138 | 137 | </script>
|
| 138 | +</script> |
139 | 139 |
|
| 140 | +<script type="text/javascript"> |
| 141 | + RED.nodes.registerType("cloudant out", { |
| 142 | + category: "storage-output", |
| 143 | + color: "rgb(114, 199, 231)", |
| 144 | + defaults: { |
| 145 | + service: { value: "", required: true }, |
| 146 | + cloudant: { type: "cloudant", validate: validateServer}, |
| 147 | + name: { value: "" }, |
| 148 | + database: { value: "", required: true }, |
| 149 | + payonly: { value: false }, |
| 150 | + operation: { value: "insert" } |
| 151 | + }, |
| 152 | + inputs: 1, |
| 153 | + outputs: 0, |
| 154 | + icon: "cloudant.png", |
| 155 | + align: "right", |
| 156 | + label: label, |
| 157 | + labelStyle: function() { |
| 158 | + return this.name?"node_label_italic":""; |
| 159 | + }, |
| 160 | + oneditprepare: oneditprepare |
| 161 | + }); |
| 162 | + |
| 163 | + function oneditprepare() { |
| 164 | + var select = $('#node-input-service'); |
| 165 | + var node = this; |
| 166 | + |
| 167 | + $.getJSON('cloudant/vcap/',function(data) { |
| 168 | + var last = select.children().last(); |
| 169 | + var opts = []; |
| 170 | + |
| 171 | + for (var i=0; i < data.length; i++) { |
| 172 | + var selected = node.service == data[i].name; |
| 173 | + opts.push( |
| 174 | + '<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + |
| 175 | + data[i].name + |
| 176 | + '</option>' |
| 177 | + ); |
| 178 | + } |
| 179 | + |
| 180 | + if (opts.length == 0) { |
| 181 | + node.service = "_ext_"; |
| 182 | + select.find("option").filter(function() { |
| 183 | + return $(this).val() == node.service; |
| 184 | + }).attr('selected', true); |
| 185 | + } else { |
| 186 | + last.before(opts.join("")); |
| 187 | + } |
| 188 | + |
| 189 | + select.change(); |
| 190 | + }); |
| 191 | + |
| 192 | + select.change(function() { |
| 193 | + var service = select.val(); |
| 194 | + if (service == "_ext_") { |
| 195 | + $("#node-input-external-details").show(); |
| 196 | + } else { |
| 197 | + $("#node-input-external-details").hide(); |
| 198 | + } |
| 199 | + }); |
| 200 | + } |
| 201 | + |
| 202 | + function label() { |
| 203 | + return this.name || this.database || "cloudant"; |
| 204 | + } |
| 205 | + |
| 206 | + function validateServer(v) { |
| 207 | + return this.service != "_ext_" || v != "_ADD_"; |
| 208 | + } |
140 | 209 | </script>
|
141 | 210 |
|
142 | 211 | <script type="text/x-red" data-help-name="cloudant out">
|
|
159 | 228 | and selecting the <b>remove</b> option for the node.
|
160 | 229 | </p>
|
161 | 230 | </script>
|
162 |
| - |
163 |
| -<script type="text/javascript"> //js functions |
164 |
| - (function() { |
165 |
| - |
166 |
| - function oneditprepare() { |
167 |
| - var select = $('#node-input-service'); |
168 |
| - var node = this; |
169 |
| - |
170 |
| - $.getJSON('cloudant/vcap/',function(data) { |
171 |
| - var last = select.children().last(); |
172 |
| - var opts = []; |
173 |
| - |
174 |
| - for (var i=0; i < data.length; i++) { |
175 |
| - var selected = node.service == data[i].name; |
176 |
| - opts.push( |
177 |
| - '<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + |
178 |
| - data[i].name + |
179 |
| - '</option>' |
180 |
| - ); |
181 |
| - } |
182 |
| - |
183 |
| - if (opts.length == 0) { |
184 |
| - node.service = "_ext_"; |
185 |
| - select.find("option").filter(function() { |
186 |
| - return $(this).val() == node.service; |
187 |
| - }).attr('selected', true); |
188 |
| - } else { |
189 |
| - last.before(opts.join("")); |
190 |
| - } |
191 |
| - |
192 |
| - select.change(); |
193 |
| - }); |
194 |
| - |
195 |
| - select.change(function() { |
196 |
| - var service = select.val(); |
197 |
| - if (service == "_ext_") { |
198 |
| - $("#node-input-external-details").show(); |
199 |
| - } else { |
200 |
| - $("#node-input-external-details").hide(); |
201 |
| - } |
202 |
| - }); |
203 |
| - } |
204 |
| - |
205 |
| - function label() { |
206 |
| - return this.name || this.database || "cloudant"; |
207 |
| - } |
208 |
| - |
209 |
| - function validateServer(v) { |
210 |
| - return this.service != "_ext_" || v != "_ADD_"; |
211 |
| - } |
212 |
| - |
213 |
| - RED.nodes.registerType("cloudant out", { |
214 |
| - category: "storage-output", |
215 |
| - color: "rgb(114, 199, 231)", |
216 |
| - defaults: { |
217 |
| - service: { value: "", required: true }, |
218 |
| - cloudant: { type: "cloudant", validate: validateServer}, |
219 |
| - name: { value: "" }, |
220 |
| - database: { value: "", required: true }, |
221 |
| - payonly: { value: false }, |
222 |
| - operation: { value: "insert" } |
223 |
| - }, |
224 |
| - inputs: 1, |
225 |
| - outputs: 0, |
226 |
| - icon: "cloudant.png", |
227 |
| - align: "right", |
228 |
| - label: label, |
229 |
| - labelStyle: function() { |
230 |
| - return this.name?"node_label_italic":""; |
231 |
| - }, |
232 |
| - oneditprepare: oneditprepare |
233 |
| - }); |
234 |
| - })(); |
235 |
| -</script> |
0 commit comments