PageSourceSearch

https://www.skytteholm.se/wp-content/themes/meetingselection.se/static/upsales-form-handler.min.js?ver=7.1.2

js skytteholm.se collected 2026-10-05 05:20:08 UTC 4,298 bytes, 2 lines download raw bytes

1document.addEventListener("alpine:init",()=>{Alpine.data("upsalesFormHandler",e=>({formId:e.formId,formCid:e.formCid,successKey:e.successKey||`form_${e.formId}`,form:{},errors:{},submitted:!1,companySearchQuery:"",companySearchSuggestions:[],companySearchSelectedName:"",companySearchDuns:"",companySearchLoading:!1,companySearchOpen:!1,companySearchDebounce:null,init(){"true"===localStorage.getItem(`upsales_success_${this.successKey}`)&&(this.submitted=!0);this.$root.querySelectorAll('input[name="Contact.phone"], input[x-model*="Contact.phone"]').forEach(e=>{e.addEventListener("input",t=>{let a=t.target.value;a=a.replace(/[^0-9+\s-]/g,"");(a.match(/\+/g)||[]).length>1&&(a=a.replace(/\+(?=.*\+)/g,"")),a.includes("+")&&"+"!==a[0]&&(a=a.replace(/\+/g,"")),t.target.value=a;const n=e.getAttribute("x-model")?.match(/form\[['"](.+?)['"]\]/);n&&(this.form[n[1]]=a)})}),window.addEventListener("click",e=>{this.$root.contains(e.target)||(this.companySearchOpen=!1)})},companySearchOnInput(){if(this.companySearchDuns="",this.companySearchSelectedName="",this.companySearchDebounce&&clearTimeout(this.companySearchDebounce),!this.form["Client.name"]||this.form["Client.name"].length<3)return this.companySearchSuggestions=[],void(this.companySearchOpen=!1);this.companySearchDebounce=setTimeout(()=>{this.companySearchFetch(this.form["Client.name"])},200)},async companySearchFetch(e){this.companySearchLoading=!0;try{const t=await fetch(`https://power.upsales.com/api/external/prospecting/clientSearch?country=SE&name=${encodeURIComponent(e)}`),a=await t.json();this.companySearchSuggestions=a.data||[],this.companySearchOpen=this.companySearchSuggestions.length>0}catch(e){console.error("Upsales client search error:",e)}this.companySearchLoading=!1},companySearchSelect(e){this.form["Client.name"]=e.name,this.form["Client.dunsNo"]=e.dunsNo,this.companySearchSelectedName=e.name,this.companySearchDuns=e.dunsNo,this.companySearchOpen=!1},companySearchOnChange(){this.form["Client.name"]!==this.companySearchSelectedName&&(this.form["Client.dunsNo"]="",this.companySearchDuns="")},fieldLabels:{"Client.name":"Företag","Client.dunsNo":"DUNS-nummer","Contact.name":"Namn","Contact.firstname":"Förnamn","Contact.lastname":"Efternamn","Contact.email":"E-post","Contact.phone":"Telefon","Extra.1763620062730":"Förfrågan gäller","Extra.1763620166182":"Ankomstdatum","Extra.1763620173536":"Avresedatum","Extra.1763620144650":"Antal deltagare","Extra.1763620243551":"Antal övernattande","Extra.1763620274984":"Övrig information","singleOptIn.1526547984158":"Godkänd integritetspolicy"},async validate(){this.errors={};const e=this.$root.querySelector("form");e.querySelectorAll("[required]").forEach(e=>{let t=e.name;if(e.hasAttribute("x-model")){const a=e.getAttribute("x-model").match(/form\[['"](.+?)['"]\]/);a&&(t=a[1])}("checkbox"===e.type?!!e.checked:e.value.trim())||(this.errors[t]="Detta fält är obligatoriskt.")});e.querySelectorAll('input[type="email"]').forEach(e=>{const t=e.value.trim();if(t&&!this.validateEmail(t)){let t=e.name;if(e.hasAttribute("x-model")){const a=e.getAttribute("x-model").match(/form\[['"](.+?)['"]\]/);a&&(t=a[1])}this.errors[t]="Ogiltig e-postadress."}});if(e.querySelectorAll('input[name="Contact.phone"], input[x-model*="Contact.phone"]').forEach(e=>{const t=e.value.trim();if(t&&!this.validatePhone(t)){let t=e.name;if(e.hasAttribute("x-model")){const a=e.getAttribute("x-model").match(/form\[['"](.+?)['"]\]/);a&&(t=a[1])}this.errors[t]="Telefonnumret får endast innehålla siffror, mellanslag, bindestreck och ett + i början."}}),Object.keys(this.errors).length>0)return;const t={event:"upsalesFormSubmit",formId:this.formId,formCid:this.formCid};for(const e in this.form)if(Object.hasOwn(this.form,e)){let a=this.form[e];if(null==a||""===a||!1===a)continue;"boolean"==typeof a&&(a=a?"1":"0"),t[this.fieldLabels[e]||e]=a}window.dataLayer=window.dataLayer||[],window.dataLayer.push(t);for(const t in this.form)if(Object.hasOwn(this.form,t)){let a=e.querySelector(`[name="${t}"]`);a||(a=document.createElement("input"),a.type="hidden",a.name=t,e.appendChild(a)),a.value=this.form[t]}e.submit()},validateEmail:e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),validatePhone:e=>/^\+?[0-9\s-]+$/.test(e)}))});
2//# sourceMappingURL=upsales-form-handler.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.