PageSourceSearch

https://www.bayhealth.org/assets/js/Foundation/Search/SiteSearchFacet.js?q=1143

js bayhealth.org collected 2026-09-24 17:41:58 UTC 4,757 bytes, 131 lines download raw bytes

1function CallSearchFacet(sender, comeFromFind, comeFromPageLoad) {
2    let elements;
3
4    //If All Option was clicked
5    if (sender.id === 'all') {
6        //Active the button
7        if (!sender.classList.contains('active')) {
8            sender.classList.add('active');
9        }
10        //remove Active class from ALL elements different from ALL
11        elements = document.querySelectorAll('a.active');
12        for (i = 0; i < elements.length; i++) {
13            var element = elements[i];
14            if (element.id !== 'all') {
15                element.classList.remove("active");
16            }
17        }
18        if (!comeFromFind) {
19
20            //Call the API again with the normal query, this parameter is being used to say if the call come from Facet
21            FillSearchSite(true, undefined, false);
22
23        }
24        processAjaxDataSite(true, true, "facets");
25        processAjaxDataSite("all", false, "facets");
26    }
27
28    //Options Clicked != ALL
29    else {
30        //remove Active class from ALL Option
31        var elementAllFacet = document.getElementById('all');
32        elementAllFacet.classList.remove('active');
33
34        if (sender.classList.contains('active')) {
35            sender.classList.remove('active');
36        }
37        else {
38            sender.classList.add('active');
39        }
40
41        //Get all elements that have class active
42        elements = document.querySelectorAll('a.active');
43
44        //Need to check if has any element selected, if not, we have to select automaticaly the ALL and call the API using the original QUERY
45        if (elements.length === 0) {
46            elementAllFacet = document.getElementById('all');
47            elementAllFacet.classList.add('active');
48            processAjaxDataSite(true, true, "facets");
49            processAjaxDataSite("all", false, "facets");
50            FillSearchSite(true, undefined, false);
51        }
52        //Logic to create the Query and pass to the Search Page, I take all active options and create the query.
53        else {
54            var auxNewQuery = "";
55            var auxFacetTemplates = ""
56            processAjaxDataSite(true, true, "facets");
57            for (i = 0; i < elements.length; i++) {
58                if (i === elements.length - 1) {
59                    auxNewQuery = auxNewQuery + "_templatename:\"" + elements[i].getAttribute("result-field-name") + "\"";
60                    //we have to clean 
61                    processAjaxDataSite(true, true, "all");
62                    auxFacetTemplates = auxFacetTemplates + elements[i].getAttribute("result-field-name");
63                }
64                else {
65                    auxNewQuery = auxNewQuery + "_templatename:\"" + elements[i].getAttribute("result-field-name") + "\" OR ";
66                    auxFacetTemplates = auxFacetTemplates + elements[i].getAttribute("result-field-name") + "|";
67                }
68            }
69
70            processAjaxDataSite(auxFacetTemplates, false, "facets");
71
72            auxNewQuery = "(" + auxNewQuery + ") AND _latestversion:true AND is_crawlable_b:true";
73
74            //Call API passing the Query.
75            FillSearchSite(true, auxNewQuery, false);
76        }
77    }
78}
79
80function FillFacetByQueryParameter(facetsSelected) {
81
82
83    if (facetsSelected != "all") {
84
85        var splitedFacets = facetsSelected.split("|");
86
87        var newQueryAux = "";
88
89        var auxFacetNew = "";
90
91
92
93        $(".links-container a").removeClass("active");
94
95
96
97        for (i = 0; i < splitedFacets.length; i++) {
98            $("[result-field-name='" + splitedFacets[i] + "']").addClass("active");
99        }
100
101
102
103        var elementsfacets = $(".links-container a.active");
104
105
106
107        for (i = 0; i < elementsfacets.length; i++) {
108            if (i === elementsfacets.length - 1) {
109                newQueryAux = newQueryAux + "_templatename:\"" + elementsfacets[i].getAttribute("result-field-name") + "\"";
110                //we have to clean 
111                processAjaxDataSite(true, true, "all");
112                auxFacetNew = auxFacetNew + elementsfacets[i].getAttribute("result-field-name");
113            }
114            else {
115                newQueryAux = newQueryAux + "_templatename:\"" + elementsfacets[i].getAttribute("result-field-name") + "\" OR ";
116                auxFacetNew = auxFacetNew + elementsfacets[i].getAttribute("result-field-name") + "|";
117            }
118        }
119
120        processAjaxDataSite(auxFacetNew, false, "facets");
121
122        newQueryAux = "(" + newQueryAux + ") AND _latestversion:true AND is_crawlable_b:true";
123
124        //Call API passing the Query.
125        FillSearchSite(true, newQueryAux, false);
126
127    }
128
129
130
131}

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.