PageSourceSearch

https://my.nmbi.ie/nmbi-search-the-register-lib.js?v=20260924065913000

js nmbi.ie collected 2026-09-24 18:59:35 UTC 11,238 bytes, 219 lines download raw bytes

1if (typeof NMBI === "undefined") { NMBI = {}; }
2if (typeof NMBI.RegisteredMembers === "undefined") { NMBI.RegisteredMembers = {}; }
3
4(function() {
5    /**
6     * NMBI.RegisteredMembers
7     **/
8
9    "use strict";
10
11    let _detailsContainer, _detailsModalLoader, _reCaptchaContainer, 
12        _recordCountContainer, _pageNumberContainer, _searchButton, _searchForm, 
13        _viewGrid, _viewGridObserver;
14
15    const _interceptXMLHttpRequest = XMLHttpRequest.prototype.open;
16
17    const _initialise = function () {
18
19        try {
20            const _detailsContainer = document.getElementById('detailsContainer');
21            const _detailsModalLoader = document.getElementById('detailsModalLoader');
22            const _reCaptchaContainer = document.getElementById('reCaptchaContainer');
23            const _recordCountContainer = document.getElementById('recordCountContainer');
24            const _pageNumberContainer = document.getElementById('4').closest('li.entitylist-filter-option-group');
25            const _searchButton = document.querySelector('button.btn-entitylist-filter-submit');
26            const _searchForm = document.querySelector('.card-body');
27            const _firstName = document.getElementById('1');
28            const _lastName = document.getElementById('2');
29            const _registrationNumber = document.getElementById('3');
30            const _pageNumber = document.getElementById('4');
31
32            document.querySelectorAll('div.row > div.col-lg-3').forEach((item, index) => { item.className = "col-lg-5 filter-vertical"; });
33            document.querySelectorAll('div.row > div.col-lg-9').forEach((item, index) => { item.className = "col-lg-7"; });
34            document.querySelectorAll('li.entitylist-filter-option-group').forEach((item, index) => { item.classList.remove('list-inline-item'); });
35            document.querySelectorAll('div.view-empty').forEach((item, index) => { item.innerHTML = document.getElementById("searchTheRegisterContent").innerHTML; });
36            document.querySelectorAll('input.has-tooltip').forEach((item, index) => { 
37                item.title = item.id == "3" 
38                    ? "Enter one or more registration numbers separated by commas. Combine with forename and/or last name to narrow your search results." 
39                    : "Enter the full or partial name. Combine with a registration number to narrow your search results.";
40                item.style.height = item.parentElement.clientHeight + "px"; 
41            });
42            document.querySelector('#entitylist-filters li:first-child').style.marginBottom = "30px";
43
44            _firstName.maxLength = 50; _firstName.onclick = function(event) { _pageNumber.value = "1"; };
45            _lastName.maxLength = 50; _lastName.onclick = function(event) { _pageNumber.value = "1"; };
46            _registrationNumber.maxLength = 200; _registrationNumber.onclick = function(event) { _pageNumber.value = "1"; };
47
48            _detailsContainer.onload = function (event) { _detailsModalLoader.style.display = "none"; };
49            _pageNumberContainer.style.display = "none";
50            _reCaptchaContainer.style.display = 'block';
51            _searchButton.disabled = true;
52            _searchButton.onclick = function(event) { 
53                window.reCaptchaEnabled = true;
54                _reCaptchaContainer.style.display = "none"; 
55                _recordCountContainer.innerHTML = "<p>&nbsp;</p>";
56            };
57            _searchForm.insertBefore(_reCaptchaContainer, _searchForm.lastElementChild);
58            _searchForm.insertBefore(_recordCountContainer, _searchForm.lastElementChild);
59
60            let _viewGrid = document.querySelector('div.view-grid');
61            let _viewGridObserver = new MutationObserver((mutationsList) => {
62                for (const mutation of mutationsList) {
63                    if (mutation.type === 'childList') {
64                        //document.querySelectorAll('table.table-fluid').forEach((item, index) => { item.className = "table table-striped"; });
65                        document.querySelectorAll('table.table-fluid').forEach((item, index) => { item.className = "table"; });
66                        document.querySelectorAll('td[data-attribute="cs_fullname"]').forEach((item, index) => { item.setAttribute('data-no-label', ''); });
67                        document.querySelectorAll('td[aria-label="action menu"]').forEach((item, index) => { 
68                            item.outerHTML = '<td class="text-end" data-no-label><button class="btn btn-default" title="View details" aria-label="View details" style="cursor: pointer;">View details</button></td>';
69                        });
70                        document.querySelectorAll('div.view-grid a[href*="view-the-registrant"]').forEach((item, index) => { 
71                            let href = item.href;
72                            let register = document.querySelector('input[name="0"]:checked');
73                            if (register && register.value == 1) {
74                                href = href.replace('view-the-registrant', 'view-the-candidate');
75                            }
76                            item.onclick = function(event) { _showDetail
76sModal(href); };
77                            item.style.cursor = 'pointer';
78                            item.removeAttribute('href');
79                            let btn = item.parentElement.parentElement.querySelector('button');
80                            btn.onclick = function(event) { _showDetailsModal(href); };
81                        });
82                        _handlePaging();
83                    }
84                }
85            });
86            _viewGridObserver.observe(_viewGrid, { childList: true, subtree: true });
87
88            XMLHttpRequest.prototype.open = function(method, url) { //intercept the call
89                this.addEventListener("load", function() {
90                    if (url.includes("_services/entity-grid-data.json")) {
91                        let recordCount = JSON.parse(this.response).ItemCount;
92                        if (recordCount > 0) {
93                            _recordCountContainer.innerHTML = "<p><b>We found " + recordCount + " result(s) that match your search criteria.</b></p>";
94                        }
95                        else {
96                            _recordCountContainer.innerHTML = _searchButton.disabled == true ? "" : "<p><b>We found no results that match your search criteria.</b></p>";
97                        }
98                    }
99                });
100                _interceptXMLHttpRequest.apply(this, arguments);
101            };
102
103
104            /**
105             * reCAPTCHA 
106             **/
107            window.onCaptchaExpired = function () {
108                if (!window.reCaptchaEnabled) {
109                    _searchButton.disabled = true;
110                    window.reCaptchaToken = "";
111                }
112            };
113            window.onCaptchaError = function () {
114                if (!window.reCaptchaEnabled) {
115                    _searchButton.disabled = true;
116                    window.reCaptchaToken = "";
117                }
118            };
119            window.onCaptchaSuccess = function (token) {
120                _searchButton.disabled = false;
121                window.reCaptchaToken = token;
122            };
123            window.reCaptchaToken = "";
124            window.reCaptchaEnabled = false;
125
126
127
128        }
129        catch (e) {
130            throw e;
131        }
132    }
133
134    const _handlePaging = function () {
135
136        let pageCount = 0, pageNumber = document.getElementById('4');
137        if (pageNumber != null) 
138        {
139            pageNumber.value = pageNumber.value == "" ? 1 : pageNumber.value;
140
141            let pagingItems = Array.from(document.querySelectorAll('a.page-link'));
142            if (pagingItems != null && pagingItems.length > 0) 
143            {
144                pageCount = pagingItems.length - 2;
145                pagingItems.forEach((item, i) => {
146                    if (i == 0)
147                    {
148                        if (pageNumber.value == 1) 
149                        {
150                            item.parentElement.className = "page-item disabled";
151                            item.setAttribute('aria-disabled', 'true');
152                            item.removeAttribute('data-page');
153                        }
154                        else 
155                        {
156                            item.parentElement.className = "page-item";
157                            item.removeAttribute('aria-disabled');
158                            item.setAttribute('data-page', +pageNumber.value - 1);
159                        }
160                    }
161                    else if (i == pageCount + 1)
162                    {
163                        if (pageNumber.value == pageCount) 
164                        {
165                            item.parentElement.className = "page-item disabled";
166                            item.setAttribute('aria-disabled', 'true');
167                            item.removeAttribute('data-page');
168                        }
169                        else 
170                        {
171                            item.parentElement.className = "page-item";
172                            item.removeAttribute('aria-disabled');
173                            item.setAttribute('data-page', +pageNumber.value + 1);
174                        }
175                    }
176                    else if (i == pageNumber.value)
177                    {
178                        item.parentElement.className = "page-item active";
179                        item.setAttribute('data-page', i);
180                    }
181                    else
182                    {
183                        item.parentElement.className = "page-item";
184                        item.setAttribute('data-page', i);
185                    }
186
187                    item.onclick = function(event) {
188                        event.preventDefault();
189                        event.stopImmediatePropagation();
190                        pageNumber.value = item.getAttribute('data-page');
191                        document.querySelector("button.btn-entitylist-filter-submit").click();
192                    }
193                });
194            }
195        }
196    };
197
198    const _hideDetailsModal = function () {
199        const iframe = document.getElementById('detailsContainer');
200        iframe.removeAttribute('src');
201        document.getElementById('detailsModal').style.display = "none";
202        document.getElementById('detailsModalLoader').style.display = "none";
203    };
204
205    const _showDetailsModal = function (href) {
206        const iframe = document.getElementById('detailsContainer');
207        iframe.src = href;
208        document.getElementById('detailsModal').style.display = 'flex';
209        document.getElementById('detailsModalLoader').style.display = 'block';
210    };
211
212    /**
213     * Public members
214     **/
215    this.Initialise = _initialise;
216    this.HideDetailsModal = _hideDetailsModal;
217    this.ShowDetailsModal = _showDetailsModal;
218
219}).apply(NMBI.RegisteredMembers);

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.