PageSourceSearch

https://petrizzio.cl/cdn/shop/t/114/assets/skin-quiz.js?v=33685639857836329421790001941

js petrizzio.cl collected 2026-10-08 15:20:27 UTC 5,514 bytes, 2 lines download raw bytes

1class SkinQuiz extends HTMLElement{connectedCallback(){this.steps=Array.from(this.querySelectorAll("[data-quiz-step]")),this.panels=Array.from(this.querySelectorAll("[data-quiz-result-panel]")),!(!this.steps.length||!this.panels.length)&&(this.intro=this.querySelector("[data-quiz-intro]"),this.stage=this.querySelector("[data-quiz-stage]"),this.progress=this.querySelector("[data-quiz-progress]"),this.progressLabel=this.querySelector("[data-quiz-progress-label]"),this.segments=Array.from(this.querySelectorAll("[data-quiz-segment]")),this.progressTemplate=this.dataset.progressTemplate||"",this.miniCart=document.querySelector("mini-cart"),this.answers=[],this.index=0,this.addEventListener("click",this.onClick.bind(this)))}static reducedMotion(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}onClick(event){const hit=selector=>{const el=event.target.closest(selector);return el&&this.contains(el)?el:null};if(hit("[data-quiz-start]"))return this.beginQuiz();if(hit("[data-quiz-restart]"))return this.beginQuiz();if(hit("[data-quiz-back]"))return this.goBack();const option=hit("[data-quiz-option]");if(option)return this.answer(option);const add=hit("[data-quiz-add]");if(add)return this.addRoutine(add)}transition(mutate){if(SkinQuiz.reducedMotion()||!this.stage){mutate();return}const stage=this.stage,from=stage.getBoundingClientRect().height;mutate(),stage.style.height="auto";const to=stage.getBoundingClientRect().height;if(Math.abs(to-from)<1){stage.style.height="";return}stage.classList.add("is-measuring"),stage.style.height=`${from}px`,stage.getBoundingClientRect(),requestAnimationFrame(()=>{stage.style.height=`${to}px`}),this.releaseHeight(stage)}releaseHeight(stage){this.onHeightEnd&&stage.removeEventListener("transitionend",this.onHeightEnd),clearTimeout(this.releaseTimer),this.onHeightEnd=event=>{event.target!==stage||event.propertyName!=="height"||(stage.style.height="",stage.classList.remove("is-measuring"),stage.removeEventListener("transitionend",this.onHeightEnd),this.onHeightEnd=null,clearTimeout(this.releaseTimer))},stage.addEventListener("transitionend",this.onHeightEnd),this.releaseTimer=setTimeout(()=>{this.onHeightEnd&&this.onHeightEnd({target:stage,propertyName:"height"})},900)}show(panel){[this.intro,...this.steps,...this.panels].filter(Boolean).forEach(el=>{el.hidden=el!==panel,el.classList.toggle("is-active",el===panel)})}focusPanel(panel,selector){const target=panel&&panel.querySelector(selector);target&&(target.setAttribute("tabindex","-1"),target.focus({preventScroll:!0}))}beginQuiz(){this.answers=[],this.index=0,this.progress&&(this.progress.hidden=!1),this.transition(()=>this.showStep())}answer(option){this.answers[this.index]=parseInt(option.dataset.quizResult,10)||1,this.index+=1,this.transition(()=>this.index>=this.steps.length?this.showResult():this.showStep())}goBack(){this.index!==0&&(this.index-=1,this.answers.length=this.index,this.transition(()=>this.showStep()))}showStep(){const current=this.steps[this.index];this.show(current);const back=current&&current.querySelector("[data-quiz-back]");back&&(back.hidden=this.index===0),this.focusPanel(current,".skin-quiz__question"),this.updateProgress(this.index+1,this.steps.length)}showResult(){const winner=this.resolveWinner(),panel=this.panels.find(p=>parseInt(p.dataset.quizResultPanel,10)===winner);this.show(panel),this.focusPanel(panel,".skin-quiz__result-heading"),this.updateProgress(this.steps.length,this.steps.length)}resolveWinner(){const tally=new Map;this.answers.forEach(result=>tally.set(result,(tally.get(result)||0)+1));const available=this.panels.map(p=>parseInt(p.dataset.quizResultPanel,10));let winner=available[0],best=-1;return available.forEach(candidate=>{const score=tally.get(candidate)||0;score>best&&(best=score,winner=candidate)}),winner}updateProgress(current,total){this.segments.forEach((segment,i)=>{segment.classList.toggle("is-filled",i<current)}),this.progressLabel&&this.progressTemplate&&(this.progressLabel.textContent=this.progressTemplate.replace("[current]",current).replace("[total]",total))}addRoutine(button){const ids=(button.dataset.variantIds||"").split(",").filter(
1Boolean);if(!ids.length)return;const items={items:ids.map(id=>({id,quantity:1}))},errorTarget=button.closest("[data-quiz-result-panel]").querySelector("[data-quiz-error]");if(this.setError(errorTarget,!1),document.body.classList.contains("template-cart")||!theme.shopSettings.cartDrawer){Shopify.postLink2(theme.routes.cart_add_url,{parameters:{...items}});return}button.setAttribute("disabled",!0),button.classList.add("loading");const sections=this.miniCart?this.miniCart.getSectionsToRender().map(section=>section.id):[],body=JSON.stringify({...items,sections,sections_url:window.location.pathname});fetch(`${theme.routes.cart_add_url}`,{...fetchConfig("javascript"),body}).then(response=>response.json()).then(response=>{if(response.status){this.setError(errorTarget,response.description);return}this.miniCart&&this.miniCart.renderContents(response),document.dispatchEvent(new CustomEvent("ajaxProduct:added",{detail:{product:response}}))}).catch(e=>{console.error(e)}).finally(()=>{button.classList.remove("loading"),button.removeAttribute("disabled")})}setError(target,message){if(!target){message&&alert(message);return}target.textContent=message||"",target.hidden=!message}}customElements.get("skin-quiz")||customElements.define("skin-quiz",SkinQuiz);
2//# sourceMappingURL=/cdn/shop/t/114/assets/skin-quiz.js.map?v=33685639857836329421790001941

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.