1ngApp.controller('Blog', function ($scope, $http, $window, $sce, $interval, $timeout, RootService) { 2 //window.history.pushState('', '', $scope._defines.domain+"/new-url"); 3 $scope.angular = false; 4 $scope.data = {}; 5 $scope.data.loader = true; 6 $scope.data.status = false; 7 $scope.data.error = false; 8 $scope.data.items = []; 9 $scope.data.count = 0; 10 $scope.filter = {}; 11 $scope.filter.categories = {}; 12 $scope.filter.sort = {}; 13 $scope.filter.sort.by = 'date'; 14 $scope.filter.sort.direction = 'desc'; 15 $scope.pagination = {}; 16 $scope.sort_code = 2; 17 $scope.updateList = function (page_number, isFilter = false) { 18 $scope.data.loader = true; 19 var filter_cats = []; 20 angular.forEach($scope.filter.categories, function (cat_value, cat_key) { 21 if (cat_value === true) { 22 filter_cats.push(cat_key); 23 } 24 }); 25 $scope.filter_cats = filter_cats; 26 var request_params = { 27 "filter": { 28 "categories": filter_cats, 29 "keyword": $scope.filter.keyword ? $scope.filter.keyword : null, 30 }, 31 "sort": { 32 "by": $scope.filter.sort.by, 33 "direction": $scope.filter.sort.direction 34 }, 35 "action": 'list', 36 "page": page_number, 37 "category_id": $scope.category_id 38 }; 39 RootService.Post('blog/search', JSON.stringify(request_params)) 40 .then(function (response) { 41 if (isFilter) $timeout(function () { 42 angular.element('.splashAjax').hide(); 43 }, 400); 44 $scope.pagination = response.data.pagination; 45 if (response.data.pagination.pages > response.data.pagination.page) { 46 $scope.enablePagination = true; 47 $scope.nextPage = response.data.pagination.page + 1; 48 } else { 49 $scope.enablePagination = false; 50 } 51 if (response.data.items.length) { 52 $scope.data.items = []; 53 $scope.data.items = response.data.items; 54 } else { 55 $scope.data.items = []; 56 if (isFilter === false) { 57 $scope.data.error = true; 58 } 59 } 60 61 $timeout(function () { 62 $scope.data.status = true; 63 $scope.data.loader = false; 64 }, 100); 65 $timeout(function () { 66 $scope.animateDiv('blog_items'); 67 }, 200); 68 }) 69 .catch(function (response) { 70 console.log(response); 71 $scope.data.loader = false; 72 }); 73 }; 74 75 $timeout(function () { 76 if ($scope.angular) { 77 $scope.updateList(1); 78 } 79 }, 10); 80 $scope.submitSearch = function () { 81 console.log('$scope.blog_keyword', $scope.blog_keyword); 82 $scope.angular = true; 83 $scope.filter.keyword = $scope.blog_keyword; 84 window.history.pushState('', '', $scope._defines.domain + "/blog/search"); 85 $scope.updateList(1, true); 86 } 87 $scope.removeFilter = function (type) { 88 switch (type) { 89 case 'keyword': 90 $scope.filter.keyword = null; 91 break; 92 case 'categories': 93 $scope.filter.categories = {}; 94 break; 95 case 'all': 96 $scope.filter = {}; 97 $scope.filter.keyword = null; 98 $scope.filter.categories = {}; 99 $scope.filter.sort = {}; 100 $scope.filter.sort.by = 'hits'; 101 $scope.filter.sort.direction = 'desc'; 102 break; 103 default: 104 } 105 $scope.updateList(1, true); 106 } 107 $scope.updateSort = function (sort) { 108 $scope.angular = true; 109 switch (sort) { 110 case 1: //hits desc
111 $scope.sort_code = 1; 112 $scope.filter.sort.by = 'hits'; 113 $scope.filter.sort.direction = 'desc'; 114 break; 115 case 2: //date desc 116 $scope.sort_code = 2; 117 $scope.filter.sort.by = 'date'; 118 $scope.filter.sort.direction = 'desc'; 119 break; 120 case 3: //sale desc 121 $scope.sort_code = 3; 122 $scope.filter.sort.by = 'date'; 123 $scope.filter.sort.direction = 'asc'; 124 break; 125 default: 126 } 127 $scope.updateList(1, true); 128 } 129 $scope.setPage = function () { 130 $scope.updateList($scope.pagination.page); 131 } 132 $scope.filtersCount = function () { 133 var filter_counts = 0 134 angular.forEach($scope.filter.categories, function (value, key) { 135 if (value === true) { 136 filter_counts++; 137 } 138 }); 139 if ($scope.filter.keyword) { 140 filter_counts++; 141 } 142 return filter_counts; 143 } 144});
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.