|
36 | 36 | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
37 | 37 | <input type="text" id="node-input-name" placeholder="Name"> |
38 | 38 | </div> |
| 39 | + <div class="form-row" id="lang-group"> |
| 40 | + <label for="node-input-lang-label"><i class="fa fa-language"></i> Language</label> |
| 41 | + <select type="text" id="node-input-lang" style="display: inline-block; width: 70%;" > |
| 42 | + <option value="en">English</option> |
| 43 | + <option value="es">Spanish</option> |
| 44 | + <option value="ar">Arabic</option> |
| 45 | + <option value="ja">Japanese</option> |
| 46 | + </select> |
| 47 | + </div> |
39 | 48 | </script> |
40 | 49 |
|
41 | 50 | <script type="text/x-red" data-template-name="visual-recognition-util-v3"> |
|
84 | 93 | <li><code>msg.params["classifier_ids"]</code> : A comma-separated list of the classifier IDs used to classify the images. "Default" is the classifier_id of the built-in classifier. (string) (Optional)</li> |
85 | 94 | <li><code>msg.params["owners"]</code> : A comma-separated list with the value(s) "IBM" and/or "me" to specify which classifiers to run. (string) (Optional)</li> |
86 | 95 | <li><code>msg.params["threshold"]</code> : A floating value (in string format) that specifies the minimum score a class must have to be displayed in the response (Optional)</li> |
| 96 | + <li><code>msg.params["accept_language"]</code> : Specifies the language of the output class names. Can be 'en' (English as default), 'es' (Spanish), 'ar' (Arabic) or 'ja' (Japanese). Classes for which no translation is available are omitted. If specified, it overrides the language specified in the node configuration (Optional)</li> |
87 | 97 | </ul> |
88 | 98 | <p>More information on this <a href="http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/visual-recognition/api/v3/?curl#classify_an_image">API documentation</a>.</p> |
89 | 99 |
|
|
163 | 173 |
|
164 | 174 |
|
165 | 175 | <script type="text/javascript"> |
| 176 | + |
| 177 | +// Need to simulate a namespace, as some of the variables had started to leak across nodes |
| 178 | + function VISUALRECOGNITIONV3 () { |
| 179 | + var language_selected = ''; |
| 180 | + } |
| 181 | + |
| 182 | + // This is the namespace for visualrecognitionv3. Currently only contains models, but more vars and functions may need to be |
| 183 | + // moved in if there is a clash with other nodes. |
| 184 | + var visualrecognitionv3 = new VISUALRECOGNITIONV3(); |
| 185 | + |
| 186 | + // Save the values in the dynamic lists to the hidden fields. |
| 187 | + function oneditsave(){ |
| 188 | + visualrecognitionv3.language_selected = $('#node-input-lang').val(); |
| 189 | + } |
| 190 | + |
166 | 191 | (function() { |
167 | 192 | RED.nodes.registerType('visual-recognition-v3', { |
168 | 193 | category: 'IBM Watson', |
169 | 194 | defaults: { |
170 | 195 | name: {value: ""}, |
171 | 196 | apikey: {value: ""}, |
172 | | - "image-feature": {value: ""} |
| 197 | + "image-feature": {value: ""}, |
| 198 | + "lang": {value: ""}, |
173 | 199 | }, |
174 | 200 | credentials: { |
175 | 201 | apikey: {type:"password"} |
176 | 202 | }, |
177 | | - color: 'rgb(72, 232, 211)', |
| 203 | + color: 'rgb(228, 189, 255)', |
178 | 204 | inputs: 1, |
179 | 205 | outputs: 1, |
180 | | - icon: "VR-v3-25x25.png", |
181 | | - paletteLabel: "visual recognition v3", |
| 206 | + icon: "VR-v3-pink.png", |
| 207 | + paletteLabel: "visual recognition", |
182 | 208 | label: function() { |
183 | | - return this.name || "visual recognition v3"; |
| 209 | + return this.name || "visual recognition"; |
184 | 210 | }, |
185 | 211 | labelStyle: function() { |
186 | 212 | return this.name ? "node_label_italic" : ""; |
187 | 213 | }, |
188 | 214 | oneditprepare: function() { |
| 215 | + var node = this; |
189 | 216 | $.getJSON('watson-visual-recognition/vcap/') |
190 | 217 | .done(function (service) { |
191 | 218 | $('.credentials').toggle(!service); |
|
195 | 222 | }) |
196 | 223 | .always(function () { |
197 | 224 | $('#credentials-check').hide(); |
198 | | - }) |
199 | | - } |
200 | | - }); |
| 225 | + }); |
201 | 226 |
|
| 227 | + // update list of ruleset for the selected service when the service changes |
| 228 | + $('#node-input-image-feature').change(function() { |
| 229 | + var selectedFeature = $('#node-input-image-feature'); |
| 230 | + if (selectedFeature.val() == 'classifyImage') { |
| 231 | + $('#lang-group').show(); |
| 232 | + } |
| 233 | + else { |
| 234 | + $('#lang-group').hide(); |
| 235 | + } |
| 236 | + }); |
| 237 | + }, |
| 238 | + oneditsave: oneditsave |
| 239 | + }); |
202 | 240 |
|
203 | 241 |
|
204 | 242 | RED.nodes.registerType('visual-recognition-util-v3', { |
|
211 | 249 | credentials: { |
212 | 250 | apikey: {type:"password"} |
213 | 251 | }, |
214 | | - color: 'rgb(72, 232, 211)', |
| 252 | + color: 'rgb(228, 189, 255)', |
215 | 253 | inputs: 1, |
216 | 254 | outputs: 1, |
217 | | - icon: "VR-v3-25x25.png", |
218 | | - paletteLabel: "visual recognition util v3", |
| 255 | + icon: "VR-v3-pink.png", |
| 256 | + paletteLabel: "visual recognition util", |
219 | 257 | label: function() { |
220 | | - return this.name || "visual recognition util v3"; |
| 258 | + return this.name || "visual recognition util"; |
221 | 259 | }, |
222 | 260 | labelStyle: function() { |
223 | 261 | return this.name ? "node_label_italic" : ""; |
|
235 | 273 | }) |
236 | 274 | } |
237 | 275 | }); |
238 | | - |
239 | | - |
240 | 276 | })(); |
241 | 277 | </script> |
0 commit comments