1
1
2
+ /**
3
+ * Misc functions
4
+ */
5
+
6
+ function isUndefined ( value ) {
7
+ return typeof value === "undefined" ;
8
+ }
9
+
2
10
function isNumber ( n ) {
3
11
return ! isNaN ( parseFloat ( n ) ) && isFinite ( n ) ;
4
12
}
@@ -105,24 +113,28 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
105
113
106
114
//then update custom analyzers
107
115
for ( index in $scope . analyzer . customAnalyzers ) {
108
- updateCustomAnalyzers ( ) ;
116
+ updateCustomAnalyzer ( index ) ;
109
117
}
110
118
111
119
//then update per-field analyzers
112
120
for ( index in $scope . analyzer . fields ) {
113
- updateFields ( ) ;
121
+ updateField ( index ) ;
114
122
}
115
123
} ) ;
116
124
117
125
//Because detectCustomAnalyzers executes asynch, we need to watch the customAnalyzer field
118
126
//to detect when the GET returns
119
127
$scope . $watch ( 'analyzer.customAnalyzers' , function ( value ) {
120
- updateCustomAnalyzers ( ) ;
128
+ for ( index in $scope . analyzer . customAnalyzers ) {
129
+ updateCustomAnalyzer ( index ) ;
130
+ }
121
131
} ) ;
122
132
123
133
//If any of the user-selected fields change, update
124
134
$scope . $watch ( 'analyzer.currentField' , function ( value ) {
125
- updateFields ( ) ;
135
+ for ( index in $scope . analyzer . fields ) {
136
+ updateField ( index ) ;
137
+ }
126
138
} , true ) ;
127
139
128
140
@@ -136,7 +148,7 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
136
148
function updateCustomAnalyzer ( index ) {
137
149
138
150
//Only query indices that are enabled
139
- if ( ! $scope . analyzer . customAnalyzers [ index ] . enable )
151
+ if ( isUndefined ( $scope . analyzer . customAnalyzers [ index ] ) || ! $scope . analyzer . customAnalyzers [ index ] . enable )
140
152
return ;
141
153
142
154
//Make sure this index has some analyzer defined
@@ -151,9 +163,9 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
151
163
}
152
164
153
165
function updateField ( index ) {
154
-
166
+ //console.log($scope.analyzer.customAnalyzers[index].enable, isUndefined($scope.analyzer.customAnalyzers[index]) === true, ! $scope.analyzer.customAnalyzers[index].enable);
155
167
//Only query indices that are enabled
156
- if ( ! $scope . analyzer . customAnalyzers [ index ] . enable )
168
+ if ( isUndefined ( $scope . analyzer . customAnalyzers [ index ] ) || ! $scope . analyzer . customAnalyzers [ index ] . enable )
157
169
return ;
158
170
159
171
//if a currentField is set for this index
@@ -230,15 +242,15 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
230
242
//This function is called when the "Enable" checkbox is toggled.
231
243
//Used to selectively update indices without calling the update* functions
232
244
$scope . indexEnabled = function ( index ) {
233
- if ( $scope . analyzer . customAnalyzers [ index ] . enable ) {
245
+ if ( ! $scope . analyzer . customAnalyzers [ index ] . enable )
246
+ return ;
234
247
235
248
//update the custom analyzers
236
249
updateCustomAnalyzer ( index ) ;
237
250
238
251
//and individual fields
239
252
updateField ( index ) ;
240
253
241
- }
242
254
243
255
}
244
256
0 commit comments