PageSourceSearch

https://wlivestock.com/app/views/auctions/bidHistoryController.js?v=buster20250808

js wlivestock.com collected 2026-10-04 06:04:55 UTC 9,504 bytes, 236 lines download raw bytes

1
2app.controller('bidHistoryController', ['$scope', '$state', '$timeout', '$location', '$q', 'localStorageService', 'auctionsService', 'permissionsService', 'authenticationService', 'lists', 'lookupService',
3    function ($scope, $state, $timeout, $location, $q, localStorageService, auctionsService, permissionsService, authenticationService, lists, lookupService) {
4        
5        $scope.initializePage = function () {
6
7            permissionsService.isAuthenticated().then(function (results) {
8                if (!results.data) {
9                    popMessage("error", "Not Authorized", "You are not authorized to view this page. Please login to continue.");
10                    authenticationService.logout();
11                    $state.go('accountLogin');
12                } else {
13
14                    $scope.getBidHistory();
15
16                }
17            }, function (error) {
18                popApiErrorMessage(error);
19            });
20        };
21        
22        $scope.getBidHistory = function (resetFilterChanged) {
23
24            if (resetFilterChanged && resetFilterChanged == true) {
25                $scope.filterChanged = true;
26                $scope.checkIfFilterChanged();
27                $scope.setQueryStringSearchParams();
28            }
29
30            $scope.isSearchInProgress = true;
31
32            $scope.checkIfFilterChanged();
33
34            var deferred = $q.defer();
35
36            var filterText = "";
37            if ($scope.filter.text && $scope.filter.text.length > 0) {
38                filterText = '%' + $scope.filter.text + '%';
39            }
40
41            auctionsService.getBidHistory(filterText, $scope.sortField, $scope.sortDirection, $scope.pageNumber, $scope.pageSize).then(function (results) {
42
43                $scope.auctionItems = results.data.auctionItems;
44                $scope.totalItems = results.data.totalRows[0].totalRows;
45
46                // Get the message for the auction item
47                $.each($scope.auctionItems, function (itemIndex, item) {
48                    // Set the winning bid information so the utility can set the message
49                    var winningInfo = {
50                        amount: item.winningAmount,
51                        userId: item.winningUserId
52                    };
53                    item.winningBidInformation = [];
54                    item.winningBidInformation.push(winningInfo);
55                    // Get the message
56                    item.bidMessage = getAuctionItemBidMessage($scope.user, item, $scope.settings);
57                });
58
59                $scope.pageIsLoaded = true;
60                $scope.isSearchInProgress = false;
61                deferred.resolve();
62
63            }, function (error) {
64                popApiErrorMessage(error);
65                deferred.resolve();
66            });
67
68            return deferred.promise;
69
70        };
71
72        $scope.toggleExpanded = function (auctionItem) {
73            if (auctionItem.isExpanded == null) {
74                auctionItem.isExpanded = false;
75            }
76
77            auctionItem.isExpanded = !auctionItem.isExpanded;
78        };
79
80        $scope.formatDateAsUtc = function (dateToFormat) {
81            return formatDateOrDateStringAsUtcDate(dateToFormat);
82        };
83        
84        $scope.getImageUrl = function (currentImageUrl, sizeToGet) {
85            //Change Image URL to whatever size was selected
86            var replaceWithText = '_' + sizeToGet + '_';
87            //Just replace whatever occurrence might be found
88            currentImageUrl = currentImageUrl.replace(/_lg_/i, replaceWithText);
89            currentImageUrl = currentImageUrl.replace(/_md_/i, replaceWithText);
90            currentImageUrl = currentImageUrl.replace(/_sm_/i, replaceWithText);
91            currentImageUrl = currentImageUrl.replace(/_xs_/i, replaceWithText);
92            return currentImageUrl;
93        };
94
95
96        /***********************************************************************************************************************
97
98        Table sorting and paging methods
99
100        */
101
102        $scope.setSort = function (newSortField) {
103            // If the sort field is the same
104            if (newSortField == $scope.sortField) {
105                // set the sort direction to opposite of what it currently is
106                $scope.sortDirection == 'ASC' ? $scope.sortDirection = 'DESC' : $scope.sortDirection = 'ASC';
107            } else {
108                // Set the sort field as the new field and set the sort direction
109                $scope.sortField = newSortField;
110                $scope.sortDirection = 'ASC';
111            }
112
113            // Set the values in the query string
114            $scope.setQueryStringSearchParams();
115
116            // Re-get the data
117            $scope.getBidHistory();  // CUSTOM PER CONTROLLER
118        };
119
120        $scope.pageResults = function (pagination) {
121            $scope.pageNumber = pagination.page;
122
123            // Set the values in the query string
124            $scope.setQueryStringSearchParams();
125
126            // Re-get the data
127            $scope.getBidHistory();  // CUSTOM PER CONTROLLER
128        };
129
130        $scope.pageSizeChange = function (newpageSize) {
131            $scope.pageSize = newpageSize;
132
133            if ($scope.pageNumber * $scope.pageSize > $scope.totalItems && $scope.totalItems > 0) {
134                $scope.pageNumber = Math.ceil($scope.totalItems / $scope.pageSize);
135            }
136
137            // Set the values in the query string
138            $scope.setQueryStringSearchParams();
139
140            // Re-get the data
141            $scope.getBidHistory();  // CUSTOM PER CONTROLLER
142        };
143
144        $scope.setQueryStringSearchParams = function () {
145
146            $location.search($scope.queryStringPrefix + "ft", $scope.filter.text);  // CUSTOM PER CONTROLLER
147
148            $location.search($scope.queryStringPrefix + "p", $scope.pageNumber);
149            $location.search($scope.queryStringPrefix + "ps", $scope.pageSize);
150            $location.search($scope.queryStringPrefix + "s", $scope.sortField);
151            $location.search($scope.queryStringPrefix + "sd", $scope.sortDirection);
152        };
153
154        $scope.getQueryStringSearchParams = function () {
155
156            var getAuctionsSinceFiltersHaveBeenApplied = false;
157
158            if (getParameterByName($scope.queryStringPrefix + "ft").length > 0) { // CUSTOM PER CONTROLLER
159                $scope.filter.text = getParameterByName($scope.queryStringPrefix + "ft");
160                getAuctionsSinceFiltersHaveBeenApplied = true;
161            }
162
163            if (getParameterByName($scope.queryStringPrefix + "p").length > 0) {
164                $scope.pageNumber = Number(getParameterByName($scope.queryStringPrefix + "p"));
165                getAuctionsSinceFiltersHaveBeenApplied = true;
166            }
167            if (getParameterByName($scope.queryStringPrefix + "ps").length > 0) {
168                $scope.pageSize = Number(getParameterByName($scope.queryStringPrefix + "ps"));
169                getAuctionsSinceFiltersHaveBeenApplied = true;
170            }
171            if (getParameterByName($scope.queryStringPrefix + "s").length > 0) {
172                $scope.sortField = getParameterByName($scope.queryStringPrefix + "s");
173                getAuctionsSinceFiltersHaveBeenApplied = true;
174            }
175            if (getParameterByName($scope.queryStringPrefix + "sd").length > 0) {
176                $scope.sortDirection = getParameterByName($scope.queryStringPrefix + "sd");
177                getAuctionsSinceFiltersHaveBeenApplied = true;
178            }
179
180            if (getAuctionsSinceFiltersHaveBeenApplied) {
181                // Re-get the data since it isn't gathered when entering the page
182                $scope.getBidHistory();  // CUSTOM PER CONTROLLER
183            }
184
185        };
186        
187        $scope.checkIfFilterChanged = function () {
188            if ($scope.filterChanged) {
189                $scope.pageNumber = 1;
190                $scope.filterChanged = false;
191            }
192        };
193
194        // Set the default variables
195        $scope.availablePageSizes = lists.availablePageSizes;
196
197        $scope.queryStringPrefix = 'bh-';  // CUSTOM PER CONTROLLER
198
199        $scope.sortField = null;  // CUSTOM PER CONTROLLER
200        $scope.sortDirection = null;
201        $scope.pageNumber = 1;
202        $scope.pageSize = 10;
203        $scope.totalItems = 0;
204
205        $scope.filter = { text: null };  // CUSTOM PER CONTROLLER        
206
207        $scope.isSearchInProgress = false;
208        $scope.filterChanged = false;
209
210        // Check to see if any values got passed in the query string
211        $scope.getQueryStringSearchParams();
212
213        /*
214    
215        End table sorting and paging methods
216    
217        ***********************************************************************************************************************/
218
219
220
221        $scope.auctionItems = [];
222        
223        $scope.pageIsLoaded = false;
224
225        //If the page hasn't loaded after 1 second, signal that the ui can show the loading animation
226        $scope.canShowPageLoading = true;
227        $timeout(function () { $scope.canShowPageLoading = true; }, 1000);
228
229        $scope.settings = lookupService.settings;
230
231        $scope.user = localStorageService.get('AuthData');
232
233        //initialize Page
234        $scope.initializePage();
235    }
236]);

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.