PageSourceSearch

https://www.trustnet.com/ingredients/scripts/search.js?rnd=8dfc2ff3-b9d1-4f91-babb-4fad9328a94a

js trustnet.com collected 2026-10-02 03:15:20 UTC 6,990 bytes, 211 lines download raw bytes

1
2/*When clicking the 'clear' button INSIDE the dropdowns (inside FE_PRT_SelectDropdown)*/
3document.querySelectorAll('.dropdown-menu .clear').forEach(clearButton => {
4
5    clearButton.addEventListener('click', function (e) {
6
7        e.preventDefault();
8
9        /*Clear all checked checkboxes*/
10        this.parentNode.querySelectorAll('.filter-list input:checked').forEach(x => { x.checked = false; });
11
12        /*Show all inputs*/
13        this.parentNode.querySelectorAll('.filter-list li').forEach(x => { $(x).show(); });
14
15        /*Remove the inner-filter search*/
16        var filterSearch = this.parentNode.querySelector('input[name="searchString"]');
17        if (filterSearch != null) {
18            filterSearch.value = '';
19        }
20
21        /*Update dropdown button text*/
22        UpdateDropdownButtonText(this.parentNode.querySelector('.filter-list input'));
23
24        /*Resubmit the form (if it's not on homepage)*/
25        var form = this.parentNode.querySelector('.filter-list input').form;
26        if (form.classList.contains('submit-on-change')) {
27
28            resetPagination(form);
29            $(form).submit();
30        }
31
32    });
33});
34
35
36
37
38
39function UpdateDropdownButtonText(checkbox) {
40    /*Get button belonging to filter list*/
41
42    var button;
43
44    var buttonId = checkbox.dataset.buttonId;
45    if (buttonId != null) {
46        button = document.getElementById(buttonId);
47    }
48
49    if (button == null) {
50        button = document.getElementById(checkbox.dataset.form + "-" + checkbox.getAttribute('name') + '-button');
51    }
52
53    if (button == null) {
54        button = document.getElementById(checkbox.getAttribute('name') + '-button');
55    }
56
57    if (button == null) {
58        return;
59    }
60
61    if (!button.classList.contains('show-selected-options')) {
62        return;
63    }
64
65    /*Get list of all checked items within filter list*/
66    var selected = [];
67    Array.from(checkbox.closest('.filter-list').querySelectorAll('li input:checked')).forEach(function () {
68
69        var label = checkbox.parentNode.querySelector('label').dataset.text;
70        selected.push(label);
71    });
72    /*Combine names to create label text*/
73    var buttonText = 'All';
74    if (selected.length == 1) {
75        buttonText = selected[0];
76    } else if (selected.length > 1) {
77        buttonText = 'Multiple selected';
78    }
79
80    button.textContent = buttonText;
81}
82
83/*When clicking a checkbox inside a filter*/
84document.addEventListener('change', function (e) {
85    if (e.target.closest(".fe_cmp_chartingtool") != null) {
86        return;
87    }
88
89    if (e.target.classList.contains('js--dropdown-search__multi-select')) {
90        /*Update button text*/
91        UpdateDropdownButtonText(e.target);
92
93        if (e.target.form != null) {
94            /*Resubmit form on search page. Have to use jquery for the data-ajax to work*/
95            if (e.target.form.classList.contains('submit-on-change')) {
96                resetPagination(e.target.form);
97                setTimeout(function () {
98                    $(e.target.form).submit();
99                }, 1);
100            }
101        }
102    }
103});
104
105
106//For searching WITHIN a filter
107$(".filter-search-filter").submit(function (e) {
108
109    e.preventDefault();
110
111    //Get filter search string
112    var searchString = $(this).find("input[name='searchString']").val().toLowerCase();
113
114    //Get all inputs within this list
115    var allItems = $(this).closest('.dropdown-menu').find(".filter-list").find("li");
116
117    //If no search string, show them all
118    if (searchString == "") {
119        allItems.show();
120        return;
121    }
122
123    //Otherwise hide them all...
124    allItems.hide();
125
126
127    //... then show the ones that match
128    var matchingItems = allItems.filter(function (x) { return $(this).find("input").val().toLowerCase().includes(searchString); });
129    matchingItems.show();
130
131});
132
133function escapeHtml(text) {
134    if (!text) return '';
135    var map = {
136        '&': '&',
137        '<': '&lt;',
138        '>': '&gt;',
139        '"': '&quot;',
140        "'": '&#039;'
141    };
142    return text.toString().replace(/[&<>"']/g, function (m) { return map[m]; });
143}
144
145function FilterMe(facet, name, hideLabelText = false) {
146    var filterList = document.getElementById(name + '-filter-list');
147    FilterListByFacets(facet, filterList, hideLabelText);
148}
149
150function FilterListByFacets(facet, filterList, hideLabelText = false) {
151
152    if (filterList == null || facet == null) {
153        return;
154    }
155
156    //Get items that we checked prior to search
157    var previouslyChecked = [...filterList.querySelectorAll("li input:checked")].map(x => x.value);
158
159    var formId = filterList.dataset.parentFormId;
160    var name = filterList.dataset.name;
161
162    var filterHtml = "";
163    facet.forEach(function (facet) {
164
165        var item = facet.value;
166
167        var text = item;
168        if (item.includes("|")) {
169            text = item.split("|")[0];
170
171            if (name == "AssetLinkList" || name == "GroupLinkList" || name == "SectorLinkList" || name == "FundList") {
172                text = item.split("|")[1];
173            }
174        }
175
176        var labelText = !hideLabelText ? text : "";
176 //For hiding text of Adviser Fund Index to replace with images
177
178        var isItemChecked = previouslyChecked.includes(item);
179
180        if (!isItemChecked) {
181            isItemChecked = previouslyChecked.some(c => c.includes("|" + item)) || previouslyChecked.some(c => c.includes(item + "|"));
182        }
183
184        var checked = isItemChecked ? "checked" : "";
185
186        var postPipe = "";
187        var prePipe = "";
188        if (item.includes("|")) {
189            prePipe = item.substring(0, item.indexOf("|"));
190            postPipe = item.substring(item.indexOf("|") + 1);
191        }
192
193        var escapedFormId = escapeHtml(formId);
194        var escapedName = escapeHtml(name);
195        var escapedItem = escapeHtml(item);
196        var escapedText = escapeHtml(text);
197        var escapedLabelText = escapeHtml(labelText);
198        var escapedPrePipe = escapeHtml(prePipe);
199        var escapedPostPipe = escapeHtml(postPipe);
200        var escapedItemValue = escapeHtml(item.replaceAll("'", "''"));
201
202        filterHtml += `<li class="list-group-item">
203                <input class="fund-search-filter-checkbox js--dropdown-search__multi-select btn-check" id="${escapedFormId}-${escapedName}-${escapedItem}" data-button-id="${escapedFormId}-${escapedName}-button" name="${escapedName}" value="${escapedItemValue}" form="${escapedFormId}" data-pre-pipe="${escapedPrePipe}" data-post-pipe="${escapedPostPipe}" ${checked} type="checkbox" />
204                <label for="${escapedFormId}-${escapedName}-${escapedItem}" data-text="${escapedText}"> ${escapedLabelText} <span class="filter-counter">(${facet.count})</span></label>
205            </li>`;
206    });
207
208    filterList.innerHTML = filterHtml;
209}
210
211

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.