var goodscbaseUrl="https://sizechart.good-apps.co/";var goodscApiUrl="https://sizechart.good-apps.co/";var goodscShop="the5ivebrand-2.myshopify.com";var goodscTriggerEvents=[6];var goodscPageIds=[];var goodscCertainBtns=[];var goodscCurrencyCode="USD";var goodscCurrencySymbol="$";var goodscVersion="22";var goodscartWidget={"widget_name":"Widget name","widget_type":"upsell","widget_themes":"style_0","design_type":{"position":"full","animation":"animate__slideInDown","type_btn":"link_btn","show_tabs":true},"top":{"close_show":true,"close_bg_color":"#F8F5F5","close_bg_color_hover":"#F8F5F5CC","close_color":"#191919","close_color_hover":"#191919","close_border_radius":"10"},"main":{"wallpaper":"wallpaper_0","timer_bg":"#fff","timer_title_color":"#000","size_chart_border_radius":"10","size_chart_border_width":"0","size_chart_border_color":"#fff","size_chart_padding_l":"30","size_chart_padding_r":"30","size_chart_padding_t":"5","size_chart_padding_b":"10","table_background_color":"#fff","table_color":"#000","table_header_color":"#000","table_font_size":"16","table_cels_border_radius":"0","table_cels_border_width":"1","table_cels_border_color":"#000","table_cels_spacing":"0","table_cels_padding":"9","link_img":"none","link_color":"#000","link_color_h":"#858585","link_fs":"18","link_font_weight":"500","float_btn_img":"float_none","float_btn_position":"center_right","float_btn_color":"#000","float_btn_color_h":"#fff","float_btn_bg":"#fff","float_btn_bg_h":"#c7c7c7","float_btn_fs":"17","float_btn_font_weight":"500","float_btn_border_color":"#000","float_btn_border_color_h":"#fff","float_btn_border_width":"2","float_btn_padding_lr":"18","float_btn_padding_tb":"5","tab_color":"#C5C5C5","tab_color_active":"#000","tab_padding":"5","tab_bg":"transparent","tab_br":"5","tab_fs":"16","chart_template":{"1":{"title":"Default heading","description":"Default subheading"}}},"translation":{"title":"Your Cart"},"custom_css":"","widget_active_img":"https:\/\/sizechart.good-apps.co\/assets\\\/images\\\/widgets\\\/preview\\\/cart\\\/style_1.png"};var goodscActiveApp=1;var goodscartSubtotal="";var goodscInlineWidget="";var goodscInlineWidgetBlog="";var goodscInlineWidgetCollections="";var goodscartSubtotalContainer="";var goodscartAppName="GoodApps - Sizechart";var goodscartInlineWidgetSelected="";var goodscartInlineWidgetAll="";if(!goodscApp){var goodscApp=function(){const params=new URLSearchParams(window.location.search)
if(!(goodscActiveApp||sessionStorage.getItem('goodscPreviewMode')))return;if(sessionStorage.getItem('goodscPreviewMode')){showPreviewMessage()};function showPreviewMessage(){let html=`
Preview Mode
`;document.body.insertAdjacentHTML('afterbegin',html)}
let cartBuilded=false;let cartIsOpen=true;let cartToAnimate=null;styleLoader();if(Shopify.designMode){buildPreviewContainer();}
if(location.href.includes('offerId')&&location.href.includes(goodscartAppName.replace(/\s/g,''))){setCrisp();buildPreviewMessage();addPreviewMessageStyles();setTimeout(()=>{openPopup();},0)
popupEvents();}
function buildPreviewMessage(){const html=`
`;const element=document.createElement("div");element.classList.add('goodsc_minipopup','goodsc_minipopup_hide');element.innerHTML=html;const rootDiv=document.body;rootDiv.append(element);}
function addPreviewMessageStyles(){const styles=`
.goodsc_minipopup {
position: fixed;
left: 30px;
bottom: 10%;
width: 300px;
height: 350px;
padding: 30px;
background: #fff;
box-shadow: 0px 3px 16px 0px rgba(0,0,0,0.08);
border: 1px solid #f1f1f2;
border-radius: 8px;
z-index: 999;
transition: 0.7s;
}
@media (max-width: 480px){
.goodsc_minipopup {
width: 80%;
}
}
@media (max-width: 380px){
.goodsc_minipopup {
padding: 15px;
}
}
.goodsc_minipopup_hide {
transform: translateY(120%);
opacity: 0;
}
.goodsc_minipopup_content {
position: relative;
display: flex;
height: 100%;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.goodsc_minipopup__close {
position: absolute;
width: 10px;
top: -25px;
right: -17px;
transition: 0.3s;
cursor: pointer;
}
@media (max-width: 380px){
.goodsc_minipopup__close {
width: 8px;
top: -16px;
right: -7px;
}
}
.goodsc_minipopup__close:hover {
transform: scale(1.2);
}
.goodsc_minipopup__message {
text-align: center;
margin: 0px;
font-size: 16px;
}
@media (max-width: 380px){
.goodsc_minipopup__message {
font-size: 14px;
}
}
.goodsc_minipopup__btns {
display: flex;
justify-content: center;
gap: 10px;
}
@media (max-width: 480px){
.goodsc_minipopup__btns {
flex-direction: column;
}
}
.goodsc_minipopup__btn {
padding: 10px 25px;
border-radius: 6px;
transition: 0.5s;
cursor: pointer;
border: none;
color: white;
}
.goodsc_minipopup__btn--yellow {
background: #FFB73E;
}
.goodsc_minipopup__btn--yellow:hover {
background: #b09059;
}
.goodsc_minipopup__btn--gray {
background: #f9f9f9;
color: #78829d
}
.goodsc_minipopup__btn--gray:hover {
background: #f1f1f2;
}
`;const element=document.createElement("style");element.innerHTML=styles;const rootDiv=document.head;rootDiv.append(element);};function openPopup(){const popup=document.querySelector('.goodsc_minipopup');popup.classList.remove('goodsc_minipopup_hide');};function closePopup(){const popup=document.querySelector('.goodsc_minipopup');popup.classList.add('goodsc_minipopup_hide');};function popupEvents(){const closeBtn=document.querySelector('.goodsc_minipopup__btn--gray');const closeIcon=document.querySelector('.goodsc_minipopup__close');closeBtn.addEventListener('click',()=>{closePopup();})
closeIcon.addEventListener('click',()=>{closePopup();})
const opener=document.querySelector('.goodsc_minipopup__btn--yellow');opener.addEventListener('click',()=>{const crisp=document.getElementById('crisp-chatbox');const text_field=crisp.querySelector('textarea');const button_send=crisp.querySelector('.cc-fpwe');const visible=crisp.querySelector('.cc-1hqb');visible.setAttribute('data-visible',true);text_field.value="Hi, I’m using GoodApps SizeChart and can’t see the widget. Please assist.";button_send.click();text_field.value="";})}
function setCrisp(){const scriptTag=document.createElement('script');scriptTag.setAttribute('type','text/javascript');scriptTag.innerHTML=`
window.$crisp=[];
window.CRISP_WEBSITE_ID="4e50b386-fde3-4da7-97f2-80e38503c5ab";
$crisp.push(["set", "user:email", "{{ $userEmail }}"]);
$crisp.push(["set", "user:name", "{{ $storeOwnerName }}"]);
$crisp.push(["set", "session:segments", [["SizeChart"]]]);
$crisp.push(["set", "session:event", ["user:welcome"]]);
$crisp.push(["set", "session:data", [
[
["myshopifyurl", "${goodscShop}"],
["totalsales", "{{ $allAmount }}"],
["totalOffers", "{{ $countOffers }}"]
]
]]);
(function(){
d=document;
s=d.createElement("script");
s.src="https://client.crisp.chat/l.js";
s.async=1;
d.getElementsByTagName("head")[0].appendChild(s);
})();`;const rootDiv=document.head;rootDiv.append(scriptTag);}
if((location.href.includes('/products/')&&goodscTriggerEvents.includes(6))||(location.href.includes('/themes/')&&goodscTriggerEvents.includes(6))){triggerType=6;if(Object.keys(goodscTriggerEvents).length&&goodscTriggerEvents.includes(+triggerType)){let url=location.href.split('?')[0].split('/');let productsIndex=url.indexOf('products');url=url[productsIndex+1];fetchPage(location.href).then(function(dataPage){const variantsId=[];const productId=dataPage.product.id;const variants_arr=dataPage.product.variants;variants_arr.forEach((variant)=>{variantsId.push(variant.id)})
const offerParams={triggerType,productId,variantsId,}
offerFetch(offerParams).then(function(dataOffer){const object=dataOffer.design;const product_page=1;for(var prop in object){if(object[prop].design_type.triger_event==product_page){goodscartWidgetObj=object[prop]
buildWidget(goodscartWidgetObj,triggerType);}}});});}}
if(location.href.includes('/pages/')&&goodscTriggerEvents.includes(4)){const triggerType=4
if(Object.keys(goodscTriggerEvents).length&&goodscTriggerEvents.includes(+triggerType)){fetchPage(location.href).then(function(dataPage){const pageId=dataPage.page.id;if(goodscPageIds.includes(pageId)){let variantsId='0';const offerParams={triggerType,variantsId,targetCode:pageId}
offerFetch(offerParams).then(function(dataOffer){const object=dataOffer.design;const selected_page=4;for(var prop in object){if(object[prop].design_type.triger_event==selected_page){goodscartWidgetObj=object[prop]
buildWidget(goodscartWidgetObj,triggerType);}}})}})}}
if(location.href.includes('/products/')&&goodscTriggerEvents.includes(14)&&!goodscTriggerEvents.includes(6)){allPagesRequest();}else if(location.href.includes('/collections/')&&!goodscTriggerEvents.includes(9)&&goodscTriggerEvents.includes(14)){allPagesRequest();}else if(location.href.includes('/blogs/')&&!goodscTriggerEvents.includes(10)&&goodscTriggerEvents.includes(14)){allPagesRequest();}else if(location.href.includes('/pages/')&&!goodscTriggerEvents.includes(4)&&goodscTriggerEvents.includes(14)){allPagesRequest();}else if(goodscTriggerEvents.includes(14)&&!location.href.includes('/collections/')&&!location.href.includes('/blogs/')&&!location.href.includes('/pages/')&&!location.href.includes('/products/')){allPagesRequest();}
function allPagesRequest(){const triggerType=14;offerRequest(triggerType)}
if((location.href.includes('/collections/')&&goodscTriggerEvents.includes(9))){const triggerType=9;offerRequest(triggerType)}
if((location.href.includes('/blogs/')&&goodscTriggerEvents.includes(10))){const triggerType=10;offerRequest(triggerType)}
function offerRequest(triggerType){let variantsId='0'
const offerParams={triggerType,variantsId,}
offerFetch(offerParams).then(function(dataOffer){const object=dataOffer.design;for(var prop in object){goodscartWidgetObj=object[prop]}
buildWidget(goodscartWidgetObj,triggerType);})}
function buildPreviewContainer(){const rootDiv=document.querySelector('.goodsc-app-container');if(!rootDiv)return;const html='The Good APP will be displayed here!';const element=document.createElement("div");element.classList.add('goodsc-app-preview');element.style.padding='20px';element.style.border='1px solid #e4e4e4';element.style.borderRadius='8px';element.style.textAlign='center';element.innerHTML=html;rootDiv.append(element);}
function clearPreviewContainer(){const previewContainer=document.querySelector('.goodsc-app-container');if(previewContainer){previewContainer.innerHTML='';}}
function buildWidget(goodscartWidgetObj,triggerType){if(!goodscartWidgetObj){return}
if(Shopify.designMode){clearPreviewContainer();}
buildParentEl();build(goodscartWidgetObj,triggerType)}
function build(goodscartWidgetObj,triggerType){iframe=document.getElementById('goodsc-widget');buildInlineLink(goodscartWidgetObj,triggerType);buildFloatButton(goodscartWidgetObj);buildCart(goodscartWidgetObj);addStyling(goodscartWidgetObj);setTabsEvent();if(!cartBuilded)return;cartToAnimate=document.querySelector('.goodsc-cart__body');setOpenCartEvent(goodscartWidgetObj);setCloseCartEvent(goodscartWidgetObj);OpenCartEvents(goodscartWidgetObj);}
function buildParentEl(){let html=``;const element=document.createElement("div");element.setAttribute("id","goodsc-app");element.innerHTML=html;element.style.display='none';element.style.width='100%';element.style.height='100%';element.style.position='fixed';element.style.background='#00000080';element.style.zIndex='99999999999999999';element.style.top='0';document.querySelector('body').prepend(element);}
function styleLoader(){const headID=document.getElementsByTagName('head')[0];const link=document.createElement('link');link.type='text/css';link.id='goodhlundlesCss'
link.rel='stylesheet';headID.appendChild(link);link.href=goodscbaseUrl+`css/goodsc-size-charts.css?v=${goodscVersion}`;};function OpenCartEvents(goodscartWidgetObj){const float_btn=document.querySelector('.goodsc-float-btn');const link=document.querySelector('.goodsc-link');if(float_btn){float_btn.addEventListener('click',()=>{openCart(goodscartWidgetObj)})}
if(link){link.addEventListener('click',()=>{openCart(goodscartWidgetObj)})}}
function openCart(goodscartWidgetObj){cartWrapper=document.querySelector('#goodsc-app');if(!cartWrapper)return;document.body.setAttribute('style','overflow: hidden');cartWrapper.style.display="block";cartToAnimate.classList.add('spinner');cartToAnimate.setAttribute('class','goodsc-cart__body');cartToAnimate.classList.add('animate__animated',`${goodscartWidgetObj.design_type ? goodscartWidgetObj.design_type.animation : 'slideInRight'}`);cartIsOpen=true;}
function setOpenCartEvent(goodscartWidgetObj){if(!cartIsOpen){openCart(goodscartWidgetObj);}}
function setCloseCartEvent(goodscartWidgetObj){const cartInWrapper=document.querySelector('.goodsc-cart__close');const popupWrap=document.querySelector('.goodsc-cart__wrap');popupWrap.addEventListener('click',function(e){if(e.target.closest(".goodsc-cart__body")===null||e.target.closest(".goodsc-cart__close")!==null){closeCart(goodscartWidgetObj,cartInWrapper);}})}
function closeCart(goodscartWidgetObj,cartInWrapper){document.body.removeAttribute('style');const cartToAnimate=cartInWrapper.closest(".goodsc-cart__body");let animationClass=goodscartWidgetObj.design_type?goodscartWidgetObj.design_type.animation:'animate__slideOutRight';switch(animationClass){case'animate__slideInLeft':cartToAnimate.classList.add('animate__animated','animate__slideOutLeft');break;case'animate__slideInRight':cartToAnimate.classList.add('animate__animated','animate__slideOutRight');break;case'animate__fadeIn':cartToAnimate.classList.add('animate__animated','animate__fadeOut');break;case'animate__slideInUp':cartToAnimate.classList.add('animate__animated','animate__slideOutDown');break;case'animate__slideInDown':cartToAnimate.classList.add('animate__animated','animate__slideOutUp');break;case'animate__zoomIn':cartToAnimate.classList.add('animate__animated','animate__zoomOut');break;case'animate__fadeInTopLeft':cartToAnimate.classList.add('animate__animated','animate__fadeOutTopLeft');break;case'animate__fadeInTopRight':cartToAnimate.classList.add('animate__animated','animate__fadeOutTopRight');break;default:break;}
setTimeout(()=>{let cartWrapper=cartInWrapper.closest("#goodsc-app");cartWrapper.style.display="none";const OfferProducts=getAppSelector('.goodsc-cart__offer-products-wrap');if(OfferProducts){if(OfferProducts.querySelector('.goodsc-cart__offer-products')){OfferProducts.querySelector('.goodsc-cart__offer-products').remove();}
if(OfferProducts.querySelector('h2')){OfferProducts.querySelector('h2').remove();}}},1000)}
async function fetchPage(url){const options={method:'GET',headers:{"Content-Type":"application/json","Accept":"application/json"}};const resp=await fetch(`${url}.json`,options);return await resp.json();}
async function offerPreviewFetch(offerParams){const options={headers:{'Content-Type':'application/json',"Accept":"application/json"}};const domain=goodscShop;const product_id=offerParams.productId?offerParams.productId:0;const params=new URLSearchParams(window.location.search)
const main_offer_id=params.get('offerId');let url=goodscApiUrl+`api/front/offers/popup-data?domain=${domain}&product_id=${product_id}&main_offer_id=${main_offer_id}`;const resp=await fetch(url,options);if(!resp.ok){throw new Error(`HTTP error, status = ${resp.status}`);}
return await resp.json();}
async function offerFetch(offerParams){const options={headers:{'Content-Type':'application/json',"Accept":"application/json"}};const domain=goodscShop;const product_id=offerParams.productId?`&product_id=${offerParams.productId}`:'';const variants_id=offerParams.variantsId?`&variants_id=${offerParams.variantsId}`:'';const trigger_event=offerParams.triggerType;const display_on_device=window.innerWidth>991?'3':'2';const cart_value=0;let logged_user;if(Shopify.designMode){logged_user='1';}else{logged_user=ShopifyAnalytics.meta.page.customerId?'1':'0';}
const cart=0;let url=goodscApiUrl+`api/front/offers?domain=${domain}${product_id}${variants_id}&cart=${cart}&display_on_device=${display_on_device}&cart_value=${cart_value}&logged_user=${logged_user}&trigger_event=${trigger_event}`;const resp=await fetch(url,options);if(!resp.ok){throw new Error(`HTTP error, status = ${resp.status}`);}
return await resp.json();}
const s_ajaxListener=new Object();s_ajaxListener.tempOpen=XMLHttpRequest.prototype.open;s_ajaxListener.tempSend=XMLHttpRequest.prototype.send;s_ajaxListener.callback=function(){}
XMLHttpRequest.prototype.open=function(a,b){if(!a)var a='';if(!b)var b='';s_ajaxListener.tempOpen.apply(this,arguments);s_ajaxListener.method=a;s_ajaxListener.url=b;if(a.toLowerCase()=='get'){s_ajaxListener.data=b.split('?');s_ajaxListener.data=s_ajaxListener.data[1];}}
XMLHttpRequest.prototype.send=function(a,b){if(!a)var a='';if(!b)var b='';s_ajaxListener.tempSend.apply(this,arguments);if(s_ajaxListener.method.toLowerCase()=='post')s_ajaxListener.data=a;s_ajaxListener.callback();}
function getAppSelector(element){return document.querySelector(element);}
function addStyling(goodscartWidgetObj){let head=getAppSelector('head');let style=`
`;head.insertAdjacentHTML('beforeend',style);}
function getInlineLinkSelector(triggerType){if(triggerType==14){return goodscartInlineWidgetAll;}else{if(location.href.includes('/products/')){return goodscInlineWidget;}else if(location.href.includes('/blogs/')){return goodscInlineWidgetBlog;}else if(location.href.includes('/collections/')){return goodscInlineWidgetCollections;}else if(location.href.includes('/pages/')){return goodscartInlineWidgetSelected;}}}
function buildInlineLink(goodscartWidgetObj,triggerType){const type_btn=goodscartWidgetObj.design_type.type_btn;let parent_element;if(document.querySelector('.product-form__quantity')&&getInlineLinkSelector(triggerType)===''){parent_element=document.querySelector('.product-form__quantity');}else if(getInlineLinkSelector(triggerType)!==''&&document.querySelector(`${getInlineLinkSelector(triggerType)}`)){parent_element=document.querySelector(`${getInlineLinkSelector(triggerType)}`);}else if(getInlineLinkSelector(triggerType)===''||!document.querySelector(`${getInlineLinkSelector(triggerType)}`)){parent_element=document.querySelector('header');}
if(type_btn=="float_btn"||!parent_element){return;}
const link_txt=goodscartWidgetObj.translation.link_text;const show_img=goodscartWidgetObj.main.link_img=='none'?'hide':'';const img_src=goodscartWidgetObj.main.link_img=='none'?'':`src='${goodscbaseUrl}assets/images/widgets/size-charts_images/${goodscartWidgetObj.main.link_img}.svg'`;const style=`
`;const html=`
${link_txt}
`;document.body.insertAdjacentHTML('beforeend',style);parent_element.insertAdjacentHTML('beforeend',html);}
function buildFloatButton(goodscartWidgetObj){const type_btn=goodscartWidgetObj.design_type.type_btn;if(type_btn=="inline_link"){return;}
const float_position=goodscartWidgetObj.main.float_btn_position;const float_btn_txt=goodscartWidgetObj.translation.float_btn_txt;const show_img=(goodscartWidgetObj.main.float_btn_img=='float_none'||goodscartWidgetObj.main.float_btn_img==undefined)?'hide':'';const img_src=(goodscartWidgetObj.main.float_btn_img=='float_none'||goodscartWidgetObj.main.float_btn_img==undefined)?'':`src='${goodscbaseUrl}assets/images/widgets/size-charts_images/${goodscartWidgetObj.main.float_btn_img}.svg'`;const style=`
`;const html=`
${float_btn_txt}
`;document.body.insertAdjacentHTML('beforeend',style);document.body.insertAdjacentHTML('beforeend',html);}
function buildCart(goodscartWidgetObj){const position=goodscartWidgetObj.design_type.position;let appWrapper=getAppSelector('#goodsc-root');if(!appWrapper)return;const cartHtml=`
`;appWrapper.insertAdjacentHTML('beforeend',cartHtml);cartBuilded=true;buildChartBlock(goodscartWidgetObj)}
function buildChartBlock(data){const template_data=data.main.chart_template;const show_tabs=data.design_type.show_tabs;for(let key in template_data){if(template_data.hasOwnProperty(key)){let block=template_data[key];createChartBlock(block.title,block.description,key);if(show_tabs){buildTabs(block.tab_name,key);hideBlocks();document.querySelector('.chart_block[data-key="1"]').classList.remove('hide');}}}}
function createChartBlock(title_content,description_content,key){const parentWrap=document.querySelector('.goodsc-cart__timer-wrap');const chartBlock=document.createElement('div');chartBlock.classList.add('chart_block');chartBlock.setAttribute('data-key',key);parentWrap.appendChild(chartBlock);const titleWrap=document.createElement('div');titleWrap.classList.add('goodsc-cart__timer-title');chartBlock.appendChild(titleWrap);title_content=title_content===null?'':title_content;titleWrap.insertAdjacentHTML('beforeend',title_content);const descriptionWrap=document.createElement('div');descriptionWrap.classList.add('goodsc-cart__timer-msg');chartBlock.appendChild(descriptionWrap);description_content=description_content===null?'':description_content;descriptionWrap.insertAdjacentHTML('beforeend',description_content);}
function buildTabs(tab_name,key){const parentWrap=document.querySelector('.goodsc-cart__tabs');const tab=document.createElement('div');tab.classList.add('goodsc-cart__tab');tab.setAttribute('data-key',key);tab.innerText=tab_name;parentWrap.appendChild(tab);if(parentWrap.children.length===1){tab.classList.add('active');tab.click();}}
function setTabsEvent(){const template_tabs=document.querySelectorAll('.goodsc-cart__tab');template_tabs.forEach((tab)=>{tab.addEventListener('click',(e)=>{hideBlocks();removeActiveTab();tab.classList.add('active');const id=e.target.getAttribute('data-key');const select_el=document.querySelector(`.chart_block[data-key="${id}"]`)
select_el.classList.remove('hide');})})}
function hideBlocks(){const blocks=document.querySelectorAll('.chart_block');blocks.forEach((block)=>{block.classList.add('hide');})}
function removeActiveTab(){const tabs=document.querySelectorAll('.goodsc-cart__tab');tabs.forEach((tab)=>{tab.classList.remove('active');})}};goodscApp();}