PageSourceSearch

https://samarthinstitute.edu.in/engg/web-assets/angular/angularjs/…blogs-page-controller.js?version=1772287905

js samarthinstitute.edu.in collected 2026-10-10 00:01:39 UTC 6,376 bytes, 175 lines download raw bytes

1
2app.controller("FrontEndAPI/ViewAllListServicesCtrl", function ($scope, $http, toastr) {
3    $scope.blogViewAllListInit = function () {
4        $scope.blogListArray = {
5            upcomingBlog: [],
6            pastBlog: [],
7        };
8        $scope.blogCounts = {
9            all: 0,
10            upcoming: 0,
11            past: 0
12        };
13        $scope.base_url = base_url;
14    
15        // Inside your Angular controller
16$scope.getCategory = [];
17
18        $scope.getAllBlogsCategory();
19        $scope.getAllBlogs();
20        $scope.getAllblogListService();
21        $scope.inputSearchValue = "";
22        $scope.categoryName = "All blogs";
23        $scope.seperator = "^%^";
24        
25    };
26
27    $scope.changeCategory = function (category) {
28        if (document.getElementById("All blogs")) {
29            document.getElementById("All blogs").classList.remove("active");
30        }
31        if (document.getElementById(category.bg_type)) {
32            document.getElementById(category.bg_type).classList.add("active");
33        }
34        if (document.getElementById($scope.categoryName)) {
35            document.getElementById($scope.categoryName).classList.remove("active");
36        }
37    
38        if (category === 'All blogs') {
39            $scope.categoryName = 'All blogs';
40            $scope.getAllBlogs();
41        } else {
42            $scope.categoryName = category.bg_type;
43            $scope.getAllblogListService();
44        }
45    };
46    
47
48    // get category of blog
49    $scope.getAllBlogsCategory = function () {
50        var transform = function (data) {
51            return $.param(data);
52        };
53        $http.post(
54            window.site_url + "FrontEndAPI//getAllBlogCategory",
55            {
56                inputSearchValue: $scope.inputSearchValue,
57            },
58            {
59                headers: {
60                    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
61                },
62                transformRequest: transform,
63            }
64        ).then(function (response) {
65            if (response.data.status.status == "201") {
66                $scope.getCategory = response.data.data;
67            } else {
68                toastr.error(response.data.status.message);
69            }
70        });
71    };
72    $scope.getAllBlogs = function () {
73        var transform = function (data) {
74            return $.param(data);
75        };
76        $http.post(
77            window.site_url + "FrontEndAPI//getAllBlogs",
78            {
79                inputSearchValue: $scope.inputSearchValue,
80            },
81            {
82                headers: {
83                    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
84                },
85                transformRequest: transform,
86            }
87        ).then(function (response) {
88            if (response.data.status.status == "201") {
89                $scope.getAllblogArray = response.data.data;
90                $scope.numberOfBlogs = $scope.getAllblogArray.length;
91                $scope.blogCounts.all = $scope.numberOfBlogs;
92    
93                // Populate blogListArray with all blogs
94                $scope.blogListArray.upcomingBlog = $scope.getAllblogArray;
95                $scope.blogListArray.pastBlog = [];
96    
97                // Reset category name to 'All blogs'
98                $scope.categoryName = "All blogs";
99            } else {
100                toastr.error(response.data.status.message);
101            }
102        });
103    };
104    
105    
106    $scope.getAllblogListService = function () {
107        
108    
109        var transform = function (data) {
110            return $.param(data);
111        };
112        $http.post(
113            window.site_url + "FrontEndAPI//getAllBlogs",
114            {
115                inputSearchValue: $scope.inputSearchValue,
116            },
117            {
118                headers: {
119                    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
120                },
121                transformRequest: transform,
122            }
123        ).then(function (response) {
124            if (response.data.status.status == "201") {
125                $scope.numberOfBlogs = response.data.data.length;
126                $scope.blogCounts.all = response.data.data.length;
127                $scope.blogCounts.upcoming = $scope.blogListArray.upcomingBlog.length;
128                $scope.blogCounts.past = $scope.blogListArray.pastBlog.length;
129                // Clear existing blog lists
130                $scope.blogListArray.upcomingBlog = [];
131                $scope.blogListArray.pastBlog = [];
132    
133                response.data.data.map((blog) => {
134                    let blogObj = {};
135                    blogObj.bg_id = blog.bg_id;
136                    blogObj.blogCategory = blog.blogCategory;
137                    blogObj.bg_created_date = blog.bg_created_date;
138                    blogObj.bg_title = blog.bg_title;
139                    blogObj.bg_s_description = blog.bg_s_description;
140                    blogObj.bg_valid_from = blog.bg_valid_from;
141                    blogObj.bg_valid_till = blog.bg_valid_till;
142                    blogObj.bg_file = blog.bg_file;
143                    blogObj.bg_report = blog.bg_report;
144                    blogObj.bg_location = blog.bg_location;
145                    blogObj.bg_descp_content = blog.bg_descp_content;
146                    blogObj.bg_new_flag = blog.bg_new_flag === "1" ? true : false;
147                    blogObj.isShowBlogs = true;
148    
149                 
150                if ($scope.categoryName === "All blogs" || blog.bg_type === $scope.categoryName) {
151                    $scope.blogListArray.upcomingBlog.push(blogObj);
152                }
153                if ($scope.categoryName === "Past Blog" && blog.bg_type === "Past Blog") {
154                    $scope.blogListArray.pastBlog.push(blogObj);
155                }
156                });
157                $scope.blogCounts.all = response.data.data.length;
158                $scope.blogCounts.upcoming = $scope.blogListArray.upcomingBlog.length;
159                $scope.blogCounts.past = $scope.blogListArray.pastBlog.length;
160            } else {
161                toastr.error(response.data.status.message);
162            }
163        });
164        
165    };
166    
167
168    $scope.getBlogDetails = (blog) => {
169        localStorage.setItem("blogsDetails", JSON.stringify(blog));
170        window.location.href = window.site_url + `blogs-details-new`;
171    }
172
173
174});
175

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.