diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 42f93d6..d7e0fb5 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -8685,77 +8685,83 @@ AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$l $scope.ShowSearch = function () { - - var primaryLexiconIndex; - for (var i = 0; i <= $rootScope.vocabTermDataArray.length - 1; i++) { - if ($rootScope.vocabTermDataArray[i].language == $rootScope.lexiconLanguageArray[0].language) { - primaryLexiconIndex = i; + if (($rootScope.vocabTermDataArray != null || $rootScope.vocabTermDataArray != undefined) && ($rootScope.vocabTermDataArray.length > 0)) { + var primaryLexiconIndex; + for (var i = 0; i <= $rootScope.vocabTermDataArray.length - 1; i++) { + if ($rootScope.vocabTermDataArray[i].language == $rootScope.lexiconLanguageArray[0].language) { + primaryLexiconIndex = i; + } } - } - console.log('ShowSearch is called'); - //this check is for log only because we are writing length so need to check if its not null or undefined - if ($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != null || $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != undefined) - console.log('$scope.VocabTermTxt.length= ' + $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt.length) + console.log('ShowSearch is called'); + //this check is for log only because we are writing length so need to check if its not null or undefined + if ($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != null || $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != undefined) + console.log('$scope.VocabTermTxt.length= ' + $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt.length) - $timeout(function () { - - if (($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != null || $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != undefined) && ($rootScope.vocabTermDataArray[0].vocabTermTxt.length > 0)) { - //This is added as the $scope.VocabTermTxt can change while changing view also the li elements need to be removed - //Remove the list and then Repopulate - if ($('#searchListDiv').html() != "") - $('#searchListDiv').empty() - //Delay compile of ul li so that the remove of li is completed. - $timeout(function () { - console.log("INSIDE WATCH. LIST IS CREATED"); - $scope.isSearchDataLoaded = true; + $timeout(function () { - if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { + if (($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != null || $rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt != undefined) && ($rootScope.vocabTermDataArray[0].vocabTermTxt.length > 0)) { + //This is added as the $scope.VocabTermTxt can change while changing view also the li elements need to be removed + //Remove the list and then Repopulate + if ($('#searchListDiv').html() != "") + $('#searchListDiv').empty() + //Delay compile of ul li so that the remove of li is completed. + $timeout(function () { + console.log("INSIDE WATCH. LIST IS CREATED"); + $scope.isSearchDataLoaded = true; - if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) { - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - } - else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) { - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - } - else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) { - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - } - else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) { - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); + if (($scope.ColoredImageSRC != null || $scope.ColoredImageSRC != undefined)) { + + if ((($rootScope.viewOrientationId == '1') || ($rootScope.viewOrientationId == '4')) && ($scope.ColoredImageSRC.length == 9)) { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + } + else if ((($rootScope.viewOrientationId == '2') || ($rootScope.viewOrientationId == '3')) && ($scope.ColoredImageSRC.length == 5)) { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + } + else if (($rootScope.viewOrientationId == '5') && ($scope.ColoredImageSRC.length == 4)) { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + } + else if (($rootScope.viewOrientationId == '6') && ($scope.ColoredImageSRC.length == 1)) { + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + } } - } - }, 500); - $scope.IsSearchVisible = true; - console.log("s" + $rootScope.vocabTermDataArray[primaryLexiconIndex].language); - $rootScope.a = primaryLexiconIndex; - var $e2 = $('').appendTo('#searchListDiv') - $compile($e2)($scope); - document.getElementById("termlistfilter").style.display = "block"; - $timeout(function () { - $rootScope.searchListArray = []; - $("#backdrop > #searchListDiv > #termlistfilter > li").each(function (key, value) { - $rootScope.searchListArray.push({ "name": $(this).find("a").html(), "id": $(this).find("a").attr("id") }); - }); - }, 100); - - } - else { - $rootScope.loadSearchData(); - if ($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt.length > 0) { - $scope.ShowSearch(); - } - } - }, 500); + }, 500); + $scope.IsSearchVisible = true; + console.log("s" + $rootScope.vocabTermDataArray[primaryLexiconIndex].language); + $rootScope.a = primaryLexiconIndex; + var $e2 = $('').appendTo('#searchListDiv') + $compile($e2)($scope); + document.getElementById("termlistfilter").style.display = "block"; + $timeout(function () { + $rootScope.searchListArray = []; + $("#backdrop > #searchListDiv > #termlistfilter > li").each(function (key, value) { + $rootScope.searchListArray.push({ "name": $(this).find("a").html(), "id": $(this).find("a").attr("id") }); + }); + }, 100); - + } + else { + $rootScope.loadSearchData(); + if ($rootScope.vocabTermDataArray[primaryLexiconIndex].vocabTermTxt.length > 0) { + $scope.ShowSearch(); + } + } + }, 500); + } + else + { + $rootScope.loadSearchData(); + $scope.ShowSearch(); + + + } }