Skip to content

Commit 7d00317

Browse files
committed
Fix some bugs introduced by method refactoring
1 parent b9e3a47 commit 7d00317

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

_site/js/controllers/AnalyzerCtrl.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
/**
3+
* Misc functions
4+
*/
5+
6+
function isUndefined(value) {
7+
return typeof value === "undefined";
8+
}
9+
210
function isNumber(n) {
311
return !isNaN(parseFloat(n)) && isFinite(n);
412
}
@@ -105,24 +113,28 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
105113

106114
//then update custom analyzers
107115
for (index in $scope.analyzer.customAnalyzers){
108-
updateCustomAnalyzers();
116+
updateCustomAnalyzer(index);
109117
}
110118

111119
//then update per-field analyzers
112120
for (index in $scope.analyzer.fields) {
113-
updateFields();
121+
updateField(index);
114122
}
115123
});
116124

117125
//Because detectCustomAnalyzers executes asynch, we need to watch the customAnalyzer field
118126
//to detect when the GET returns
119127
$scope.$watch('analyzer.customAnalyzers', function(value) {
120-
updateCustomAnalyzers();
128+
for (index in $scope.analyzer.customAnalyzers){
129+
updateCustomAnalyzer(index);
130+
}
121131
});
122132

123133
//If any of the user-selected fields change, update
124134
$scope.$watch('analyzer.currentField', function(value) {
125-
updateFields();
135+
for (index in $scope.analyzer.fields) {
136+
updateField(index);
137+
}
126138
}, true);
127139

128140

@@ -136,7 +148,7 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
136148
function updateCustomAnalyzer(index){
137149

138150
//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 )
140152
return;
141153

142154
//Make sure this index has some analyzer defined
@@ -151,9 +163,9 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
151163
}
152164

153165
function updateField(index) {
154-
166+
//console.log($scope.analyzer.customAnalyzers[index].enable, isUndefined($scope.analyzer.customAnalyzers[index]) === true, ! $scope.analyzer.customAnalyzers[index].enable);
155167
//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 )
157169
return;
158170

159171
//if a currentField is set for this index
@@ -230,15 +242,15 @@ function AnalyzerCtrl($scope, $http, Analyzer, Data){
230242
//This function is called when the "Enable" checkbox is toggled.
231243
//Used to selectively update indices without calling the update* functions
232244
$scope.indexEnabled = function(index) {
233-
if($scope.analyzer.customAnalyzers[index].enable){
245+
if(! $scope.analyzer.customAnalyzers[index].enable)
246+
return;
234247

235248
//update the custom analyzers
236249
updateCustomAnalyzer(index);
237250

238251
//and individual fields
239252
updateField(index);
240253

241-
}
242254

243255
}
244256

0 commit comments

Comments
 (0)