PageSourceSearch

https://www.acsilver.co.uk/shop/pc/service/app/search.js

js acsilver.co.uk collected 2026-10-02 07:01:16 UTC 7,214 bytes, 222 lines download raw bytes

1// Search App
2var fsApp = angular.module('productcart.facets', []);
3
4fsApp.config(['$compileProvider', '$locationProvider', function ($compileProvider, $locationProvider) {
5    $locationProvider.html5Mode({ enabled: true, requireBase: false });
6}]);
7
8fsApp.directive('htmldiv', ['$compile', '$parse', function($compile, $parse) {
9return {
10  restrict: 'E',
11  link: function(scope, element, attr) {
12    scope.$watch(attr.content, function() {      
13      if (scope.roundtrip == 1) {
14          element.html($parse(attr.content)(scope));
15          $compile(element.contents())(scope);
16      }      
17    }, true);
18  }
19}
20}]);
21
22fsApp.controller('solrSearchCtrl', ['$scope', '$location', '$http', '$timeout', '$log', '$compile', 'httpRequest', 'pcService', function($scope, $location, $http, $timeout, $log, $compile, httpRequest, pcService) {
23 
24      $scope.productList = [];
25    
26        // Defaults
27        $scope.roundtrip = 0;
28        $scope.page = 1;
29        $scope.pageSize = 40;
30        $scope.total = 0; 
31        
32        $scope.type = '';
33        $scope.myhtml = '';
34
35        $scope.categories= [];
36        $scope.sizes = [];
37        $scope.brands = [];
38        $scope.prices = [];
39        $scope.colors = [];
40
41        $scope.url = decodeURI($location.url());
42
43        // Async Data Load Callback
44        $scope.$on('handleProductList', function(event, data) {
45            $scope.roundtrip = 1;
46            console.log('load');
47            $scope.myhtml = data;         
48        });
49        
50        // Paging
51        $scope.DoPageRefresh = function(text, page, pageSize, total){
52            $scope.page = page;
53            $location.search('page', $scope.page);    
54            loadData();
55        };
56
57        // Load Data
58        function loadData() { 
59            $scope.url = $location.absUrl().split('?')[1]             
60            pcService.getProductList($scope.url, false);
61        };
62
63
64        // Start: Category
65        $scope.AddRemoveCat = function (val) {  
66            if (typeof $scope.categories == 'undefined') {
67                $scope.categories = [];
68            }  
69            if ($scope.categories.indexOf(val) == -1){
70                $scope.categories.push(val);
71            } else {
72                var index = $scope.categories.indexOf(val);
73                $scope.categories.splice(index, 1);
74            } 
75            $location.search('categories[]', $scope.categories);    
76            loadData();
77        };
78        // End: Category
79
80        // Start: Size
81        $scope.AddRemoveSize = function (val) {  
82            if (typeof $scope.sizes == 'undefined') {
83                $scope.sizes = [];
84            }  
85            if ($scope.sizes.indexOf(val) == -1){
86                $scope.sizes.push(val);
87            } else {
88                var index = $scope.sizes.indexOf(val);
89                $scope.sizes.splice(index, 1);
90            } 
91            $location.search('sizes[]', $scope.sizes);    
92            loadData();
93        };
94        // End: Size
95    
96        // Start: Brand
97        $scope.AddRemoveBrand = function (val) {  
98            if (typeof $scope.brands == 'undefined') {
99                $scope.brands = [];
100            }  
101            if ($scope.brands.indexOf(val) == -1){
102                $scope.brands.push(val);
103            } else {
104                var index = $scope.brands.indexOf(val);
105                $scope.brands.splice(index, 1);
106            } 
107            $location.search('brands[]', $scope.brands);    
108            loadData();
109        };
110        // End: Brand
111        
112        // Start: Price
113        $scope.AddRemovePrice = function (val) {  
114            if (typeof $scope.prices == 'undefined') {
115                $scope.prices = [];
116            }  
117            if ($scope.prices.indexOf(val) == -1){
118                $scope.prices.push(val);
119            } else {
120                var index = $scope.prices.indexOf(val);
121                $scope.prices.splice(index, 1);
122            } 
123            $location.search('prices[]', $scope.prices);    
124            loadData();
125        };
126        // End: Price
127        
128        // Start: Color
129        $scope.AddRemoveColor = function (val) {  
130            if (typeof $scope.colors == 'undefined') {
131                $scope.colors = [];
132            }  
133            if ($scope.colors.indexOf(val) == -1){
134                $scope.colors.push(val);
135            } else {
136                var index = $scope.colors.indexOf(val);
137                $scope.colors.splice(index, 1);
138            } 
139            $location.search('colors[]', $scope.colors);    
140            loadData();
141        };
142        // End: Color
143        
144        // Start: Sort
145        $scope.AddRemoveSort = function (val) {  
146            console.log('sorted');
147            if (typeof $scope.sort == 'undefined') {
148                $scope.sort = '';
149            } else {
150                $scope.sort = val;
151            }  
152            $location.search('sort', $scope.sort);    
153            loadData();
154        };
155        // End: Sort 
156
157
158        function refreshView() {  
159    
160            if (typeof $scope.productList.pageInfo == 'undefined') {
161                $scope.total = 0;
162            } else {
163                $scope.total = $scope.productList.pageInfo.total; 
164            }
165            
166            $scope.type = $location.search()['type'];
167            
168            $scope.categories = $location.search()['categories[]'];
169            if (!angular.isObject($scope.categories)) {
170                if ($scope.categories) { $scope.categories = [$scope.categories] };
171            }
172    
173            $scope.sizes = $location.search()['sizes[]'];
174            if (!angular.isObject($scope.sizes)) {
175                if ($scope.sizes) { $scope.sizes = [$scope.sizes] };
176            }
177            $scope.brands = $location.search()['brands[]'];
178            if (!angular.isObject($scope.brands)) {
179                if ($scope.brands) { $scope.brands = [$scope.brands] };
180            }        
181            $scope.prices = $location.search()['prices[]'];
182            if (!angular.isObject($scope.prices)) {
183                if ($scope.prices) { $scope.prices = [$scope.prices] };
184            }
185            $scope.colors = $location.search()['colors[]'];
186            if (!angular.isObject($scope.colors)) {
187                if ($scope.colors) { $scope.colors = [$scope.colors] };
188            }
189            $scope.url = $location.absUrl().split('?')[1]  
190
191        };
192
193
194        $scope.Evaluate = function (val) {
195            if (val == 'true' || val == true) {
196                return true;
197            } else {
198                return false;
199            }
200        };
201
202
203        $scope.IsEmpty = function (val) {
204            if (val) {
205                return false;
206            } else {
207                return true;
208            }
209        };
210
211        refreshView();
212
213}]);
214
215
216// Bootstrap
217angular.element(document).ready(function () {
218    //angular.bootstrap($('#searchApp'), ['productcart.facets']);
219    //$('#searchApp').removeClass('cloak');
220});
221
222

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.