☎ Call an expert
` ); footerMount.insertAdjacentHTML( 'beforeend', ` ` ); // footer newsletter form - hubspot embed script if (!document.getElementById('hubspot-embed-script')) { const script = document.createElement('script'); script.id = 'hubspot-embed-script'; script.src = 'https://js.hsforms.net/forms/embed/47316647.js'; script.defer = true; document.body.appendChild(script); } (function initHeaderDropdown() { const sportSelect = document.querySelector('.category-search-header #sport-selector'); const orgSearchInput = document.querySelector('.category-search-header #organization-search'); // NOTE: results container id now matches the Ares widget markup const orgResults = document.querySelector('.category-search-header #organization-search-results'); const orgIdInput = document.querySelector('.category-search-header #organization-id'); if (!orgSearchInput || !orgResults) { return; } const API_BASE = `${middleware_api}droids-library/v1`; const API_HEADERS = { 'X-Api-Key': `${middleware_api_key}`, Accept: 'application/json', }; const currentURL = new URL(window.location.href); const selectedSport = currentURL.searchParams.get('sport'); const selectedOrgId = currentURL.searchParams.get('orgId'); // Sport dropdown is unchanged - still backed by the middleware API if (sportSelect && sportSelect.dataset.loaded !== 'true') { sportSelect.dataset.loaded = 'true'; fetch(API_BASE + '/sports', { headers: API_HEADERS }) .then(response => { if (!response.ok) throw new Error('Sports request failed'); return response.json(); }) .then(data => { const sports = data && Array.isArray(data.results) ? data.results : []; const fragment = document.createDocumentFragment(); sportSelect.innerHTML = ''; sports.forEach(sport => { if (!sport || !sport.id || !sport.name) return; const option = document.createElement('option'); option.value = sport.id; option.textContent = sport.name; option.dataset.sportName = sport.name; if (String(sport.name) === String(selectedSport)) { option.selected = true; } fragment.appendChild(option); }); sportSelect.appendChild(fragment); }) .catch(error => { console.error('Sports dropdown error:', error); sportSelect.innerHTML = ''; }); sportSelect.addEventListener('change', function () { const selectedOption = this.options[this.selectedIndex]; const url = new URL(window.location.href); if (this.value) { url.searchParams.set('sport', selectedOption.dataset.sportName || ''); } else { url.searchParams.delete('sport'); } window.location.href = url.toString(); }); } // ---- Organization search: now delegated to Ares widget ---- if (orgSearchInput.dataset.loaded === 'true') { return; } orgSearchInput.dataset.loaded = 'true'; function initAresOrgSearch() { if (typeof AresFastOrganizationSearch === 'undefined') { console.error('AresFastOrganizationSearch failed to load'); return; } window.addEventListener('DOMContentLoaded', function () { }); window.bulkPdpOrganizationSearch = new AresFastOrganizationSearch({ input: '#organization-search', results: '#organization-search-results', organizationId: '#organization-id', organizationIdParameter: 'organizationId', legacyOrganizationIdParameter: 'orgId', syncUrl: true, onSelect: function (organization) { console.log('Selected organization', organization); } }); if (selectedOrgId && selectedOrgId !== '0') { fetch(API_BASE + '/organizations/' + selectedOrgId, { headers: API_HEADERS }) .then(response => { if (!response.ok) throw new Error('Organization restore failed'); return response.json(); }) .then(org => { if (org && org.name) { orgSearchInput.value = org.name; if (orgIdInput) orgIdInput.value = org.id; } }) .catch(error => { console.error('Organization restore error:', error); }); } } if (typeof AresFastOrganizationSearch === 'undefined') { const aresScript = document.createElement('script'); aresScript.src = ''; aresScript.defer = true; aresScript.onload = initAresOrgSearch; aresScript.onerror = () => console.error('Failed to load Ares organization search script'); document.body.appendChild(aresScript); } else { initAresOrgSearch(); } document.querySelector('#organization-search').addEventListener('ares:organization-selected', function (event) { var organization = event.detail.organization; // populateBulkPdp({ ...organization, logo_url: organization.artworkUrl }); }); const queryString = window.location.search; if (queryString) { document.querySelectorAll('a[href]').forEach(link => { const href = link.getAttribute('href'); if ( !href || href.startsWith('#') || href.startsWith('mailto:') || href.startsWith('tel:') || href.startsWith('javascript:') ) { return; } try { const url = new URL(href, window.location.origin); // Only modify links that belong to this store if (url.origin !== window.location.origin) { return; } currentURL.searchParams.forEach((value, key) => { if (!url.searchParams.has(key)) { url.searchParams.set(key, value); } }); link.href = url.toString(); } catch (error) { console.error('Query append error:', error); } }); } })(); document.body.classList.remove('is-customer-store'); window.isCustomerStore = false; } } catch (e) { console.error('Header/Footer render failed:', e); } } const directStoreProduct = `login` === 'product' && Boolean(new URLSearchParams(window.location.search).get('store')); if (directStoreProduct) { window.__storeDataReady.then(renderHeaderAndFooter); } else { renderHeaderAndFooter(); }