|
99 | 99 | </script> |
100 | 100 |
|
101 | 101 | <script type="text/javascript"> |
| 102 | + |
| 103 | +// This is the on edit prepare function, which will be |
| 104 | +//invoked everytime the dialog is shown. |
| 105 | +function nlconeditprepare() { |
| 106 | + $('#node-input-mode').change(function () { |
| 107 | + var mode = $('#node-input-mode').val(); |
| 108 | + $('.form-row.mode.' + mode).show(); |
| 109 | + $('.form-row.mode:not(.' + mode + ')').hide(); |
| 110 | + }) |
| 111 | + $.getJSON('watson-natural-language-classifier/vcap/') |
| 112 | + .done(function (service) { |
| 113 | + $('.credentials').toggle(!service); |
| 114 | + }) |
| 115 | + .fail(function () { |
| 116 | + $('.credentials').show(); |
| 117 | + }).always(function () { |
| 118 | + $('#credentials-check').hide(); |
| 119 | + }) |
| 120 | +} |
| 121 | + |
| 122 | + |
102 | 123 | (function() { |
103 | 124 | RED.nodes.registerType('watson-natural-language-classifier', { |
104 | 125 | category: 'IBM Watson', |
|
125 | 146 | labelStyle: function() { |
126 | 147 | return this.name ? "node_label_italic" : ""; |
127 | 148 | }, |
128 | | - //oneditprepare: nlconeditprepare |
129 | | - oneditprepare: function() { |
130 | | - $('#node-input-mode').change(function () { |
131 | | - var mode = $('#node-input-mode').val(); |
132 | | - $('.form-row.mode.' + mode).show(); |
133 | | - $('.form-row.mode:not(.' + mode + ')').hide(); |
134 | | - }) |
135 | | - $.getJSON('watson-natural-language-classifier/vcap/') |
136 | | - .done(function (service) { |
137 | | - $('.credentials').toggle(!service); |
138 | | - }) |
139 | | - .fail(function () { |
140 | | - $('.credentials').show(); |
141 | | - }).always(function () { |
142 | | - $('#credentials-check').hide(); |
143 | | - }) |
144 | | - } |
| 149 | + oneditprepare: nlconeditprepare |
145 | 150 | }); |
146 | 151 | })(); |
147 | 152 | </script> |
0 commit comments