1function displayAddress(latitude, longitude) { 2 const geocodeUrl = `https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${latitude}&lon=${longitude}`; 3 4 fetch(geocodeUrl) 5 .then(response => response.json()) 6 .then(data => { 7 if (data && data.display_name) { 8 const address = data.display_name; 9 // document.getElementById('user-address-container').innerHTML = `<p>Your location: ${address} (Latitude: ${latitude}, Longitude: ${longitude})</p>`; 10 } else { 11 // console.error('Error fetching address:', data); 12 // document.getElementById('user-address-container').innerHTML = `<p>Could not determine address. Latitude: ${latitude}, Longitude: ${longitude}</p>`; 13 } 14 }) 15 .catch(err => console.error('Error with geocoding request:', err)); 16} 17 18 19 20function getIpBasedLocation(container, limit) { 21 fetch('https://ipinfo.io/json?token=79d8bb26476051') 22 .then(response => response.json()) 23 .then(data => { 24 const { city, region, country, loc } = data; 25 const [latitude, longitude] = loc.split(','); 26 27 //console.log(`Approximate Latitude: ${latitude}, Longitude: ${longitude}`); 28 // Display the approximate location 29 // displayAddress(latitude, longitude); 30 //document.getElementById('user-location-container').innerHTML = `<p>Your approximate location: ${city}, ${region}, ${country} (Latitude: ${latitude}, Longitude: ${longitude})</p>`; 31 // Send approximate coordinates to the server 32 sendCoordinatesToServer(container, limit, latitude, longitude); 33 }) 34 .catch(err => console.error('Error fetching IP-based location:', err)); 35} 36 37function getPreciseLocation(container, limit) { 38 if (navigator.geolocation) { 39 navigator.geolocation.getCurrentPosition( 40 function (position) { 41 // Success: Got precise location 42 const latitude = position.coords.latitude; 43 const longitude = position.coords.longitude; 44 // console.log(`Precise Latitude: ${latitude}, Longitude: ${longitude}`); 45 // Display the precise location 46 // displayAddress(latitude, longitude); 47 //document.getElementById('user-location-container').innerHTML = `<p>Your precise location: Latitude ${latitude}, Longitude ${longitude}</p>`; 48 // Send precise coordinates to the server 49 sendCoordinatesToServer(container, limit, latitude, longitude); 50 }, 51 function (error) { 52 // If the user denies the geolocation prompt, the fallback to IP-based location is already handled 53 console.warn("Could not get precise location. Using IP-based location instead."); 54 } 55 ); 56 } else { 57 console.error("Geolocation is not supported by this browser."); 58 container.innerHTML = 59 `<p>Geolocation is not supported by this browser.</p>`; 60 } 61} 62 63function sendCoordinatesToServer(container, limit, latitude, longitude) { 64 const xhr = new XMLHttpRequest(); 65 const params = `action=get_closest_sites&latitude=${latitude}&longitude=${longitude}&limit=${limit}`; 66 67 xhr.open('POST', spp_ajax_var.ajaxurl, true); 68 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 69 70 xhr.onreadystatechange = function () { 71 if (xhr.readyState === 4 && xhr.status === 200) { 72 // Handle the response from the server 73 container.innerHTML = xhr.responseText; 74 75 var elem = document.querySelector('#closest-sites-container .supernova-pp--agent-cards'); 76 77 var flkty = new Flickity(elem, { 78 contain: true, 79 freeScroll: true, 80 wrapAround: false, 81 groupCells: 1, 82 cellAlign: 'center', 83 pageDots: false, 84 prevNextButtons: true 85 }); 86 87 // Equal height for all cards (hack) 88 Flickity.prototype._createResizeClass = function () { 89 this.element.classList.add('flickity-resize'); 90 }; 91 92 Flickity.createMethods.push('_createResizeClass'); 93 94 var resize = Flickity.prototype.resize; 95 Flickity.prototype.resize = function () { 96 this.element.classList.remove('flickity-resize'); 97 resize.call(this); 98 this.element.classList.add('flickity-resize'); 99 }; 100 } else if (xhr.readyState === 4) { 101 container.innerHTML = '<p>Error fetching closest sites.</p>'; 102 } 103 }; 104 105 xhr.send(params); 106} 107 108 109 110document.addEventListener('DOMContentLoaded', function () { 111 if (document.querySelector('.pp--subsite')) { 112 localStorage.setItem('pp_microsite_id', spp_ajax_var.siteId); 113 //console.log("Site ID in localStorage:", localStorage.getItem("pp_microsite_id")); 114 if (document.querySelector('[data-market]')) { 115 localStorage.setItem('pp_microsite_market', document.querySelector('[data-market]').dataset.market); 116 //console.log("Market in localStorage:", localStorage.getItem("pp_microsite_market")); 117 } 118 } 119 120 if (document.getElementById('closest-sites-container')) { 121 let container = document.getElementById('closest-sites-container'); 122 let limit = 32; // Maximum number of sites/microsites/agents to fetch 123 124 // Fetch IP-based location immediately 125 getIpBasedLocation(container, limit); 126 127 // Then attempt to get precise geolocation 128 getPreciseLocation(container, limit); 129 } 130 131 132 133 if (document.querySelector('.supernova-below-menu')) { 134 const menu = document.querySelector('#menu-below-header-menu'); 135 const hoverEffect = document.createElement('div'); 136 hoverEffect.classList.add('supernova-pp-menu-hover'); 137 menu.appendChild(hoverEffect); 138 139 const menuItems = document.querySelectorAll('#menu-below-header-menu li'); 140
141 menuItems.forEach(item => { 142 item.addEventListener('mouseenter', function (e) { 143 const rect = item.getBoundingClientRect(); 144 const offsetLeft = item.offsetLeft; 145 const itemWidth = rect.width; 146 147 hoverEffect.style.width = `${itemWidth}px`; 148 hoverEffect.style.transform = `translateX(${offsetLeft}px)`; 149 }); 150 }); 151 152 menu.addEventListener('mouseleave', function () { 153 hoverEffect.style.width = `0`; 154 }); 155 } 156 157 if (document.querySelector('.pp--subsite') && document.getElementById('pp-agent-name')) { 158 const menuLogoLink = document.querySelector('.menu-logo-large'); 159 const textNode = document.createTextNode(document.getElementById('pp-agent-name').dataset.name); 160 161 const textContainer = document.createElement('div'); 162 textContainer.appendChild(textNode); 163 textContainer.classList.add('pp--tagline'); 164 165 menuLogoLink.appendChild(textContainer); 166 } 167 168 169 170 // 171 if (document.querySelector('.pp--subsite') && document.querySelector('.supernova-below-menu')) { 172 let container = document.querySelector('.supernova--content'); 173 let stickySidebar = document.querySelector('.supernova-below-menu'); 174 let sticky = new Sticky('.supernova-below-menu'); 175 } 176 177 // 178 if (document.querySelector('.populate-properties select')) { 179 document.querySelector('.populate-properties select').addEventListener('change', function () { 180 //console.log('Selected value:', this.value); 181 document.querySelector('.branch-email input[type="email"]').value = this.value; 182 document.querySelector('.branch-email input[type="email"]').dataset.email = this.value; 183 }); 184 } 185}); 186 187/* 188document.addEventListener("DOMContentLoaded", (event) => { 189 const menuLogoLink = document.querySelector('.menu-logo-large'); 190 const textNode = document.createTextNode('LOCAL KNOWLEDGE. NATIONWIDE.'); 191 192 const textContainer = document.createElement('div'); 193 textContainer.appendChild(textNode); 194 textContainer.classList.add('pp--tagline'); 195 196 menuLogoLink.appendChild(textContainer); 197}); 198/**/ 199 200function supernovaPPAgentFinder() { 201 let input, 202 filter, 203 ul, 204 li, 205 a, 206 i, 207 txtValue, 208 locationValue, 209 areasValue; 210 211 input = document.getElementById("myInput"); 212 filter = input.value.toUpperCase(); 213 ul = document.querySelector('#closest-sites-container .supernova-pp--agent-cards'); 214 li = ul.querySelectorAll('.supernova-pp--agent-card'); 215 216 for (i = 0; i < li.length; i++) { 217 a = li[i]; 218 //txtValue = a.textContent || a.innerText; 219 txtValue = a.dataset.title; 220 locationValue = a.dataset.location; 221 areasValue = a.dataset.areas; 222 223 if ( 224 txtValue.toUpperCase().indexOf(filter) > -1 || 225 locationValue.toUpperCase().indexOf(filter) > -1 || 226 areasValue.toUpperCase().indexOf(filter) > -1 227 ) { 228 li[i].style.display = ''; 229 } else { 230 li[i].style.display = 'none'; 231 } 232 233 // Reinitialize Flickity to adjust to the filtered items 234 let elem = document.querySelector('#closest-sites-container .supernova-pp--agent-cards'); 235 Flickity.data(elem).reloadCells(); 236 Flickity.data(elem).resize(); 237 } 238} 239 240 241 242jQuery(document).ready(function () { 243 jQuery('.expandable-box').hover(function (e) { 244 if (jQuery(this).hasClass('open')) { 245 jQuery('.expandable-box.out').not(jQuery(this)).removeClass('out'); 246 jQuery(this).removeClass('open'); 247 } 248 else { 249 jQuery('.expandable-box').not(jQuery(this)).addClass('out').removeClass('open'); 250 jQuery(this).addClass('open').removeClass('out'); 251 } 252 }); 253});
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.