PageSourceSearch

https://cfir.science/app/multi-search/multi-search.controller.js

js cfir.science collected 2026-10-08 13:35:50 UTC 4,181 bytes, 123 lines download raw bytes

1(function() {
2    'use strict';
3
4    angular
5    .module('cfirScienceApp')
6    .controller('MultiSearchController', MultiSearchController);
7
8    MultiSearchController.$inject = ['$timeout','$scope', '$location', '$state', '$http', 'Upload',
9        'FindContext', 'FormType', 'Location', 'FindObject','MultiSearch', '$anchorScroll'];
10
11    function MultiSearchController($timeout, $scope, $location, $state, $http, Upload, FindContext,
12        FormType, Location, FindObject, MultiSearch, $anchorScroll) {
13        var vm = this;
14        vm.totalItems = null;
15        vm.numOfPages = null;
16        vm.fieldValues = null;
17        vm.currentPage = 1;
18        vm.slides = [
19            {
20                id:0,
21                image:"content/images/feature/1.jpg"
22            },
23            {
24                id:1,
25                image:"content/images/feature/3.jpg"
26            },
27            {
28                id:2,
29                image:"content/images/feature/4.jpg"
30            },
31            {
32                id:3,
33                image:"content/images/feature/5.jpg"
34            },
35            {
36                id:4,
37                image:"content/images/feature/6.jpg"
38            }
39        ]
40
41        vm.params = {
42            objectID: $location.search().objectID,
43            objectClass:$location.search().objectClass,
44            formTypeName:$location.search().formTypeName,
45            formTypeAltNames:$location.search().formTypeAltNames,
46            locationName:$location.search().locationName,
47            storagePlace:$location.search().storagePlace,
48            inventoryNumber:$location.search().inventoryNumber,
49            material:$location.search().material,
50            literature:$location.search().literature,
51            model:$location.search().model,
52            image:$location.search().image,
53            page:$location.search().page ? parseInt($location.search().page) : 0,
54            size: 20
55        };
56        vm.dontLike = ["page", "size", "image", "model"];
57        vm.currentPage = vm.params.page+1;
58
59
60        vm.result = null;
61
62        vm.search = function () {
63            vm.result = null;
64            vm.params.page = vm.currentPage - 1;
65            $location.search(vm.params);
66            like();
67            MultiSearch.query(vm.params,function (result) {
68                vm.result = result;
69                vm.totalItems = result.totalElements;
70                vm.numOfPages = result.totalPages;
71                $location.hash('');
72                $timeout(function() {
73                    $location.hash('search-results');
74                    $anchorScroll();
75                }, 200);
76            });
77            delike();
78
79        };
80        vm.openDetail = function (findObjectId) {
81            console.log(findObjectId);
82        };
83        init();
84
85        function init() {
86            if(Object.keys($location.search()).length !== 0)
87                vm.search();
88            $http.get('api/field-values').then(function(result){
89                vm.fieldValues = result.data;
90            });
91        }
92
93        function like(){
94            for (var key in vm.params) {
95                if (vm.params[key] && vm.params.hasOwnProperty(key) && vm.dontLike.indexOf(key) < 0 ) {
96                    vm.params[key] = "%"+vm.params[key]+"%";
97                }
98            }
99        }
100
101        function delike(){
102            for (var key in vm.params) {
103                if (vm.params[key] && vm.params.hasOwnProperty(key) && vm.dontLike.indexOf(key) < 0 ) {
104                    vm.params[key] = vm.params[key].substring(1,vm.params[key].length-1);
105                }
106            }
107        }
108        vm.clear = function(){
109            vm.params.objectID = null;
110            vm.params.objectClass = null;
111            vm.params.formTypeName = null;
112            vm.params.formTypeAltNames = null;
113            vm.params.locationName = null;
114            vm.params.storagePlace = null;
115            vm.params.inventoryNumber = null;
116            vm.params.material = null;
117            vm.params.literature = null;
118            vm.params.model = null;
119            vm.params.image = null;
120            $location.search(vm.params);
121        }
122    }
123})();

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.