PageSourceSearch

https://www.leadsnearby.com/wp-content/plugins/lnb-v8-scheduler/dist/js/v8-formatter-min.js?ver=1786724750

js leadsnearby.com collected 2026-09-24 13:04:41 UTC 13,511 bytes, 2 lines download raw bytes

1"use strict";const v8Formatter={v8Forms:document.querySelectorAll(".v8Form__form"),init:function(){for(let e of this.v8Forms){let t=e.querySelectorAll("[data-logic]");this.showConditionalFields(t,e),this.customRadio(e);let n=e.querySelector('input[type="tel"]');n.addEventListener("keyup",this.formatPhoneField(n)),this.addInlineCalendar(e),this.formatFileUpload(e);let i=e.querySelector(".v8-zip-lookup > input");if(i){let e=document.querySelector(".v8Form__bottom-nav");e&&(e.style.display="none"),i.addEventListener("input",e=>this.lookupZipCode(i))}}this.getReferrer()},lookupZipCode:async function(e){/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)&&"geolocation"in navigator&&e&&window.addEventListener("load",()=>{confirm("Would you like to share your location to automatically detect your zip code?")?navigator.geolocation.getCurrentPosition(async t=>{let{latitude:n,longitude:i}=t.coords;console.log("Latitude: ",n,"Longitude: ",i);try{let t=await fetch(`https://api.bigdatacloud.net/data/reverse-geocode-client?latitude=${n}&longitude=${i}&localityLanguage=en`),l=await t.json(),a=l.postcode||l.localityInfo.administrative[0].isoName;if(!a)return void console.error("Unable to detect zip code from location.");e.value=a,console.log("Auto-detected ZIP Code: ",a),e.dispatchEvent(new Event("change"))}catch(e){return void console.error("Error during geolocation or reverse geocoding: ",e)}},e=>{console.warn(`Geolocation Error (${e.code}): ${e.message}`)}
1):console.log("Geolocation denied by the user.")});let t=e.value.trim(),n=document.querySelector(".v8Form__bottom-nav");if(n&&(n.style.display="none"),t.length<5)return;if(!/^(\d{5}(?:-\d{4})?)|([A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d)$/.test(t)){console.warn("Invalid ZIP or Postal Code.");let t=document.createElement("div");return t.classList.add("v8-fail-message"),t.innerHTML="<strong>Error!</strong> Please enter a valid ZIP or Postal Code.",e.parentElement.insertBefore(t,e.parentElement.firstChild),void(n&&(n.style.display="none"))}console.log("Looking up ZIP or Postal Code:",t);let i=document.createElement("div");i.classList.add("v8-spinner"),i.innerHTML='<div class="v8-spinner-container"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>';let l=document.querySelector(".v8Form");l?l.appendChild(i):e.parentElement.appendChild(i);try{let l=await fetch(`${wpRest.siteUrl}/wp-content/plugins/lnb-v8-scheduler/src/api/st-zip-lookup.php?frontEndLookup=true&zip=${encodeURIComponent(t)}`),a=await l.json();if(e.parentElement.querySelectorAll(".v8-success-message, .v8-fail-message").forEach(e=>e.remove()),l.ok&&"success"===a.status){console.log("Service zones data received:",a);let t=document.createElement("div");t.classList.add("v8-success-message"),t.innerHTML=`<strong>Success!</strong> ${a.message}`,e.parentElement.insertBefore(t,e.parentElement.firstChild),n&&(n.style.display="block")}else{console.log("Service is not available or unexpected response format.");let t=document.createElement("div");t.classList.add("v8-fail-message"),t.innerHTML="<strong>Sorry!</strong> Service is not available in this area. Please try another ZIP or Postal Code.",e.parentElement.insertBefore(t,e.parentElement.firstChild),n&&(n.style.display="none")}}catch(t){console.error("Error during zip code lookup:",t);let n=document.createElement("div");n.classList.add("v8-fail-message"),n.innerHTML="<strong>Error!</strong> Unable to perform the lookup at the moment.",e.parentElement.insertBefore(n,e.parentElement.firstChild)}finally{i.remove()}},formatPhoneField:(e,t)=>(async function(t){if(!e.value)return e.value;let n=e.value.replace(/\D/g,"").match(/^(\d{3})(\d{3})(\d{4})$/);if(n){t.target.value=`(${n[1]}) ${n[2]}-${n[3]}`;let i=e.closest(".v8-cust-lookup");if(i){console.log("Triggering ServiceTitan lookup for phone number:",n[1]+n[2]+n[3]);let e=n[1]+n[2]+n[3],t=document.createElement("div"),l=document.createElement("div"),a=document.createElement("div");t.classList.add("v8-spinner"),t.innerHTML='<div class="v8-spinner-container"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>';let o=document.querySelector(".v8Form");o?o.appendChild(t):i.appendChild(t);try{let n=await fetch(`${wpRest.siteUrl}/wp-content/plugins/lnb-v8-scheduler/src/api/st-cust-lookup.php?frontEndLookup=true&phone=${e}`),o=await n.json(),r=i.querySelector(".v8-fail-message"),d=i.querySelector(".v8-success-message");r&&r.remove(),d&&d.remove();let s=document.querySelector(".v8Form__returning");if(n.ok&&o&&o.data&&o.data.length>0){console.log("Customer data received:",o),s&&(s.value="true");let e=(e,t)=>e.substring(0,t)+"****";if(o.data.length>1){let t=document.createElement("div");t.classList.add("v8-address-modal");let n=document.createElement("div");n.classList.add("v8-address-modal-content"),n.innerHTML="<h2>Select Your Service Address</h2>";let i=document.createElement("ul");i.classList.add("v8-address-list"),o.data.forEach(n=>{let l=document.createElement("li"),a=e(n.name,3),o=e(n.address.street,7);l.innerHTML=`${a}, ${o}, ${n.address.zip}`,l.addEventListener("click",()=>{let e=document.getElementById("given-name"),i=document.getElementById("family-name"),l=document.getElementById("address1"),a=document.getElementById("address2"),o=document.getElementById("city"),r=document.getElementById("zip");if(e&&i){let t=n.name.split(" ");e.value=t[0],i.value=t.length>1?t[t.length-1]:""}l&&(l.value=n.address.street),a&&(a.value=n.address.unit||""),o&&(o.value=n.address.city),r&&(r.value=n.address.zip),t.remove()}),i.appendChild(l)}),n.appendChild(i);
1let l=document.createElement("button");l.innerText="Close",l.classList.add("v8-modal-close"),l.addEventListener("click",()=>t.remove()),n.appendChild(l),t.appendChild(n),document.body.appendChild(t)}else{let e=o.data[0];l.classList.add("v8-success-message"),l.innerHTML="<strong>Congratulations!</strong> We found your information in our system. Please review and confirm.",i.insertBefore(l,i.firstChild);let t=document.getElementById("given-name"),n=document.getElementById("family-name"),a=document.getElementById("address1"),r=document.getElementById("address2"),d=document.getElementById("city"),s=document.getElementById("zip");t&&(t.value=e.name.split(" ")[0]),n&&(n.value=e.name.split(" ").slice(-1)[0]),a&&(a.value=e.address.street),r&&(r.value=e.address.unit||""),d&&(d.value=e.address.city),s&&(s.value=e.address.zip)}}else console.log("No customer data found, form can be filled manually."),s&&(s.value="false"),a.classList.add("v8-fail-message"),a.innerHTML="<strong>Oops! We didn’t find a match for that phone number.</strong> No problem! You can try another number, or simply continue filling out the form below — it only takes a sec!",i.insertBefore(a,i.firstChild)}catch(e){console.error("Error during customer lookup:",e)}finally{t.remove()}}}return null}),showConditionalFields(e,t){for(let n of e){n.style.display="none";let e=n.dataset.logic.split("-"),i=t.querySelector(`[name="input_${e[0]}"]`),l=i.parentElement.parentElement.querySelector(`[value="${e[2]}"]`);"checkbox"===i.type&&l.addEventListener("change",function(e){this.checked?n.style.display="inline-block":n.style.display="none"}),"radio"===i.type&&l.addEventListener("change",function(e){i.parentElement.querySelector("input[type=radio]:checked"),l.checked?n.style.display="inline-block":n.style.display="none"})}},customRadio:function(e){e.addEventListener("click",function(e){if(e.target.classList.contains("v8Fields__radio-single")){for(let t of e.target.parentElement.children)t.classList.remove("v8-radio-selected"),t.querySelector("input").checked=!1;e.target.classList.add("v8-radio-selected"),e.target.querySelector("input").checked=!0}})},formatFileUpload:function(e){let t=e.querySelectorAll('input[type="file"]');for(let e of t){let t=new FileReader,n=e.parentElement.querySelector(".v8Fields__fileupload-preview"),i=e.parentElement.querySelector(".v8Fields__fileupload-preview--close");t.addEventListener("load",function(e){new Image,n.style.backgroundImage=`url(${t.result})`},!1),e.addEventListener("change",function(e){if(-1!==e.target.files[0].type.search("image"))t.readAsDataURL(e.target.files[0]);else if("application/pdf"===e.target.files[0].type){let e=document.createElement("fa-icon");e.setAttribute("icon","file-pdf"),e.style.fontSize="30px",e.style.textAlign="center",e.style.padding="5% 0",e.style.display="inherit",n.appendChild(e)}}),i.addEventListener("click",function(t){e.value=null,n.style.backgroundImage=""})}}
1,getReferrer(){document.querySelector(".v8__referrer").value=document.referrer},addInlineCalendar:function(e){let t=e.querySelector(".v8-inline-calendar > input"),n=e.querySelector(".v8-inline-calendar"),i=[];if(!n||!t)return;n.classList.contains("v8-no-weekends")?i=[0,6]:n.classList.contains("v8-no-sat-only")?i=[6]:n.classList.contains("v8-no-sun-only")&&(i=[0]);let l=new Date;"undefined"!=typeof v8Settings&&v8Settings.enableOneDayBuffer?(console.log("One-day buffer is enabled"),l.setDate(l.getDate()+1)):console.log("One-day buffer is disabled");let a={inline:!0,minDate:l,dateFormat:"Y-m-d",allowInput:!0,disable:[function(e){return i.includes(e.getDay())}],onChange:async function(t,n,i){let l=e.querySelector("[name=gf_form_id]").value,a=Array.from(e.querySelectorAll(".v8_business_units select")).find(e=>null!==e.offsetParent),o=Array.from(e.querySelectorAll(".v8_job_type select")).find(e=>null!==e.offsetParent),r=a?a.value:null,d=o?o.value:null;if(r||console.warn("Business Unit ID is missing."),d||console.warn("Job Type Selector is missing or empty."),!e.querySelector(".v8-dynamic-slots"))return;let s=await e.querySelector(".v8-dynamic-slots > div > .v8Fields__radio-container"),c=document.createElement("div");c.classList.add("v8-spinner"),c.innerHTML='<div class="v8-spinner-container"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>';let u=document.querySelector(".v8Form");u?u.appendChild(c):s.appendChild(c),console.log("Fetching capacity data for date:",n," and formId:",l);try{let e=`${wpRest.siteUrl}/wp-content/plugins/lnb-v8-scheduler/src/api/st-cap-lookup.php?frontEndLookup=true&date=${n}&formId=${l}`;r&&(e+=`&businessUnitIds=${r}`),d&&(e+=`&jobTypeId=${d}`);let t=await fetch(e);if(console.log("Raw response from API:",t),!t.ok)throw Error(`API request failed with status ${t.status}`);let i=await t.json();if(i.availabilities&&i.availabilities.length>0){let e=i.availabilities.filter(e=>e.isAvailable).reduce((e,t)=>{let n=`${t.start}-${t.end}`;return e[n]?e[n].openAvailability+=t.openAvailability:e[n]={...t,openAvailability:t.openAvailability},e},{}),t=Object.values(e);console.log("Aggregated Available Slots:",t);let n=s.querySelector("input").name;for(;s.firstChild;)s.removeChild(s.lastChild);for(let e of t){let t=new Date(e.start),i=new Date(e.end),l={weekday:"short",year:"numeric",month:"short",day:"numeric"},a=t.toLocaleDateString("en-US",l),o={hour:"numeric",minute:"numeric",hour12:!0,timeZone:"UTC"},r=t.toLocaleString("en-US",o),d=i.toLocaleString("en-US",o),c=document.createElement("input");c.type="radio",c.value=e.start,c.name=n;let u=document.createElement("span");u.innerHTML=`${a}, ${r} - ${d}`,console.log(e.openAvailability);let v=document.createElement("div");v.classList.add("v8Fields__radio-single"),0===e.openAvailability&&(v.classList.add("v8-radio-unavailable"),v.title="Time Unavailable"),v.appendChild(c),v.appendChild(u),s.appendChild(v)}}else s.innerHTML='No available time slot <div class="v8-no-calendar"><svg xmlns="http://www.w3.org/2000/svg" width="60" height="61" fill="none"><path fill="#737475" d="M60 17.016H0V7.889a2.715 2.715 0 0 1 2.707-2.707h54.586A2.715 2.715 0 0 1 60 7.89z"></path><path fill="#DFE0E1" d="M57.293 60.348H2.707A2.715 2.715 0 0 1 0 57.641V17.016h60V57.64a2.703 2.703 0 0 1-2.707 2.707"></path><path fill="#fff" d="M55.94 21.076H4.06v35.212h51.88z"></path><path fill="#BCBCBD" d="M15.12 10.345a5.18 5.18 0 0 1-5.182-5.182C9.938 2.3 12.278 0 15.121 0s5.182 2.32 5.182 5.182h-1.934a3.243 3.243 0 0 0-3.248-3.248 3.243 3.243 0 0 0-3.249 3.248c0 1.798 1.47 3.23 3.249 3.23zM30.01 10.345a5.18 5.18 0 0 1-5.182-5.182C24.828 2.3 27.148 0 30.01 0a5.18 5.18 0 0 1 5.182 5.182h-1.934a3.256 3.256 0 0 0-3.248-3.248 3.243 3.243 0 0 0-3.249 3.248 3.243 3.243 0 0 0 3.249 3.249zM44.879 10.345a5.18 5.18 0 0 1-5.182-5.182C39.697 2.3 42.037 0 44.879 0a5.18 5.18 0 0 1 5.182 5.182h-1.934a3.255 3.255 0 0 0-3.248-3.248 3.255 3.255 0 0 0-3.249 3.248 3.243 3.243 0 0 0 3.249 3.249z"></path><path fill="#949596" d="M55.94 31.692H4.06v1.547h51.88zM55.94 43.99H4.06v1.547h51.88z"></path><path fill="#949596" d="M17.402 21.076h-1.547v35.212h1.547zM30.783 21.076h-1.547v35.212h1.547zM44.144 21.076h-1.547v35.212h1.547z"></path><path fill="#949596" stroke="#949596" stroke-width="0.5" d="m25.804 37.052.177-.176-.177-.177-.501-.502-.177-.176-.177.176L23.147 38l-1.802-1.802-.177-.176-.177.176-.5.502-.178.177.177.176 1.802 1.802-1.802 1.802-.177.177.177.177.502.501.176.177.177-.177 1.802-1.802 1.802 1.802.177.177.177-.177.5-.501.178-.177-.177-.177-1.802-1.802z"></path></svg></div>'}catch(e){console.error("Error occurred during fetch or parsing JSON:",e)}finally{c.remove()}}};this.calendar=flatpickr(t,a),e.querySelector(".flatpickr-input").style.display="none"}}.init();
2//# sourceMappingURL=v8-formatter-min.js.map

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.