searchApp.directive('basicSearch',['$document','$timeout','Constants', 'searchConstants', 'commonsAppServices', 'basicSearchService', 'mySharedService', '$sce', '$window', '$localStorage', '$filter', 'mixpanelService','$rootScope', function($document,$timeout,Constants, searchConstants, commonsAppServices, basicSearchService, sharedService, $sce, $window, $localStorage, $filter, mixpanelService,$rootScope) { return { restrict: "E", replace: true, scope: { searchCompany : '=', callbackFn : '&', calltoFn : '&', wantToAdd : '@', txtPlaceHolder : '@', wishListText : '@', ignoreAdded:'@', showAdvancedsearch : '@' }, link: function (scope, element, attrs) { scope.isPopupVisible = false; scope.newCompanyAdded = false;scope scope.callbackCompanyList={}; scope.companyArray={}; scope.companyList={}; scope.newCompanyList={}; scope.search=""; scope.search.text=""; scope.hitCount = 0; scope.rawHitCount = 0; scope.advSearchFilters = {}; scope.countryName = ""; scope.stateName = ""; scope.industryName = ""; scope.sectorName = ""; scope.countryControl = {}; scope.stateControl = {}; scope.industryControl = {}; scope.sectorControl = {}; scope.zipcodeControl = {}; scope.areacodeControl = {}; scope.hideAdvcdSearch = false; scope.isAdvancedSearchPopupVisible = false; scope.ownership={}; scope.ownership.value=""; scope.ownership.value="Any"; scope.zipcodes = []; scope.areacodes = []; scope.employeeArray = [0,5,10,20,50,75,100,200,250,300,350,400,450,500,600,700,800,900,1000,1500,2000,4000,6500,10000,20000,50000,75000,100000]; scope.revenueArray = [0,1000000,2000000,5000000,15000000,30000000,65000000,130000000,250000000,500000000,1000000000,2000000000,4000000000,8000000000,15000000000,30000000000,65000000000,130000000000,265000000000,500000000000]; scope.fundingArray = [0,100000,250000,600000,850000,1000000,5000000,10000000,15000000,20000000,35000000,50000000,75000000,1000000000,2000000000]; scope.ageArray = [0,2,3,4,5,7,10,15,20,30,40,50,60,70,80,90,100]; var localStorageKeysArray = ["ngStorage-ownership","ngStorage-country","ngStorage-state","ngStorage-industry","ngStorage-industryCode", "ngStorage-sector","ngStorage-employeemin","ngStorage-employeemax","ngStorage-revenuemin","ngStorage-revenuemax", "ngStorage-fundingmin","ngStorage-fundingmax","ngStorage-agemin","ngStorage-agemax","ngStorage-zipcodes"]; scope.focusIndex = -1; scope.searchSuggestionBoxHeight = 0; scope.zipDefaultOption = "Zip/Postal Code"; scope.areaDefaultOption = "Area Code"; scope.noOfSelectedZips = 0; scope.noOfSelectedAreas = 0; scope.showSearchBar = false; var mixpanel_c = searchConstants.mixpanelUtil.mixpanel_property; var gaEvent_c = searchConstants.gaEventConstants; var ignoreIndexList=new Array(); attrs.$observe('showAdvancedsearch', function(value){ if(!value){ scope.showAdvancedsearch=true; } }); attrs.$observe('ignoreAdded', function(value){ if(!value){ scope.ignoreAdded=false; } }); attrs.$observe('wantToAdd', function(value){ if(!value){ scope.wantToAdd=true; }else if(value=="false"){ scope.wantToAdd=false; }else{ scope.wantToAdd=true; } }); attrs.$observe('wishListText', function(value){ if(!value){ scope.wishListText="Company Added to request list. Will appear in the list after approval"; } }); attrs.$observe('calltoFn', function(value){ if(!value){ scope.calltoFn=function(){}; } }); function updateListSelection(liID) { var list = document.getElementById("basicSearchSuggestionBox"); var targetLi = document.getElementById("basicSearchSuggestionBox-"+liID); list.scrollTop = (targetLi.offsetTop - 63); }; var headerWatermark = "Search for a company"; var selectedItem=null; var searchTerm = ""; function headerBasicSearch() { var searchBox = document.getElementById("headerBasicSearch"); if(searchBox != null){ searchTerm = scope.search.text; if (searchTerm == undefined || searchTerm == "" || searchTerm == headerWatermark) { //user haven't entered anything //1) nothing to search //2) autocomplete menu won't be available return; } location.href = HOST_WITH_SSL+"browsecompanyprofiles.htm?searchTerm=" + searchTerm; } return false; }; scope.handleKeyPress = function(e) { var keycode; if (e) keycode = e.which; else return true; if (keycode == 13) { //this function is in search.js var searchParameter = scope.search.text; if(searchParameter != null && searchParameter != undefined){ _gaq.push(['_trackEvent', gaEvent_c.CATEGORY_SEARCH, gaEvent_c.SEARCH_ENTERKEYPRESSED, searchParameter]); } if(scope.focusIndex != -1){ location.href = scope.companyList[scope.focusIndex].seoFriendlyCompanyProfileUrl; } else{ headerBasicSearch(); } }else if(keycode == 40) { e.preventDefault(); scope.focusIndex++; scope.focusIndex = (scope.focusIndex + scope.companyList.length) % scope.companyList.length; updateListSelection(scope.focusIndex); } else if(keycode == 38) { e.preventDefault(); if(scope.focusIndex == - 1 ) { scope.focusIndex = (scope.focusIndex + scope.companyList.length) % scope.companyList.length; }else{ scope.focusIndex--; scope.focusIndex = (scope.focusIndex + scope.companyList.length) % scope.companyList.length; } updateListSelection(scope.focusIndex); } } scope.searchRedirectToCPpage = function(url){ var searchParameter = scope.search.text; if(searchParameter != null && searchParameter != undefined){ _gaq.push(['_trackEvent', gaEvent_c.CATEGORY_SEARCH, gaEvent_c.SEARCH_LOGOCLICKED, searchParameter]); } window.location = url; } scope.$on('showAdvSearchBox', function(event) { scope.showAdvancedSearchPopup(); }); scope.updateSearchResult = function(searchTerm) { scope.focusIndex = -1; searchTerm = searchTerm.replace("https://", ''); searchTerm = searchTerm.replace("http://", ''); searchTerm = searchTerm.replace("www.", ''); if(searchTerm != "" && searchTerm.length > 1) { scope.isPopupVisible = true; scope.searchSuggestionBoxHeight = $window.innerHeight - 85 + 'px'; commonsAppServices.searchCompanies(searchTerm).then(function(result) { document.querySelector("#header-overlay").style.display = "block"; scope.companyArray = result.data.results; searchTerm = getSearchTerm(searchTerm); if(searchTerm != "" && scope.companyArray != null && scope.companyArray != '') { scope.newCompanyAdded = false; scope.callbackCompanyList = scope.callbackFn(); var tempList=new Array(); angular.forEach(scope.companyArray, function(item) { var label = item.shortName + " | " + item.primaryDomain + getTickerIfNotNull(item); var lSearchTerm = searchTerm.toLowerCase(); var displayString = label; var lLabel = label.toLowerCase(); var startIndex = 0; while (lLabel.indexOf(lSearchTerm, startIndex) > -1) { var index = lLabel.indexOf(lSearchTerm, startIndex); startIndex = index + lSearchTerm.length + 13; var startString = displayString.substring(0, index); var endString = displayString.substring(index + lSearchTerm.length); var searchString = displayString.substring(index, index + lSearchTerm.length); searchString = "" + searchString + ""; displayString = startString + searchString + endString; lLabel = displayString.toLowerCase(); } var linkString = displayString; var following = false; var overrideFollow=false; var ignoreEntry=false; angular.forEach(scope.callbackCompanyList, function(company) { if (company.id+'' === item.id) { if(scope.ignoreAdded){ ignoreEntry=true; return; } if(company.overrideFollow==undefined){ following = true; }else{ overrideFollow=true; following = company.follow == undefined || company.follow; } } }); if(!ignoreEntry){ tempList.push(item); } item["overrideFollow"]=overrideFollow; item["resultString"] = linkString; item["following"] = following; }); scope.companyList = tempList; } else { document.querySelector("#header-overlay").style.display = "none"; scope.companyList = null; if(scope.wantToAdd && ValidURL(searchTerm)) { var company = []; scope.newCompanyList = []; company["url"] = searchTerm; scope.newCompanyList.push(company); } else { scope.newCompanyList = null; scope.companyList = null; } } }); } else { document.querySelector("#header-overlay").style.display = "none"; scope.isPopupVisible = false; scope.companyList=null; } }; scope.addNewCompanyToWatchlist = function(website) { commonsAppServices.addNewCompanyToWatchlist(website).then(function(result) { scope.isPopupVisible = false; scope.newCompanyAdded = true; }); } scope.$on('companyAdded', function() { scope.addedCompany = sharedService.addedCompany ; angular.forEach(scope.companyArray, function(company) { if (company.id === scope.addedCompany.id) { company.following = true; return false; } }); }); scope.$on('companyRemoved', function() { scope.removedCompany = sharedService.removedCompany ; angular.forEach(scope.companyArray, function(company) { if (company.id === scope.removedCompany.id) { company.following = false; return false; } }); }); scope.closebasicSearchPopup = function(){ document.querySelector("#header-overlay").style.display = "none"; scope.isPopupVisible = false; scope.search.text=""; } scope.closeAdvancedSearchPopup = function(){ document.querySelector("#header-overlay").style.display = "none"; scope.isAdvancedSearchPopupVisible = false; }; scope.showAdvancedSearchPopup = function() { if(scope.isAdvancedSearchPopupVisible) { document.querySelector("#header-overlay").style.display = "none"; scope.isAdvancedSearchPopupVisible = false; } else { document.querySelector("#header-overlay").style.display = "block"; scope.isPopupVisible = false; scope.search.text=""; scope.isAdvancedSearchPopupVisible = true; var prop = {}; prop[mixpanel_c.ACTION] = mixpanel_c.ADVANCED_SEARCH_TRIGGERED; mixpanelService.trackEvent(mixpanel_c.ADVANCED_SEARCH, prop); basicSearchService.getCountryList().then(function(response){ var result = response.data; scope.countryList = []; scope.countryMap = {}; var country = result.countryList; // scope.countryList.push("Select Country"); for (var i = 0; i < country.length; i++) { if (country[i].name != undefined && country[i].name != null) { scope.countryList.push(country[i].name); scope.countryMap[country[i].name] = country[i].code; } } //scope.stateList = []; var industry = result.industryList; scope.industryList = []; scope.industryMap = {}; // scope.industryList.push("Select Industry"); angular.forEach(industry, function (value, key) { if (value != undefined && value != null) { scope.industryList.push(value); scope.industryMap[value] = key; } }); //scope.sectorList = []; }); // clear advanced search persisted attributes in local storage for (var key in localStorageKeysArray ) { localStorage.removeItem(localStorageKeysArray [key]); } retainStorageToPopUp(); scope.getSearchHits(); } } function retainStorageToPopUp(){ var advSearchObject = {}; if(isNotUndefinedOrNull($localStorage.owler_advSearchObject)){ advSearchObject = JSON.parse($localStorage.owler_advSearchObject); } if(isNotUndefinedOrNull(advSearchObject.ownership)){ scope.ownership.value = advSearchObject.ownership; } if(isNotUndefinedOrNull(advSearchObject.country)){ scope.countryName = advSearchObject.country; } if(isNotUndefinedOrNull(advSearchObject.state)){ showStateList(scope.countryName,true); scope.stateName = advSearchObject.state; } if(isNotUndefinedOrNull(advSearchObject.industry)){ scope.industryName = advSearchObject.industry; } if(isNotUndefinedOrNull(advSearchObject.industryCode)){ scope.industryCode = advSearchObject.industryCode; } if(isNotUndefinedOrNull(advSearchObject.industryCode) && isNotUndefinedOrNull(advSearchObject.sector)){ showSectorList(advSearchObject.industryCode); scope.sectorName = advSearchObject.sector; } if(isNotUndefinedOrNull(advSearchObject.employeemin)){ scope.emp_slider.minValue = advSearchObject.employeemin; } if(isNotUndefinedOrNull(advSearchObject.employeemax)){ if(advSearchObject.employeemax > scope.employeeArray.length - 1){ scope.emp_slider.maxValue = scope.employeeArray.length - 1; } else { scope.emp_slider.maxValue = advSearchObject.employeemax; } } if(isNotUndefinedOrNull(advSearchObject.revenuemin)){ scope.rev_slider.minValue = advSearchObject.revenuemin; } if(isNotUndefinedOrNull(advSearchObject.revenuemax)){ if(advSearchObject.revenuemax > scope.revenueArray.length - 1){ scope.rev_slider.maxValue = scope.revenueArray.length - 1; } else { scope.rev_slider.maxValue = advSearchObject.revenuemax; } } if(isNotUndefinedOrNull(advSearchObject.fundingmin)){ scope.fun_slider.minValue = advSearchObject.fundingmin; } if(isNotUndefinedOrNull(advSearchObject.fundingmax)){ if(advSearchObject.fundingmax > scope.fundingArray.length - 1) { scope.fun_slider.maxValue = scope.fundingArray.length - 1; } else { scope.fun_slider.maxValue = advSearchObject.fundingmax; } } if(isNotUndefinedOrNull(advSearchObject.agemin)){ scope.age_slider.minValue = advSearchObject.agemin; } if(isNotUndefinedOrNull(advSearchObject.agemax)){ if(advSearchObject.agemax > scope.ageArray.length - 1){ scope.age_slider.maxValue = scope.ageArray.length - 1; } else { scope.age_slider.maxValue = advSearchObject.agemax; } } } var showStateList = function(country,enableSequence) { basicSearchService.getStateList(country).then(function(response){ if(country != "Select Country") { scope.stateList = []; scope.stateMap = {}; var state = response.data; for (var i = 0; i < state.length; i++) { if (state[i].name != undefined && state[i].name != null) { scope.stateList.push(state[i].name); scope.stateMap[state[i].name] = state[i].code; } } if(enableSequence){ var advSearchObject = {}; if(isNotUndefinedOrNull($localStorage.owler_advSearchObject)){ advSearchObject = JSON.parse($localStorage.owler_advSearchObject); } if(!isNotUndefinedOrNull(advSearchObject.zipcodes)){ advSearchObject.zipcodes = []; } if(!isNotUndefinedOrNull(advSearchObject.areacodes)){ advSearchObject.areacodes = []; } if(isNotUndefinedOrNull(scope.stateMap)){ showZipAreaCodeList(scope.stateMap[advSearchObject.state]); scope.zipcodes = advSearchObject.zipcodes; scope.noOfSelectedZips = scope.zipcodes.length; if(scope.noOfSelectedZips == 0){ scope.zipDefaultOption = "Zip/Postal Code"; } else { scope.zipDefaultOption = scope.noOfSelectedZips + " Selected"; } scope.areacodes = advSearchObject.areacodes; scope.noOfSelectedAreas = scope.areacodes.length; if(scope.noOfSelectedAreas == 0){ scope.areaDefaultOption = "Area Code"; } else { scope.areaDefaultOption = scope.noOfSelectedAreas + " Selected"; } } if((isNotUndefinedOrNull(scope.zipcodes) && scope.zipcodes.length > 0) || (isNotUndefinedOrNull(scope.areacodes) && scope.areacodes.length > 0)){ scope.getSearchHits(); } } } }); } var showZipAreaCodeList = function(stateCode) { if(isNotUndefinedOrNullOrEmpty(stateCode)){ basicSearchService.getZipAndAreaList(stateCode).then(function(response){ if(stateCode != "Select State") { var zipcode = response.data.zipCodes; scope.zipcodeList = []; scope.zipcodeMap = {}; for (var i = 0; i < zipcode.length; i++) { scope.zipcodeList.push(zipcode[i]); scope.zipcodeMap[zipcode[i]] = zipcode[i]; } var areacode = response.data.areaCodes; scope.areacodeList = []; scope.areacodeMap = {}; for (var j = 0; j < areacode.length; j++) { scope.areacodeList.push(areacode[j]); scope.areacodeMap[areacode[j]] = areacode[j]; } } }); } } var showSectorList = function(industry) { basicSearchService.getSectorList(industry).then(function(response){ if(industry != "Select Industry") { scope.sectorList = []; scope.sectorMap = {}; // scope.sectorList.push("Select Sector"); var sector = response.data; angular.forEach(sector, function (value, key) { if (value != undefined && value != null) { scope.sectorList.push(value); scope.sectorMap[value] = key; } }); } }); } var formatNumber = function(num) { return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); }; scope.handleSearchFocus = function(){ document.querySelector("#header-overlay").style.display = "none"; scope.hideAdvcdSearch = true; scope.isAdvancedSearchPopupVisible = false; } scope.showAdvSearchIcon = function(){ scope.hideAdvcdSearch = false; } var resetZipAreaCode = function(){ scope.zipcodes = []; scope.zipcodeList = []; scope.zipDefaultOption = "Zip/Postal Code"; scope.noOfSelectedZips = 0; scope.areacodes = []; scope.areacodeList = []; scope.areaDefaultOption = "Area Code"; scope.noOfSelectedAreas = 0; } scope.countryControl.publish = function(labelName,newValue,isValid){ resetZipAreaCode(); if(newValue != "Select Country") { scope.countryName = newValue; scope.stateName = "Select State"; if(scope.countryMap != null || scope.countryMap != undefined){ showStateList(scope.countryMap[newValue],false); } } else { scope.countryName = "Select Country"; scope.stateName = "Select State"; scope.stateList = []; } scope.getSearchHits(); }; scope.stateControl.publish = function(labelName, newValue, isValid){ resetZipAreaCode(); if(newValue != "Select State") { scope.stateName = newValue; if(scope.stateMap != null && scope.stateMap != undefined && scope.countryName == 'USA'){ showZipAreaCodeList(scope.stateMap[newValue]); } } else { scope.stateName = "Select State"; } scope.getSearchHits(); }; scope.zipcodeControl.publish = function(labelName,newValue,isValid){ if(newValue != "Zip/Postal Code") { scope.zipcodes = newValue; } scope.getSearchHits(); }; scope.areacodeControl.publish = function(labelName,newValue,isValid){ if(newValue != "Area Code") { scope.areacodes = newValue; } scope.getSearchHits(); }; scope.industryControl.publish = function(labelName,newValue,isValid){ if(newValue != "Select Industry") { scope.industryName = newValue; scope.sectorName = "Select Sector"; if(isNotUndefinedOrNull(scope.industryMap) && isNotUndefinedOrNull(scope.industryMap[newValue])){ showSectorList(scope.industryMap[newValue]); } angular.forEach(scope.industryMap, function(value, key){ if(scope.industryName == key) { scope.industryCode = value; } }) } else { scope.industryName = "Select Industry"; scope.sectorName = "Must select Industry first"; scope.sectorList = []; } scope.getSearchHits(); }; scope.sectorControl.publish = function(labelName, newValue, isValid){ if(newValue != "Select Sector") { scope.sectorName = newValue; } else { scope.sectorName = "Select Sector"; } scope.getSearchHits(); }; scope.hideAdvancedSearchPopup = function() { scope.isAdvancedSearchPopupVisible = false; document.querySelector("#header-overlay").style.display = "none"; } scope.getSearchHits = function(){ scope.advSearchFilters.ownership = scope.ownership.value; if(scope.countryName == "Select Country") scope.advSearchFilters.country = ""; else scope.advSearchFilters.country = scope.countryName; if(scope.stateName == "Select State") scope.advSearchFilters.state = ""; else scope.advSearchFilters.state = scope.stateName; if(scope.zipcodes == null || scope.zipcodes == undefined || scope.zipcodes.length == 0){ scope.advSearchFilters.zipcodes = []; } else { scope.advSearchFilters.zipcodes = scope.zipcodes; } if(scope.areacodes == null || scope.areacodes == undefined || scope.areacodes.length == 0){ scope.advSearchFilters.areacodes = []; } else { scope.advSearchFilters.areacodes = scope.areacodes; } if(scope.industryName == "Select Industry") scope.advSearchFilters.industry = ""; else scope.advSearchFilters.industry = scope.industryName; if(scope.sectorName == "Select Sector" || scope.sectorName == "Must select Industry first") scope.advSearchFilters.sector = ""; else scope.advSearchFilters.sector = scope.sectorName; scope.advSearchFilters.employeemin = scope.emp_slider.options.stepsArray[scope.emp_slider.minValue]; scope.advSearchFilters.employeemax = scope.emp_slider.options.stepsArray[scope.emp_slider.maxValue]; scope.advSearchFilters.revenuemin = scope.rev_slider.options.stepsArray[scope.rev_slider.minValue]; scope.advSearchFilters.revenuemax = scope.rev_slider.options.stepsArray[scope.rev_slider.maxValue]; scope.advSearchFilters.fundingmin = scope.fun_slider.options.stepsArray[scope.fun_slider.minValue]; scope.advSearchFilters.fundingmax = scope.fun_slider.options.stepsArray[scope.fun_slider.maxValue]; scope.advSearchFilters.agemin = Number(scope.age_slider.options.stepsArray[scope.age_slider.minValue]); scope.advSearchFilters.agemax = Number(scope.age_slider.options.stepsArray[scope.age_slider.maxValue]); var searchHitsCount = basicSearchService.getSearchHits(scope.advSearchFilters); searchHitsCount.then(function(hitCounts) { scope.rawHitCount = hitCounts.data; scope.hitCount = formatNumber(hitCounts.data); }); }; function isNotUndefinedOrNullOrEmpty(val) { return !(val === undefined || val === null || val === ""); }; function isNotUndefinedOrNull(val) { return !(val === undefined || val === null); }; scope.generateList = function(){ var advSearchObject = {}; var prop = {}; prop[mixpanel_c.ACTION] = mixpanel_c.LIST_GENERATED; mixpanelService.trackEvent(mixpanel_c.ADVANCED_SEARCH, prop); advSearchObject.ownership = scope.ownership.value; if(isNotUndefinedOrNullOrEmpty(scope.countryName)){ if(scope.countryName == "Select Country"){ scope.countryName = ""; } advSearchObject.country = scope.countryName; } if(isNotUndefinedOrNullOrEmpty(scope.stateName)){ if(scope.stateName == "Select State"){ scope.stateName = ""; } advSearchObject.state = scope.stateName; } if(scope.zipcodes != null && scope.zipcodes != undefined && scope.zipcodes.length > 0){ if(scope.zipcodes == "Zip/Postal Code"){ scope.zipcodes = []; } advSearchObject.zipcodes = scope.zipcodes; } if(scope.areacodes != null && scope.areacodes != undefined && scope.areacodes.length > 0){ if(scope.areacodes == "Area Code"){ scope.areacodes = []; } advSearchObject.areacodes = scope.areacodes; } if(isNotUndefinedOrNullOrEmpty(scope.industryName)){ if(scope.industryName == "Select Industry"){ scope.industryName = ""; scope.industryCode = ""; } advSearchObject.industry = scope.industryName; advSearchObject.industryCode = scope.industryCode; } if(isNotUndefinedOrNullOrEmpty(scope.sectorName)){ if(scope.sectorName == "Select Sector" || scope.sectorName == "Must select Industry first"){ scope.sectorName = ""; } advSearchObject.sector = scope.sectorName; } if(isNotUndefinedOrNullOrEmpty(scope.emp_slider.minValue)){ advSearchObject.employeemin = scope.emp_slider.minValue; advSearchObject.employeeminvalue = scope.advSearchFilters.employeemin; } if(isNotUndefinedOrNullOrEmpty(scope.emp_slider.maxValue)){ advSearchObject.employeemax = scope.emp_slider.maxValue; advSearchObject.employeemaxvalue = scope.advSearchFilters.employeemax; } if(isNotUndefinedOrNullOrEmpty(scope.rev_slider.minValue)){ advSearchObject.revenuemin = scope.rev_slider.minValue; advSearchObject.revenueminvalue = scope.advSearchFilters.revenuemin; } if(isNotUndefinedOrNullOrEmpty(scope.rev_slider.maxValue)){ advSearchObject.revenuemax = scope.rev_slider.maxValue; advSearchObject.revenuemaxvalue = scope.advSearchFilters.revenuemax; } if(isNotUndefinedOrNullOrEmpty(scope.fun_slider.minValue)){ advSearchObject.fundingmin = scope.fun_slider.minValue; advSearchObject.fundingminvalue = scope.advSearchFilters.fundingmin; } if(isNotUndefinedOrNullOrEmpty(scope.fun_slider.maxValue)){ advSearchObject.fundingmax = scope.fun_slider.maxValue; advSearchObject.fundingmaxvalue = scope.advSearchFilters.fundingmax; } if(isNotUndefinedOrNullOrEmpty(scope.age_slider.minValue)){ advSearchObject.agemin = scope.age_slider.minValue; advSearchObject.ageminvalue = scope.advSearchFilters.agemin; } if(isNotUndefinedOrNullOrEmpty(scope.age_slider.maxValue)){ advSearchObject.agemax = scope.age_slider.maxValue; advSearchObject.agemaxvalue = scope.advSearchFilters.agemax; } $localStorage.owler_advSearchObject = JSON.stringify(advSearchObject); $window.open(Constants.apiUrl+"/advancedsearch.htm","_self"); } /*scope.$watch('ownership.value', function(val) { if (val !== undefined) scope.ownership.value = val; scope.getSearchHits(); });*/ scope.emp_slider = { minValue: 0, maxValue: 27, options: { stepsArray: scope.employeeArray, translate: function(value){ lastValue = scope.employeeArray[scope.employeeArray.length - 1]; if(scope.employeeArray[value] != lastValue){ return $filter("numberFormatWithPrecision")(scope.employeeArray[value]); }else{ return $filter("numberFormatWithPrecision")(scope.employeeArray[value]) + "+"; } }, hideLimitLabels: true, onEnd: function(id) { scope.getSearchHits(); } }}; scope.rev_slider = { minValue: 0, maxValue: scope.revenueArray.length - 1, options: { stepsArray: scope.revenueArray, translate: function(value){ lastValue = scope.revenueArray[scope.revenueArray.length - 1]; if(scope.revenueArray[value] != lastValue){ return $filter("currencyFormat")(scope.revenueArray[value]); }else{ return $filter("currencyFormat")(scope.revenueArray[value]) + "+"; } }, hideLimitLabels: true, onEnd: function(id) { scope.getSearchHits(); } }}; scope.fun_slider = { minValue: 0, maxValue: scope.fundingArray.length - 1, options: { stepsArray: scope.fundingArray, translate: function(value) { lastValue = scope.fundingArray[scope.fundingArray.length - 1]; if(scope.fundingArray[value] != lastValue){ return $filter("currencyFormat")(scope.fundingArray[value]); }else{ return $filter("currencyFormat")(scope.fundingArray[value]) + "+"; } }, hideLimitLabels: true, onEnd: function(id) { scope.getSearchHits(); } }}; scope.age_slider = { minValue: 0, maxValue: 16, //maxValue: 6, options: { stepsArray: scope.ageArray, translate: function(value) { lastValue = scope.ageArray[scope.ageArray.length - 1]; if(scope.ageArray[value] != lastValue){ return scope.ageArray[value]; }else{ return scope.ageArray[value] + "+"; } }, hideLimitLabels: true, onEnd: function(id) { scope.getSearchHits(); } }}; scope.getHTMLvalue = function(name){ return $sce.trustAsHtml(name); }; function getTickerIfNotNull(item){ var ticker = item.tickerSymbol; if(ticker != null){ return " | Ticker: " +item.tickerSymbol; }else{ return ""; }; } function getSearchTerm(str){ return stripDomain(str); } function ValidURL(str) { var strValue = str; var patt = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,})$/; var result = patt.test(strValue); if(result) { return true; } else { return false; } } commonsAppServices.getTemplateLoader('basicSearch.html',Constants.cdnFullPath + 'scripts/angular/commons/modules/searchcompany/basicSearch.html')(element,scope); } }; }]);