PageSourceSearch

https://airinfotech.in/components/index/topical/index.topical.controller.js

js airinfotech.in collected 2026-10-09 04:08:12 UTC 10,573 bytes, 289 lines download raw bytes

1(function () {
2    'use strict';
3
4    angular.module("airWebapp.indexSearch.topical")
5            .controller("TopicalController", TopicalController);
6
7    TopicalController.$inject = ["airPageTitle", "$scope", "$location", "$window", "DTOptionsBuilder", "DTColumnBuilder", "defaultIndexParams", "airUtils", "IndexService", "CasesService", "AuthService"];
8
9    function TopicalController(airPageTitle, $scope, $location, $window, DTOptionsBuilder, DTColumnBuilder, defaultIndexParams, airUtils, IndexService, CasesService, AuthService) {
10        airPageTitle.title = "Topical index search";
11        var _this = this;
12        this.$location = $location;
13        this.$window = $window;
14        this.IndexService = IndexService;
15        this.CasesService = CasesService;
16        this.data = {};
17        this.curSections = {};
18        this.selectedItem = {};
19        this.firstLoad = true;
20        this.searchParams = angular.copy(defaultIndexParams);
21        this.searchParams.journal = [];
22        this.formOptions = {};
23        this.formOptions.journals = airUtils.getUserJournals();
24        this.State = {
25            page: 1,
26            pageTop: 1,
27            totalItems: 0
28        };
29        this.curState = {
30            page: 1,
31            pageTop: 1,
32            totalItems: 0
33        };
34
35        this.selAllJournals();
36        this.searchTopical();
37        localStorage.setItem("pagenewsearch", false);
38        $scope.$watch(angular.bind(this, function () {
39            return this.searchParams.q;
40        }), function (newVal, oldVal) {
41            if (newVal && newVal !== oldVal) {
42                _this.searchParams.offset = 0;
43                _this.searchParams.limit = 20;
44                _this.searchTopical();
45            }
46            if (newVal === "") {
47                _this.data = {};
48                _this.searchTopical();
49            }
50        });
51        function updateTopCit(params) {
52            $scope.vm.searchParams.offset = params.offset;
53            $scope.vm.searchParams.limit = params.limit;
54            $scope.vm.IndexService.uptTopicalCases($scope.vm.searchParams).then(function (data) {
55                $scope.vm.topicalCitations = data.topical.citations;
56
57            }, function () {
58                console.log("Error fetching topical cases");
59            });
60        }
61        ;
62        var offset = 1;
63        $(document).on('click', ".paginate_button.next.disabled", function () {
64            var params = {
65                limit: 1000,
66                offset: offset
67            }
68            params.offset = offset * params.limit;
69            updateTopCit(params);
70            offset++;
71        });
72
73        $(document).on('click', ".paginate_button.previous", function () {
74            offset--;
75            var params = {
76                limit: 1000,
77                offset: offset
78            }
79            params.offset = offset * params.limit;
80            updateTopCit(params);
81
82        });
83
84
85        var input = document.getElementById('topical');
86
87        input.onkeyup = function () {
88            var key = event.keyCode || event.charCode;
89            localStorage.setItem("keycode", key);
90            _this.searchTopical();
91        };
92
93
94//        TopicalController.prototype.searchTopical = function () {
95//            var _this = this;
96//
97//            var keycode = localStorage.getItem("keycode");
98//            if (keycode === "8") {
99//                this.curState.page = 1;
100//                this.searchParams.offset = 0;
101//                _this.topicalCount = 0;
102//                _this.topicalCitations = '';
103//                document.getElementById("myForm").reset();
104//                _this.curMax();
105//                _this.curMin();
106//            }
107//            if (this.searchParams.q === "" || this.searchParams.q.length < 2) {
108//                return;
109//            }
110//            this.firstLoad = false;
111//            console.log(this.searchParams);
112//            this.IndexService.searchTopical(this.searchParams).then(function (data) {
113//                _this.curState.totalItems = data.count;
114//                _this.data = data;
115//            }, function () {
116//                console.log("error fetching dictionary data");
117//            });
118//        };
119    }
120
121    TopicalController.prototype.curMin = function () {
122        var min = ((this.State.page - 1) * this.searchParams.limit) + this.searchParams.limit;
123        return min;
124    };
125
126    TopicalController.prototype.curMax = function () {
127        var max = ((this.curState.page - 1) * this.searchParams.limit) + this.searchParams.limit;
128        return (max < this.curState.totalItems) ? max : this.curState.totalItems;
129    };
130
131
132    TopicalController.prototype.searchTopical = function () {
133        var _this = this;
134//        if (this.searchParams.q === "" || this.searchParams.q.length < 2) {
135//            return;
136//        }
137        this.firstLoad = false;
138        console.log(this.searchParams);
139        this.IndexService.searchTopical(this.searchParams).then(function (data) {
140            _this.curState.totalItems = data.count;
141            _this.data = data;
142        }, function () {
143            console.log("error fetching dictionary data");
144        });
145    };
146
147    TopicalController.prototype.pageChanged = function () {
148        this.searchParams.offset = (this.curState.page - 1) * this.searchParams.limit;
149        this.searchTopical();
150    };
151
152    TopicalController.prototype.citPageChanged = function () {
153        var topical = this.selectedItem;
154        this.searchParams.offset = (this.State.page - 1) * this.searchParams.limit;
155        this.getCitationslist(topical);
156    };
157
158    TopicalController.prototype.getCitations = function () {
159        var topical = this.selectedItem;
160        this.getTopicalCitations(topical);
161    };
162    TopicalController.prototype.selAllJournals = function () {
163        var _this = this;
164        angular.forEach(this.formOptions.journals, function (j) {
165            if (j.sub && (_this.searchParams.journal.indexOf(j.id) == -1)) {
166                _this.searchParams.journal.push(j.id);
167            }
168        });
169    };
170
171    TopicalController.prototype.getCitationslist = function (topical) {
172        var _this = this;
173//        _this.searchParams.journal = ['sc', 'crilj', 'hc', 'scw', 'aironline'];
174        if (this.selectedItem == this.selectedItem.id) {
175            return;
176        }
177        _this.firstLoad = false;
178        this.selectedItem = topical;
179        this.IndexService.getTopicalCases(this.selectedItem.id, _this.searchParams.journal, this.searchParams.offset, _this.searchParams.citationName).then(function (data) {
180            _this.searchParams.topid = data.topical.id;
181            _this.topicalCount = data.count;
182            _this.topicalCitations = data.topical.citations;
183        }, function () {
184            console.log("Error fetching topical cases");
185        });
186    };
187
188
189    TopicalController.prototype.getTopicalCit = function () {
190        var _this = this;
191        var searchParams = {};
192
193
194        var userdet = localStorage.getItem("userdetails");
195        var user_subscription = JSON.parse(userdet);
196        var subscription = JSON.parse(user_subscription.subscriptions);
197        var subsArr = [];
198        $.each(subscription, function (i, obj) {
199            if (obj.type == "JOURNALCOMBINED")
200            {
201                subsArr.push(obj.journal + "+" + obj.sub);
202                console.log("subsArr", subsArr);
203            } else if (obj.type == "JOURNAL")
204            {
205                subsArr.push(obj.journal);
206                console.log("subsArr2", subsArr);
207            }
208
209        });
210        searchParams.subscription = subsArr;
211//        searchParams.filterstring = this.selectedItem.word;
212        searchParams.searchtype = "phrase";
213        localStorage.setItem('searchtype', searchParams.searchtype);
214        searchParams.q = this.selectedItem.word;
215        searchParams.feature = "default";
216
217        this.CasesService.setOriginalParams(searchParams, this.type);
218        this.$location.path("/cases");
219//        this.$window.open("/cases", '_blank');
220    }
221
222    TopicalController.prototype.getTopicalCitations = function (topical) {
223        var _this = this;
224//        _this.searchParams.journal = ['sc', 'crilj', 'hc', 'scw', 'aironline'];
225        var userdet = localStorage.getItem("userdetails");
226        var user_subscription = JSON.parse(userdet);
227        var subscription = JSON.parse(user_subscription.subscriptions);
228        var subsArr = [];
229        $.each(subscription, function (i, obj) {
230            if (obj.type == "JOURNALCOMBINED")
231            {
232                subsArr.push(obj.journal + "+" + obj.sub);
233                console.log("subsArr", subsArr);
234            } else if (obj.type == "JOURNAL")
235            {
236                subsArr.push(obj.journal);
237                console.log("subsArr2", subsArr);
238            }
239
240        });
241        _this.searchParams.subscription = subsArr;
242
243        if (this.selectedItem == this.selectedItem.id) {
244            return;
245        }
246        _this.firstLoad = false;
247        _this.searchParams.offset = 0;
248        _this.State.page = 1;
249        this.selectedItem = topical;
250        this.IndexService.getTopicalCases(this.selectedItem.id, _this.searchParams.journal, this.searchParams.offset, _this.searchParams.citationName, _this.searchParams.subscription).then(function (data) {
251            _this.searchParams.topid = data.topical.id;
252            _this.topicalCount = data.count;
253            _this.topicalCitations = data.topical.citations;
254
255        }, function () {
256            console.log("Error fetching topical cases");
257            _this.topicalCitations = '';
258            _this.topicalCount = 0;
259        });
260    };
261
262    TopicalController.prototype.getActCases = function () {
263        var searchParams = {};
264        searchParams.word = this.selectedItem.word;
265
266        var topicClean = this.selectedItem.word.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
267//    angular.forEach(this.topicalCitations, function(entry) {
268//      if (entry.selected === true) {
269//        this.topicalCitations.push(actClean + ":" + entry.key);
270//      }
271//    });
272
273        searchParams.cit = this.topicalCitations;
274
275        this.CasesService.setOriginalParams(searchParams.word);
276        this.$location.path("/cases");
277    };
278
279    TopicalController.prototype.getCase = function () {
280        this.$location.path("/cases").search({
281            case: this.selectedCitation.id
282        });
283    };
284
285    TopicalController.prototype.getCasesLink = function (caseid) {
286        return "cases?case=" + caseid;
287    };
288
289})();

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.