1class PCAFE_GFSPF_Frontend{constructor(options){this.options=options;this.init()} 2init(){this.initSmartPhoneField();this.addCountryCode()} 3triggerPhoneData(sourceId,dataName,value){if(!document.querySelectorAll(`.spf_${sourceId}.spf_meta_${dataName}`).length){return} 4var element=document.querySelector(`.spf_${sourceId}.spf_meta_${dataName}`).querySelector('input');element.value=value;element.dispatchEvent(new Event('change'))} 5initSmartPhoneField(){if(typeof intlTelInput=='undefined'){return} 6const input=document.querySelector(this.options.inputId);if(input===null){return} 7const iti=window.intlTelInput(input,this.configuration());let field_id=`${this.options.formId}_${this.options.fieldId}`;input.addEventListener('blur',(e)=>{this.validateNumber(e.currentTarget,field_id,iti)});input.addEventListener('keyup',(e)=>{var currentText=iti.getNumber(intlTelInput.utils.numberFormat.E164);if(typeof currentText==="string"){iti.setNumber(currentText)} 8this.formatValidation(e.currentTarget,iti)});setTimeout(()=>{let countryData=iti.getSelectedCountryData();this.populatePhoneMeta(countryData)},500);input.addEventListener('countrychange',(e)=>{let countryData=iti.getSelectedCountryData();this.populatePhoneMeta(countryData)});let getCookieValue=this.getCookie("gf_spf_"+field_id),getInputValue=input.value;if(getInputValue){input.closest('div').querySelector('input[type="hidden"]').value=getCookieValue}} 9populatePhoneMeta(countryData){for(var item in countryData){if(countryData.hasOwnProperty('iso2')&&item=='iso2'){this.triggerPhoneData(this.options.formId+'_'+this.options.fieldId,'cc',countryData[item])} 10if(countryData.hasOwnProperty('dialCode')&&item=='dialCode'){this.triggerPhoneData(this.options.formId+'_'+this.options.fieldId,'cdc',countryData[item]);this.triggerPhoneData(this.options.formId+'_'+this.options.fieldId,'cdcp','+'+countryData[item])} 11if(countryData.hasOwnProperty('name')&&item=='name'){this.triggerPhoneData(this.options.formId+'_'+this.options.fieldId,'cn',countryData[item])}}} 12configuration(){let field_id=`input_${this.options.fieldId}`;var config={initialCountry:this.options.defaultCountry,formatOnDisplay:!0,formatAsYouType:!0,countrySearch:!0,fixDropdownWidth:!0,hiddenInput:function(telInputName){return{phone:field_id}},useFullscreenPopup:!1};if(this.options.language){config.i18n=this.geti18n(this.options.language)} 13if(this.options.autoIp){this.detectIPAddress(config,this.options.pcafe_ipinfo_key)} 14if(this.options.flag==""||this.options.flag=="flagonly"){config.nationalMode=!0}else if(this.options.flag=="flagcode"){config.nationalMode=!1;config.autoHideDialCode=!1}else{config.nationalMode=!1;config.separateDialCode=!0} 15if(this.options.exIn=='ex_only'){config.onlyCountries=this.options.countries.split(',')} 16if(this.options.exIn=='pre_only'){config.excludeCountries=this.options.countries.split(',')} 17if(this.options.placeholder){config.autoPlaceholder='off'} 18if(this.options.strictMode){config.strictMode=!0} 19if(!this.options.countrySearch){config.countrySearch=!1} 20config=gform.applyFilters('gform_spf_options_pre_init',config,this.options.formId,this.options.fieldId);return config} 21detectIPAddress(config,api_key){var api_url=api_key?`https://ipinfo.io?token=${api_key}`:"https://ipinfo.io";config.initialCountry="auto";config.geoIpLookup=function(success,failure){jQuery.get(api_url,function(){},"jsonp").always(function(resp){var countryCode=resp&&resp.country?resp.country:"";success(countryCode)})}} 22validateNumber(input,field_id,iti){const isValid=iti.isValidNumber();let errorMsg=input.parentNode.parentNode.querySelector(".error-msg"),validMsg=input.parentNode.parentNode.querySelector(".valid-msg");if(input.value){if(isValid){errorMsg.classList.add('hide');validMsg.classList.remove('hide');let number=iti.getNumber(intlTelInput.utils.numberFormat.E164);this.createCookie("gf_spf_"+field_id,number,1500);input.parentNode.parentNode.querySelector('input[type="hidden"]').value=number;input.setAttribute('aria-invalid','false')}else{validMsg.classList.add('hide');errorMsg.classList.remove('hide');let number=iti.getNumber(intlTelInput.utils.numberFormat.E164);this.createCookie("gf_spf_"+field_id,number,1500);input.parentNode.parentNode.querySelector('input[type="hidden"]').value=number;input.setAttribute('aria-invalid','true')}}
22else{validMsg.classList.add('hide');errorMsg.classList.add('hide')}} 23formatValidation(input,iti){const isValid=iti.isValidNumberPrecise();let errorMsg=input.parentNode.parentNode.querySelector(".error-msg"),validMsg=input.parentNode.parentNode.querySelector(".valid-msg");if(input.value){if(isValid){errorMsg.classList.add('hide');validMsg.classList.remove('hide')}}else{validMsg.classList.add('hide');errorMsg.classList.add('hide')}} 24addCountryCode(){if(this.options.flag!=='flagcode')return;const input=document.querySelector(this.options.inputId);if(input===null){return} 25const iti=intlTelInput.getInstance(input);const handleCountryChange=(e)=>{const currentCountryData=iti.getSelectedCountryData();const countryCode=`+${currentCountryData.dialCode}`;this.updateCountryCodeHandler(e.currentTarget,countryCode)};input.addEventListener('keydown',handleCountryChange);input.addEventListener('input',handleCountryChange);input.addEventListener('countrychange',handleCountryChange)} 26updateCountryCodeHandler(element,currentCode){let value=element.value;if(currentCode&&'+undefined'===currentCode||['','+'].includes(value)){return} 27if(!value.startsWith(currentCode)){value=value.replace(/\+/g,'');element.value=currentCode+value}} 28createCookie(cookieName,value,minutes){if(minutes){var date=new Date();date.setTime(date.getTime()+minutes*60*1000);var expires="; expires="+date.toGMTString()}else{var expires=""} 29document.cookie=cookieName+"="+value+expires+"; path=/"} 30getCookie(cookieName){let name=cookieName+"=";let decodedCookie=decodeURIComponent(document.cookie);let ca=decodedCookie.split(';');for(let i=0;i<ca.length;i++){let c=ca[i];while(c.charAt(0)==' '){c=c.substring(1)} 31if(c.indexOf(name)==0){return c.substring(name.length,c.length)}} 32return""} 33geti18n(language){let langCode;switch(language){case 'ar':langCode=(typeof spf_ar!=='undefined')?spf_ar:null;break;case 'bg':langCode=(typeof spf_bg!=='undefined')?spf_bg:null;break;case 'bn':langCode=(typeof spf_bn!=='undefined')?spf_bn:null;break;case 'bs':langCode=(typeof spf_bs!=='undefined')?spf_bs:null;break;case 'ca':langCode=(typeof spf_ca!=='undefined')?spf_ca:null;break;case 'cs':langCode=(typeof spf_cs!=='undefined')?spf_cs:null;break;case 'da':langCode=(typeof spf_da!=='undefined')?spf_da:null;break;case 'de':langCode=(typeof spf_de!=='undefined')?spf_de:null;break;case 'el':langCode=(typeof spf_el!=='undefined')?spf_el:null;break;case 'es':langCode=(typeof spf_es!=='undefined')?spf_es:null;break;case 'fa':langCode=(typeof spf_fa!=='undefined')?spf_fa:null;break;case 'fi':langCode=(typeof spf_fi!=='undefined')?spf_fi:null;break;case 'fr':langCode=(typeof spf_fr!=='undefined')?spf_fr:null;break;case 'hi':langCode=(typeof spf_hi!=='undefined')?spf_hi:null;break;case 'hr':langCode=(typeof spf_hr!=='undefined')?spf_hr:null;break;case 'hu':langCode=(typeof spf_hu!=='undefined')?spf_hu:null;break;case 'id':langCode=(typeof spf_id!=='undefined')?spf_id:null;break;case 'it':langCode=(typeof spf_it!=='undefined')?spf_it:null;break;case 'ja':langCode=(typeof spf_ja!=='undefined')?spf_ja:null;break;case 'ko':langCode=(typeof spf_ko!=='undefined')?spf_ko:null;break;case 'mr':langCode=(typeof spf_mr!=='undefined')?spf_mr:null;break;case 'nl':langCode=(typeof spf_nl!=='undefined')?spf_nl:null;break;case 'no':langCode=(typeof spf_no!=='undefined')?spf_no:null;break;case 'pl':langCode=(typeof spf_pl!=='undefined')?spf_pl:null;break;case 'pt':langCode=(typeof spf_pt!=='undefined')?spf_pt:null;break;case 'ro':langCode=(typeof spf_ro!=='undefined')?spf_ro:null;break;case 'ru':langCode=(typeof spf_ru!=='undefined')?spf_ru:null;break;case 'sk':langCode=(typeof spf_sk!=='undefined')?spf_sk:null;break;case 'sv':langCode=(typeof spf_sv!=='undefined')?spf_sv:null;break;case 'te':langCode=(typeof spf_te!=='undefined')?spf_te:null;break;case 'th':langCode=(typeof spf_th!=='undefined')?spf_th:null;break;case 'tr':langCode=(typeof spf_tr!=='undefined')?spf_tr:null;break;case 'ur':langCode=(typeof spf_ur!=='undefined')?spf_ur:null;break;case 'vi':langCode=(typeof spf_vi!=='undefined')?spf_vi:null;break;case 'zh':langCode=(typeof spf_zh!=='undefined')?spf_zh:null;break;default:langCode=null;break} 34return langCode}}
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.