UNPKG

node-red-node-watson

Version:
97 lines (86 loc) 3.77 kB
<!-- Copyright 2013,2022 IBM Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <script type="text/x-red" data-template-name="watson-language-translator-identify"> <div id="credentials-check" class="form-row"> <div class="form-tips"> <i class="fa fa-question-circle"></i><b> Please wait: </b> Checking for bound service credentials... </div> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row credentials" style="display: none;"> <label for="node-input-apikey"><i class="fa fa-key"></i> API Key</label> <input type="password" id="node-input-apikey" placeholder="API Key"></input> </div> <div class="form-row credentials"> <label for="node-input-cwm-service-endpoint"><i class="fa fa-tag"></i> Service Endpoint</label> <input type="text" id="node-input-service-endpoint" placeholder="https://gateway.watsonplatform.net/language-translator/api"> </div> </script> <script type="text/x-red" data-help-name="watson-language-translator-identify"> <p>Packaged in with release 0.7.0 of node-red-node-watson</p> <p>The Watson Language Translator service can be used to identify languages used in a text input. <p> <p>Node input : </p> <ul> <li><code>msg.payload</code> : The input text to identify language against in UTF-8 format</li> </ul> <p>Node output : </p> <ul> <li><code>msg.lang</code> : The identified language with the highest confidence level</li> <li><code>msg.languages</code> : array of identified languages with the language 5-letter ISO language code with the associated confidence score</li> </ul> <p>For more information about the Language Identification service, read the service <a href="https://console.bluemix.net/docs/services/language-translator/index.html">documentation</a>.</p> </script> <script type="text/javascript"> // This is the on edit prepare function, which will be invoked everytime the dialog // is shown. function li2oneditprepare() { $.getJSON('watson-language-translator-identify/vcap/') .done(function (service) { $('.credentials').toggle(!service); }) .fail(function () { $('.credentials').show(); }).always(function () { $('#credentials-check').hide(); }); } (function() { RED.nodes.registerType('watson-language-translator-identify', { category: 'IBM Watson', defaults: { name: {value: ''}, 'service-endpoint' :{value: ''} }, credentials: { apikey: {type: 'password'} }, color: 'rgb(84,149,230)', inputs: 1, outputs: 1, icon: 'LanguageTranslator25x25.png', paletteLabel: 'language identify', label: function() { return this.name || 'language identify'; }, labelStyle: function() { return this.name ? 'node_label_italic' : ''; }, oneditprepare: li2oneditprepare }); })(); </script>