PageSourceSearch

https://www.postaffiliatepro.it/js/login.js?v=20260924100516

js postaffiliatepro.it collected 2026-09-26 03:39:31 UTC 7,279 bytes, 1 lines download raw bytes

1(()=>{var l=window.loginConfig||{productDomain:"postaffiliatepro.com",storageKey:"pap_login"};(!l.productId||!l.recaptchaId||!l.apiUrl)&&console.error("Login configuration missing. Check page front-matter.");var u=l.localization||{},r={ERROR:"Error",WAITING:"Waiting",VALID:"Valid"},w={async sendApiRequest(n){let{url:t,method:i="GET",data:s,params:e}=n,a=t;if(e){let o=new URLSearchParams(e);a+=`?${o.toString()}`}let c={method:i,headers:{"Content-Type":"application/json"}};s&&(c.body=JSON.stringify(s));try{let o=await fetch(a,c);if(!o.ok){let g=`HTTP ${o.status}: ${o.statusText}`;try{let h=await o.json();h&&h.message&&(g=h.message)}catch{}let f=new Error(g);throw f.status=o.status,f}return await o.json()}catch(o){throw o}},parseError(n,t){if(n.status===500)return t;try{return(typeof n=="string"?JSON.parse(n):n).message||t}catch{return t}},debounce(n,t){let i;return function(...e){let a=()=>{clearTimeout(i),n(...e)};clearTimeout(i),i=setTimeout(a,t)}}},d=class n{constructor(){this.state=r.ERROR,this.message="Invalid field",this.uniqueValues=[]}valid(t=""){return this.state=r.VALID,this.message=t,this}error(t){return this.state=r.ERROR,this.message=t,this}waiting(){return this.state=r.WAITING,this.message="",this}setUnique(...t){return this.uniqueValues=[...t],this}hasUniqueChanged(...t){return this.uniqueValues.length!==t.length?!0:this.uniqueValues.some((i,s)=>i!==t[s])}static textLength(t="Field is required",i=1,s="input"){let e=new n;return e.validate=a=>((a.element.querySelector(s)?.value||"").length>=i?e.valid():e.error(t),e),e}static regex(t,i,s="input"){let e=new n;return e.validate=a=>{let o=a.element.querySelector(s)?.value||"";return t.test(o)?e.valid():e.error(i),e},e}static apiRequest(t,i){let s=new n;return s.precheck=i||(e=>{let a=e.getValue();return!a||a===""?(s.error(u.fieldEmpty||"Field is required"),!0):s.hasUniqueChanged(a)?(s.setUnique(a),!1):!0}),s.validate=async e=>{if(s.precheck(e))return s;try{s.waiting();let a=t(e),c=await w.sendApiRequest(a);s.error(u.domainFailed||"Domain not found")}catch(a){a.message&&a.message.includes("already used")?s.valid(u.domainValid||"Domain found - ready to login"):a.status===404?s.error(u.domainFailed||"Domain not found"):s.error(u.fieldInvalid||"Unable to validate domain")}return s},s}},m=class{constructor(t){this.name=t,this.active=!0,this.validators=[],this.validationTimeout=null,this._element=null}get element(){return this._element||(this._element=document.querySelector(`[data-id="${this.name}main"]`)),this._element}get input(){return this.element?.querySelector("input")}getValue(){return this.input?.value||""}setValue(t){return this.input&&(this.input.value=t),this}isActive(){return this.active}setActive(t){return this.active=t,this}setState(t,i=""){return this.element?(Object.values(r).forEach(s=>{this.element.classList.remove(s)}),this.element.classList.add(t),this.setErrorMessage(i),this):this}setErrorMessage(t){let i=this.element?.querySelector(".ErrorMessage");return i&&(i.textContent=t),this}addValidator(t){return this.validators.includes(t)||this.validators.push(t),this}async validate(){if(!(!this.validators.length||!this.isActive())){this.cancelValidation();try{let t=await Promise.all(this.validators.map(a=>a.validate(this))),i=t.find(a=>a.state===r.ERROR);if(i){this.setState(r.ERROR,i.message);return}if(t.find(a=>a.state===r.WAITING)){this.setState(r.WAITING,u.validating||"Validating...");return}let e=t.find(a=>a.message)||t[0];this.setState(r.VALID,e.message)}catch{this.setState(r.ERROR,u.fieldInvalid||"Validation failed")}window.signupForm&&window.signupForm.updateButtonState()}}getState(){if(!this.element)return r.ERROR;for(let t of Object.values(r))if(this.element.classList.contains(t))return t;return r.ERROR}scheduleValidation(t=0){return this.cancelValidation(),t<=0?(this.validate(),this):(this.validationTimeout=setTimeout(()=>{this.validationTimeout=null,this.validate()},t),this)}cancelValidation(){return this.validationTimeout&&(clearTimeout(this.validationTimeout),this.validationTimeout=null),this}validateOn(t,i=0,s=null){let e=w.debounce(()=>{this.scheduleValidation(i)},i),a=s?this.element?.querySelector(s):this.element;return a&&a.addEventListener(t,e),this}},p=class{constructor(){this.fields=new Map,this.submitButton=null}
1get element(){return document.querySelector('[data-id="signup"]')}getField(t){return this.fields.has(t)||this.fields.set(t,new m(t)),this.fields.get(t)}getSubmitButton(){return this.submitButton||(this.submitButton=document.querySelector('[data-id="createButtonmain"]')),this.submitButton}async validateAll(){let t=Array.from(this.fields.values()).filter(e=>e.isActive());t.forEach(e=>e.cancelValidation());let i=t.map(e=>e.validate());return await Promise.all(i),t.every(e=>e.getState()===r.VALID)}updateButtonState(){let t=this.getSubmitButton(),s=Array.from(this.fields.values()).filter(e=>e.isActive()).every(e=>e.getState()===r.VALID);t&&(s?(t.classList.remove("cursor-not-allowed"),t.classList.add("cursor-pointer")):(t.classList.add("cursor-not-allowed"),t.classList.remove("cursor-pointer")))}async submit(){if(!await this.validateAll()){this.showErrorPopup();return}try{let i=await this.getReCaptchaToken(),s={subdomain:this.getField("domainField").getValue(),grtoken:i};localStorage.setItem(l.storageKey,s.subdomain);let e=this.getSubmitButton()?.querySelector("span");e&&(e.textContent=u.redirecting||"Redirecting...");let a=`https://${s.subdomain}.${l.productDomain}/merchants/`;window.location.href=a}catch(i){console.error("Login failed:",i),this.showErrorPopup()}}async getReCaptchaToken(){return new Promise((t,i)=>{if(typeof grecaptcha>"u"){i(new Error("reCAPTCHA not loaded"));return}grecaptcha.ready(()=>{grecaptcha.execute(l.recaptchaId,{action:"login"}).then(t).catch(i)})})}showErrorPopup(){let t=document.querySelector(".Login__overlay"),i=document.querySelector(".Login__popup");t?.classList.add("active"),i?.classList.add("active")}},v=class{constructor(){this.overlay=document.querySelector(".Login__overlay"),this.popup=document.querySelector(".Login__popup"),this.closeButton=document.querySelector(".Login__popup__close")}init(){this.bindEvents()}bindEvents(){document.addEventListener("keydown",t=>{t.key==="Escape"&&this.close()}),this.overlay?.addEventListener("click",()=>this.close()),this.popup?.addEventListener("click",t=>{t.stopPropagation()}),this.closeButton?.addEventListener("click",()=>this.close())}close(){this.overlay?.classList.remove("active"),this.popup?.classList.remove("active")}};function E(n){let t=n.getField("domainField"),i=d.apiRequest(e=>({url:`${l.apiUrl}subscriptions/_check_domain`,method:"POST",params:{productId:l.productId,subdomain:e.getValue()}}));t.addValidator(d.textLength(u.fieldEmpty||"Domain is required",1)).addValidator(i).validateOn("focusout").validateOn("keyup",500).validateOn("change");let s=t.input;return s&&s.addEventListener("input",e=>{let a=e.target.value,c=a.replace(/[^a-zA-Z0-9-]/g,"");a!==c&&(e.target.value=c)}),t}function y(){let n=new p,t=new v;E(n);let i=n.getSubmitButton();return i&&i.addEventListener("click",s=>{s.preventDefault(),n.submit()}),t.init(),window.signupForm=n,n.updateButtonState(),{form:n,popup:t}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y();})();

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.