ceoApp.controller('ceoPageController', [ '$scope', 'ceoPageService', 'Constants', 'mixpanelService', function($scope, ceoPageService, Constants, mixpanelService) { var marketingUrl = Constants.marketingUrl; var industryAwardCount = {}; industryAwardCount["Artificial Intelligence"] = 25; industryAwardCount["Automobile"] = 25; industryAwardCount["Finance"] = 50; industryAwardCount["Consulting & Business Services"] = 25; industryAwardCount["Tech"] = 50; industryAwardCount["Marketing & Creative Agencies"] = 25; industryAwardCount["Airlines"] = 25; industryAwardCount["Education"] = 25; industryAwardCount["Energy & Utilities"] = 40; industryAwardCount["Food & Beverages"] = 25; industryAwardCount["Hardware & Equipment"] = 25; industryAwardCount["Healthcare"] = 50; industryAwardCount["Industrial Goods"] = 25; industryAwardCount["Insurance"] = 25; industryAwardCount["Internet of Things"] = 25; industryAwardCount["Media & Entertainment"] = 50; industryAwardCount["On Demand Economy"] = 25; industryAwardCount["Personal & Household Goods"] = 25; industryAwardCount["Pharma & Biotech"] = 25; industryAwardCount["Real Estate & Construction"] = 40; industryAwardCount["Retail & Ecommerce"] = 50; industryAwardCount["SaaS"] = 25; industryAwardCount["Telecommunications"] = 25; industryAwardCount["Transportation & Warehousing"] = 25; industryAwardCount["Travel & Hospitality"] = 30; var segmentLinkMap = {}; segmentLinkMap["US Overall"] = "&type=Public&input=100"; segmentLinkMap["SMBs"] = "&input=50"; segmentLinkMap["Early Stage Companies"] = "&input=50"; var industryLinkMap = {}; industryLinkMap["Tech"] = "&input=200"; industryLinkMap["Education"] = "&input=50"; industryLinkMap["Energy ! Utilities"] = "&input=50"; industryLinkMap["Travel ! Hospitality"] = "&input=50"; industryLinkMap["Pharma ! Biotech"] = "&input=50"; industryLinkMap["Finance"] = "&input=50"; industryLinkMap["Hardware ! Equipment"] = "&input=50"; industryLinkMap["Food ! Beverages"] = "&input=50"; industryLinkMap["Transportation ! Warehousing"] = "&input=50"; industryLinkMap["Internet of Things"] = "&input=50"; industryLinkMap["Consulting ! Business Services"] = "&input=50"; industryLinkMap["Healthcare"] = "&input=50"; industryLinkMap["Media ! Entertainment"] = "&input=50"; industryLinkMap["Marketing ! Creative Agencies"] = "&input=20"; industryLinkMap["Airlines"] = "&input=20"; industryLinkMap["Industrial Goods"] = "&input=50"; industryLinkMap["SaaS"] = "&input=50"; industryLinkMap["On Demand Economy"] = "&input=50"; industryLinkMap["Real Estate ! Construction"] = "&input=50"; industryLinkMap["Telecommunications"] = "&input=50"; industryLinkMap["Personal ! Household Goods"] = "&input=20"; industryLinkMap["Retail ! Ecommerce"] = "&input=50"; industryLinkMap["Insurance"] = "&input=50"; industryLinkMap["Automobile"] = "&input=50"; industryLinkMap["Artificial Intelligence"] = "&input=50"; var cityLinkMap = {}; cityLinkMap["Atlanta"] = "&input=50"; cityLinkMap["Austin"] = "&input=50"; cityLinkMap["Birmingham"] = ""; cityLinkMap["Boston"] = "&input=50"; cityLinkMap["Burlington"] = ""; cityLinkMap["Cambridge"] = "&type=Public"; cityLinkMap["Charlotte"] = "&type=Public"; cityLinkMap["Chicago"] = "&input=50"; cityLinkMap["Cincinnati"] = ""; cityLinkMap["Cleveland"] = ""; cityLinkMap["Columbus"] = ""; cityLinkMap["Dallas"] = "&type=Public"; cityLinkMap["Denver"] = ""; cityLinkMap["Fort Worth"] = ""; cityLinkMap["Houston"] = "&input=50"; cityLinkMap["Indianapolis"] = ""; cityLinkMap["Jacksonville"] = ""; cityLinkMap["Kansas City"] = ""; cityLinkMap["Las Vegas"] = ""; cityLinkMap["Los Angeles"] = "&input=50"; cityLinkMap["Louisville"] = ""; cityLinkMap["Miami"] = ""; cityLinkMap["Minneapolis"] = "&type=Public"; cityLinkMap["Montreal"] = ""; cityLinkMap["Nashville"] = ""; cityLinkMap["New York"] = "&input=50"; cityLinkMap["Omaha"] = ""; cityLinkMap["Orlando"] = ""; cityLinkMap["Philadelphia"] = ""; cityLinkMap["Phoenix"] = ""; cityLinkMap["Pittsburgh"] = ""; cityLinkMap["Portland"] = ""; cityLinkMap["Raleigh"] = ""; cityLinkMap["Salt Lake City"] = ""; cityLinkMap["San Antonio"] = ""; cityLinkMap["Silicon Valley"] = "&input=35"; cityLinkMap["San Diego"] = ""; cityLinkMap["San Francisco"] = "&input=50"; cityLinkMap["Scottsdale"] = ""; cityLinkMap["Seattle"] = "&input=25"; cityLinkMap["Seattle"] = "&input=35"; cityLinkMap["Tampa"] = ""; cityLinkMap["Toronto"] = "&type=Public"; cityLinkMap["Vancouver"] = ""; cityLinkMap["Washington"] = ""; $scope.industryCounts = industryAwardCount; $scope.ceoData = []; $scope.isCity = false; $scope.isIndustry = false; $scope.isSegment = false; $scope.isOverall = false; $scope.isQuery = false; $scope.cityTitle = ""; $scope.industryTitle = ""; $scope.segmentTitle = ""; $scope.searchTitle = ""; $scope.industryName = ""; $scope.pageNumber = pageNumber; $scope.numberOfPages = numberOfPages $scope.queryTerm = ""; $scope.isStudy = isStudy; $scope.showHide = function(isShowed) { if (isShowed) { return "- Hide all cities"; } else { return "+ Show all cities"; } } console.log($scope.queryTerm); function camelize(str) { return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); } cityName = camelize(cityName); if (industryName == "Internet Of Things" || industryName == "Internet of Things") { industryName = "Internet of Things" } else if (industryName != "SaaS") { industryName = camelize(industryName); } industryName = industryName.replace("!", "&"); segmentName = camelize(segmentName); if (segmentName == "Smbs") { segmentName = "SMBs" } if (segmentName == "New Kids On The Block") { segmentName = "New Kids on the Block" } if (segmentName == "Us Overall") { segmentName = "US Overall" } if (segmentName == "Us Public Companies") { segmentName = "US Public Companies" } if (segmentName == "Most Rated Us Public Companies") { segmentName = "Most Rated US Public Companies"; } init(); function init() { if (query && query != "null") { trackCeoPageQuery(query) fetchCeosFromSearchQuery(query, pageNumber); $scope.isQuery = true; $scope.searchTitle = "Search Results of " + query; } else if (cityName && cityName != "null" && cityName != "Null") { fetchCeosFromCity(cityName, pageNumber, companyStatus, votes, companyRevenue); $scope.isCity = true; $scope.cityTitle = "Top " + cityName + " CEOs"; } else if (segmentName && segmentName != "null" && segmentName != "Null") { fetchCeosFromSegment(segmentName, pageNumber, isStudy); $scope.isSegment = true; $scope.segmentTitle = "Top CEOs in " + segmentName; }else if (industryName && industryName != "null" && industryName != "Null") { fetchCeosFromIndustry(industryName, pageNumber, companyStatus, votes, companyRevenue); $scope.isIndustry = true; $scope.industryTitle = "Top CEOs in " + industryName; $scope.industryName = industryName; } else { fetchAllCeos(pageNumber); $scope.isOverall = true; } } $scope.fetchAllCeos = fetchAllCeos; $scope.fetchCeosFromCity = fetchCeosFromCity; $scope.fetchCeosFromSegment = fetchCeosFromSegment; $scope.fetchCeosFromIndustry = fetchCeosFromIndustry; $scope.fetchCeosFromSearchQuery = fetchCeosFromSearchQuery; function fetchCeosFromSearchQuery(query, pageNumber) { var promise = ceoPageService.getCeoSearchResult(query, pageNumber); promise.then(function(response) { $scope.ceoData = response.data; }); } function fetchAllCeos(pageNumber) { var promise = ceoPageService.getAllCeos(pageNumber); promise.then(function(response) { $scope.ceoData = response.data; }); } function fetchCeosFromCity(city, pageNumber, companyStatus, votes, companyRevenue) { var promise = ceoPageService.getMatchedCeosFromCity(city, pageNumber, companyStatus, votes, companyRevenue); promise.then(function(response) { $scope.ceoData = response.data; }); } function fetchCeosFromSegment(segment, pageNumber, isStudy) { var promise = ceoPageService.getMatchedCeosFromSegment(segment, pageNumber, companyStatus, votes, companyRevenue, isStudy); promise.then(function(response) { $scope.ceoData = response.data; }); } function fetchCeosFromIndustry(industry, pageNumber, companyStatus, votes, companyRevenue) { var promise = ceoPageService.getMatchedCeosFromIndustry(industry, pageNumber, companyStatus, votes, companyRevenue); promise.then(function(response) { $scope.ceoData = response.data; }); } $scope.sortType = 'ceoRating'; // set the default sort type $scope.sortReverse = true; // set the default sort order $scope.goToCity = function(city) { var url = marketingUrl + "/ceo-ratings.htm?cityName=" + city; if (isStudy) { url = url + cityLinkMap[city] + "&study=yes"; } return url } $scope.goToIndustry = function(industry) { var url = marketingUrl + "/ceo-ratings.htm?industryName=" + industry; if (isStudy) { url = url + industryLinkMap[industry] + "&study=yes"; } return url; } $scope.goToSegment = function(segment) { var url = marketingUrl + "/ceo-ratings.htm?segmentName=" + segment; if (isStudy) { url = url + segmentLinkMap[segment] + "&study=yes"; } return url; } $scope.showBadge = function(isWinner) { console.log(isWinner); } $scope.trackPreviousButton = function() { var prop ={}; prop["page"] = $scope.pageNumber; mixpanelService.trackEvent( "Previous page navigation" ,prop); } $scope.trackNextButton = function() { var prop ={}; prop["page"] = $scope.pageNumber; mixpanelService.trackEvent( "Next page navigation" ,prop); } $scope.trackCeoPageCity = function(city){ var prop ={}; prop["City"] = city; mixpanelService.trackEvent( "Top CEOs in city" ,prop); } $scope.trackCeoPageIndustry = function(industry){ var prop ={}; prop["Industry"] = industry; mixpanelService.trackEvent( "Top CEOs in industry" ,prop); } $scope.trackCeoPageSegment = function(segment){ var prop ={}; prop["Segment"] = segment; mixpanelService.trackEvent( "Top CEOs in segment" ,prop); } function trackCeoPageQuery(query){ var prop ={}; prop["Query"] = query; mixpanelService.trackEvent( "Track searching term" ,prop); } }] );