Skip to content

Commit c6b60ec

Browse files
committed
oneditprepare function
1 parent 9fec12a commit c6b60ec

File tree

1 file changed

+22
-17
lines changed
  • services/natural_language_classifier

1 file changed

+22
-17
lines changed

services/natural_language_classifier/v1.html

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@
9999
</script>
100100

101101
<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+
102123
(function() {
103124
RED.nodes.registerType('watson-natural-language-classifier', {
104125
category: 'IBM Watson',
@@ -125,23 +146,7 @@
125146
labelStyle: function() {
126147
return this.name ? "node_label_italic" : "";
127148
},
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
145150
});
146151
})();
147152
</script>

0 commit comments

Comments
 (0)