|
| 1 | +<!-- |
| 2 | + Copyright 2013,2015 IBM Corp. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +--> |
| 16 | + |
| 17 | +<script type="text/x-red" data-template-name="watson-tone-analyzer-v3"> |
| 18 | + <div id="credentials-check" class="form-row"> |
| 19 | + <div class="form-tips"> |
| 20 | + <i class="fa fa-question-circle"></i><b> Please wait: </b> Checking for bound service credentials... |
| 21 | + </div> |
| 22 | + </div> |
| 23 | + <div class="form-row"> |
| 24 | + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
| 25 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 26 | + </div> |
| 27 | + <div class="form-row credentials" style="display: none;"> |
| 28 | + <label for="node-input-username"><i class="fa fa-user"></i> Username</label> |
| 29 | + <input type="text" id="node-input-username" placeholder="Username"> |
| 30 | + </div> |
| 31 | + <div class="form-row credentials" style="display: none;"> |
| 32 | + <label for="node-input-password"><i class="fa fa-key"></i> Password</label> |
| 33 | + <input type="password" id="node-input-password" placeholder="Password"> |
| 34 | + </div> |
| 35 | + <div class="form-row"> |
| 36 | + <label for="node-input-tones"><i class="fa fa-comments-o"></i> Tones</label> |
| 37 | + <select type="text" id="node-input-tones" style="display: inline-block; width: 70%;" > |
| 38 | + <option value="all">All</option> |
| 39 | + <option value="emotion">Emotion</option> |
| 40 | + <option value="language">Language</option> |
| 41 | + <option value="social">Social</option> |
| 42 | + </select> |
| 43 | + </div> |
| 44 | + <div class="form-row"> |
| 45 | + <label for="node-input-sentences"><i class="fa fa-language"></i> Sentences</label> |
| 46 | + <select type="text" id="node-input-sentences" style="display: inline-block; width: 70%;" > |
| 47 | + <option value="true">True</option> |
| 48 | + <option value="false">False</option> |
| 49 | + </select> |
| 50 | + </div> |
| 51 | + <div class="form-row"> |
| 52 | + <label for="node-input-contentType"><i class="fa fa-comments-o"></i> Content type</label> |
| 53 | + <select type="text" id="node-input-contentType" style="display: inline-block; width: 70%;" > |
| 54 | + <option value="false">Text</option> |
| 55 | + <option value="true">HTML</option> |
| 56 | + </select> |
| 57 | + </div> |
| 58 | + |
| 59 | +</script> |
| 60 | + |
| 61 | +<script type="text/x-red" data-help-name="watson-tone-analyzer"> |
| 62 | + <p>The Tone Analyzer service uses linguistic analysis to detect emotional tones, social propensities, and writing styles in written communication.</p> |
| 63 | + <p>The text to analyze should be passed in on <b>msg.payload</b>.</p> |
| 64 | + <p>The service response will be returned on <b>msg.response</b>.</p> |
| 65 | + <p>Usng the node editor dialog users can filter the results by tone (emotion, writing or social) and whether to include sentence-level analysis.</p> |
| 66 | + <p>For more information about the Tone Analyzer service, read the <a href="https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/tone-analyzer.html">documentation</a>.</p> |
| 67 | +</script> |
| 68 | + |
| 69 | +<script type="text/javascript"> |
| 70 | + (function() { |
| 71 | + RED.nodes.registerType('watson-tone-analyzer-v3', { |
| 72 | + category: 'IBM Watson', |
| 73 | + defaults: { |
| 74 | + name: {value: ""}, |
| 75 | + tones: {value: "all"}, |
| 76 | + sentences: {value: "true"}, |
| 77 | + contentType: {value: "false"} |
| 78 | + }, |
| 79 | + credentials: { |
| 80 | + username: {type:"text"}, |
| 81 | + password: {type:"password"} |
| 82 | + }, |
| 83 | + color: "rgb(84,149,230)", |
| 84 | + inputs: 1, |
| 85 | + outputs: 1, |
| 86 | + icon: "tone_analyzer.png", |
| 87 | + paletteLabel: "tone analyzer", |
| 88 | + label: function() { |
| 89 | + return this.name || "tone analyzer"; |
| 90 | + }, |
| 91 | + labelStyle: function() { |
| 92 | + return this.name ? "node_label_italic" : ""; |
| 93 | + }, |
| 94 | + oneditprepare: function() { |
| 95 | + $.getJSON('watson-tone-analyzer/vcap/') |
| 96 | + .done(function (service) { |
| 97 | + $('.credentials').toggle(!service); |
| 98 | + }) |
| 99 | + .fail(function () { |
| 100 | + $('.credentials').show(); |
| 101 | + }).always(function () { |
| 102 | + $('#credentials-check').hide(); |
| 103 | + }) |
| 104 | + } |
| 105 | + }); |
| 106 | + })(); |
| 107 | +</script> |
0 commit comments