PageSourceSearch

https://airbarrier.org/wp-content/themes/Divi-child/js/custom-member-search.js?ver=20261002040854

js airbarrier.org collected 2026-10-02 10:38:46 UTC 5,154 bytes, 107 lines download raw bytes

1function updateStateDropdown() {
2    const countrySelect = document.getElementById('country');
3    const stateSelect = document.getElementById('state');
4    const selectedCountryId = countrySelect.value;
5    stateSelect.innerHTML = '';
6    const allOption = statesData.find(item => item.text === 'All');
7    if (allOption) {
8        const option = document.createElement('option');
9        option.value = allOption.value;
10        option.textContent = allOption.text;
11        stateSelect.appendChild(option);
12    }
13    if (selectedCountryId === '1' || selectedCountryId === '2') {
14        const filteredStates = statesData.filter(state =>
15            state.country_id === selectedCountryId && state.text !== 'All'
16        );
17        filteredStates.forEach(state => {
18            const option = document.createElement('option');
19            option.value = state.value;
20            option.textContent = state.text;
21            stateSelect.appendChild(option);
22        });
23    }
24}
25
26function resetForm() {
27    document.getElementById('search-form').reset();
28    updateStateDropdown();
29    document.getElementById('search-results').innerHTML = '';
30}
31
32document.addEventListener("DOMContentLoaded", function () {
33    updateStateDropdown();
34    const form = document.getElementById("search-form");
35    const resultsContainer = document.getElementById("search-results");
36
37    form.addEventListener("submit", function (e) {
38        e.preventDefault();
39        const memberTypeSelect = document.getElementById("member_type");
40        const countrySelect = document.getElementById("country");
41        const stateSelect = document.getElementById("state");
42        const searchTextInput = document.querySelector('[name=search_text]');
43        const memberTypeLabel = memberTypeSelect.options[memberTypeSelect.selectedIndex].text;
44        const countryLabel = countrySelect.options[countrySelect.selectedIndex].text;
45        const stateLabel = stateSelect.options[stateSelect.selectedIndex].text;
46
47        document.getElementById("member_type_label").value = memberTypeLabel;
48        document.getElementById("country_label").value = countryLabel;
49        document.getElementById("state_label").value = stateLabel;
50
51        const formData = new FormData();
52        formData.append("action", "custom_member_search_ajax");
53        formData.append("search_text", searchTextInput.value);
54        formData.append("member_type", memberTypeSelect.value);
55        formData.append("country", countrySelect.value);
56        formData.append("state", stateSelect.value);
57        formData.append("member_type_label", memberTypeLabel);
58        formData.append("country_label", countryLabel);
59        formData.append("state_label", stateLabel);
60
61        resultsContainer.innerHTML = '<div class="loader" style="text-align:center;padding:20px;font-weight:bold;">Loading results...</div>';
62
63        fetch(customSearchAjax.ajaxurl, {
64            method: "POST",
65            body: formData
66        })
67            .then(res => res.text())
68            .then(html => {
69                resultsContainer.innerHTML = html;
70
71                const exactMatchGrid = document.querySelector('.grid_main_box.exact-match-section');
72                const exactMatchTable = document.querySelector('.listing_main_otr.exact-match-section');
73                const otherResultsGrid = document.querySelector('.grid_main_box.other-results-section');
74                const otherResultsTable = document.querySelector('.listing_main_otr.other-results-section');
75
76                const gridToggle = document.getElementById("gridToggle");
77                const tableToggle = document.getElementById("tableToggle");
78
79                if (gridToggle && tableToggle) {
80                    gridToggle.classList.add('active');
81                    tableToggle.classList.remove('active');
82
83                    gridToggle.addEventListener("click", () => {
84                        if (exactMatchGrid) exactMatchGrid.style.display = 'flex';
85                        if (exactMatchTable) exactMatchTable.style.display = 'none';
86                        if (otherResultsGrid) otherResultsGrid.style.display = 'flex';
87                        if (otherResultsTable) otherResultsTable.style.display = 'none';
88                        gridToggle.classList.add('active');
89                        tableToggle.classList.remove('active');
90                    });
91
92                    tableToggle.addEventListener("click", () => {
93                        if (exactMatchGrid) exactMatchGrid.style.display = 'none';
94                        if (exactMatchTable) exactMatchTable.style.display = 'block';
95                        if (otherResultsGrid) otherResultsGrid.style.display = 'none';
96                        if (otherResultsTable) otherResultsTable.style.display = 'block';
97                        tableToggle.classList.add('active');
98                        gridToggle.classList.remove('active');
99                    });
100                }
101            })
102            .catch(err => {
103                console.error("AJAX error:", err);
104                resultsContainer.innerHTML = "<p>Error loading results.</p>";
105            });
106    });
107});

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.