function loadFacets() {
                if ($stateParams.c) {
                    // no selection changes
                    if ($stateParams.c === $scope.currentCategory) return;

                    $scope.currentCategory = $stateParams.c;
                    $scope.currentFacet = $stateParams.facet;

                    indexService.loadFacetsAsync($stateParams.c).then(function (filteredFacets) {
                        var itemsPerPage = 0;
                        var pageCounter = 0;
                        // an array containing pages and their respective facets
                        $scope.facets = [[]];
                        $scope.facetCount = filteredFacets.length;

                        $scope.currentFacetPage = 0;
                        for (var i = 0; i < filteredFacets.length; i++) {
                            // determine number of pages and add pages to array
                            if (itemsPerPage === $scope.panelSize) {
                                $scope.facets.push([]);
                                pageCounter += 1;
                                itemsPerPage = 0;
                            }

                            // Page selection based on selected facet?
                            if (filteredFacets[i].name === $scope.currentFacet) {
                                $scope.currentFacetPage = pageCounter;
                            }

                            // add facets to pages
                            $scope.facets[pageCounter].push(filteredFacets[i]);
                            itemsPerPage += 1;
                        }
                        $scope.resultSize = filteredFacets.size;
                    });

                } else {
                    $scope.facets = undefined;
                    $scope.facetValues = undefined;
                }
            }
/**
             * Load facets for a selected category from url param 'c'
             * and create panel paging accordingly
             */
Load facets for a selected category from url param 'c'
and create panel paging accordingly
Load facets for a selected category from url param ' c ' and create panel paging accordingly
function loadFacets() {
                if ($stateParams.c) {
                    if ($stateParams.c === $scope.currentCategory) return;
                    $scope.currentCategory = $stateParams.c;
                    $scope.currentFacet = $stateParams.facet;
                    indexService.loadFacetsAsync($stateParams.c).then(function (filteredFacets) {
                        var itemsPerPage = 0;
                        var pageCounter = 0;
                        $scope.facets = [[]];
                        $scope.facetCount = filteredFacets.length;
                        $scope.currentFacetPage = 0;
                        for (var i = 0; i < filteredFacets.length; i++) {
                            if (itemsPerPage === $scope.panelSize) {
                                $scope.facets.push([]);
                                pageCounter += 1;
                                itemsPerPage = 0;
                            }
                            if (filteredFacets[i].name === $scope.currentFacet) {
                                $scope.currentFacetPage = pageCounter;
                            }
                            $scope.facets[pageCounter].push(filteredFacets[i]);
                            itemsPerPage += 1;
                        }
                        $scope.resultSize = filteredFacets.size;
                    });
                } else {
                    $scope.facets = undefined;
                    $scope.facetValues = undefined;
                }
            }
function loadFacets ( ) { if ( $stateParams . c ) { if ( $stateParams . c === $scope . currentCategory ) return ; $scope . currentCategory = $stateParams . c ; $scope . currentFacet = $stateParams . facet ; indexService . loadFacetsAsync ( $stateParams . c ) . then ( function ( filteredFacets ) { var itemsPerPage = 0 ; var pageCounter = 0 ; $scope . facets = [ [ ] ] ; $scope . facetCount = filteredFacets . length ; $scope . currentFacetPage = 0 ; for ( var i = 0 ; i < filteredFacets . length ; i ++ ) { if ( itemsPerPage === $scope . panelSize ) { $scope . facets . push ( [ ] ) ; pageCounter += 1 ; itemsPerPage = 0 ; } if ( filteredFacets [ i ] . name === $scope . currentFacet ) { $scope . currentFacetPage = pageCounter ; } $scope . facets [ pageCounter ] . push ( filteredFacets [ i ] ) ; itemsPerPage += 1 ; } $scope . resultSize = filteredFacets . size ; } ) ; } else { $scope . facets = undefined ; $scope . facetValues = undefined ; } }
Load facets for a selected category from url param 'c'
 and create panel paging accordingly
Load facets for a selected category from url param ' c ' and create panel paging accordingly
// no selection changes // an array containing pages and their respective facets // determine number of pages and add pages to array // Page selection based on selected facet? // add facets to pages