(async function () { var shop = JSON.parse('{"_id":"66ba7741a1ac870129a1cdf0","origin":"furniture-depot-anada.myshopify.com","customTheme":{"productList":{"classControl":"div.collection","loopOn":"div.item-details-wrapper","pathToPrice":"div.on-sale","pathToOnSalePrice":"span.price.regular-price.price--final"},"productDetail":{"classControl":"div.product__info-aside","pathToPrice":"span.price-item.price-item--sale.price--final,span.price-item.price-item--regular","after":"div.product-form__buttons"},"cart":{"classControl":"div.cart__footer","pathToPrice":"span.price--final","after":"button.cart__checkout-button.button.button--primary"}},"theme":"Custom"}'); var flexitiAppServerUrl = 'https://ecomm-monthly-payment-widget.flexiti.com'; var themesConfig = JSON.parse('[{"theme_store_id":null,"name":"Tempest","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":"#product-loop","loopOn":".price","pathToPrice":".prod-price > .money","pathToOnSalePrice":".onsale > .money"},"productDetail":{"classControl":"#product-description","pathToPrice":".product-price > .money","appendTo":"#product-price"},"cart":{"classControl":"#shopping-cart","pathToPrice":"#basket-right > h4 > span.money","appendTo":"#basket-right > h4"}},"css":"tempest"},{"theme_store_id":796,"name":"Debut","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".grid--view-items","loopOn":".grid--view-items .grid__item","pathToPrice":"dl.price > div.price__regular > dd >span.price-item--regular","pathToOnSalePrice":".price > .price__sale > dd > .price-item--sale"},"productDetail":{"classControl":".product-single","pathToPrice":".price-item--sale","appendTo":"dl.price"},"cart":{"classControl":".template-cart","pathToPrice":".cart-subtotal__price","before":".cart__shipping"}},"css":"debut"},{"theme_store_id":730,"name":"Brooklyn","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".grid-collage","loopOn":".grid-product__wrapper","pathToPrice":".grid-product__price-wrap > .grid-product__price","pathToOnSalePrice":".grid-product__price-wrap > .grid-product__price"},"productDetail":{"classControl":".product-single","pathToPrice":".product-single__price","appendTo":"div[data-price-container]"},"cart":{"classControl":"#your-shopping-cart","pathToPrice":".cart__subtotal","after":".push--large--seven-twelfths > .grid--full.cart__row--table"}},"css":"brooklyn"},{"theme_store_id":679,"name":"Supply","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".grid-uniform","loopOn":".product-item--price","pathToPrice":".h1 > span:last","pathToOnSalePrice":".h1 > span:last"},"productDetail":{"classControl":"#ProductSection","pathToPrice":"#productPrice-product-template > span:last","after":".product-meta"},"cart":{"classControl":"#your-shopping-cart","pathToPrice":".cart-subtotal--price > span","after":".cart-subtotal"}},"css":"supply"},{"theme_store_id":380,"name":"Minimal","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".grid-uniform","loopOn":".grid-link","pathToPrice":".grid-link__meta","pathToOnSalePrice":".grid-link__meta"},"productDetail":{"classControl":"#shopify-section-product-template","pathToPrice":"#ProductPrice","after":".product-single__prices"},"cart":{"classControl":"#your-shopping-cart","pathToPrice":".cart__subtotal-price","before":".cart__policies"}},"css":"minimal"},{"theme_store_id":719,"name":"Pop","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".grid-uniform.product-grid","loopOn":".grid-uniform.product-grid .product-wrapper","pathToPrice":".product__price","pathToOnSalePrice":".grid-link__meta"},"productDetail":{"classControl":"#shopify-section-product-template","pathToPrice":"#shopify-section-product-template","after":".product-single__price"},"cart":{"classControl":"form.cart-wrapper","pathToPrice":"form.cart-wrapper .cart__subtotal","after":".cart__subtotal:parent"}},"css":"pop"},{"theme_store_id":829,"name":"Narrative","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".collection-template","loopOn":".collection-template .card__info","pathToPrice":".card__price","pathToOnSalePrice":".card__price > .card__price--sale"},"productDetail":{"classControl":"#shopify-section-product-template","pathToPrice":".product__current-price","after":".product__price"},"cart":{"classControl":"form.cart__form","pathToPrice":"form.cart__form .cart-footer__subtotal","after":".cart-footer__subtotal:parent"}},"css":"narrative"},{"theme_store_id":782,"name":"Jumpstart","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":"#shopify-section-collection-template","loopOn":"#shopify-section-collection-template .product","pathToPrice":".price"},"productDetail":{"classControl":".product-template","pathToPrice":"#ProductPrice-product-template","before":".form__row"},"cart":{"classControl":"#cart-form","pathToPrice":"#cart-form .cart__subtotal","after":"#cart-form .cart__subtotal"}},"css":"jumpstart"},{"theme_store_id":578,"name":"Simple","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":"#products","loopOn":".product__prices ","pathToPrice":".product__price","pathToOnSalePrice":".product__price--on-sale"},"productDetail":{"classControl":".template-product","pathToPrice":"#ProductPrice","after":".product-single__prices"},"cart":{"classControl":"#your-shopping-cart","pathToPrice":".cart__subtotal","before":".cart__policies"}},"css":"simple"},{"theme_store_id":775,"name":"Venture","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":".template-collection","loopOn":".template-collection .product-card__info","pathToPrice":".product-card__regular-price","pathToOnSalePrice":".product-card__price"},"productDetail":{"classControl":"#shopify-section-product-template","pathToPrice":"#ProductPrice-product-template","after":".product-single__meta-list"},"cart":{"classControl":".template-cart","pathToPrice":".cart__subtotal","before":".cart__taxes"}},"css":"venture"},{"theme_store_id":766,"name":"Boundless","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":"#products","loopOn":".product-item__meta","pathToPrice":".product-item__price-wrapper","pathToOnSalePrice":".product-item__price-wrapper > span .product-item__price--sale > span .js-price"},"productDetail":{"classControl":"#shopify-section-product-template","pathToPrice":".js-price","after":".product__price"},"cart":{"classControl":"#your-shopping-cart","pathToPrice":".cart__subtotal","before":".cart__policies"}},"css":"boundless"},{"theme_store_id":1368,"name":"Craft","script":"storefront-script-tempest.js.twig","config":{"productList":{"classControl":"div.collection","loopOn":"div.card__information","pathToPrice":"div.price","pathToOnSalePrice":"span.price-item.price-item--sale.price-item--last"},"productDetail":{"classControl":"div.product__info-wrapper.grid__item","pathToPrice":"div.price__container","after":"div.price.price--large.price--show-badge"},"cart":{"classControl":"div.cart__footer","pathToPrice":".totals__subtotal-value","after":".totals"}},"css":"craft"}]'); var selectedTheme = shop.theme; var shopOrigin = shop.origin; var regexpToGetProductPrice = /\d*\,?\d+.?\d*/; var config = null; var myEle = document.getElementById('flexitiModal'); var storeLanguage = document.documentElement.lang === 'fr' ? 'fr' : 'en'; console.log('Shop', shopOrigin); console.log('Flexiti App Server URL', flexitiAppServerUrl); await loadjQuery(); await loadEasyModal(); try { detectThemeAndFlexitiRender(); flexitiCode(); } catch (err) { console.log(err); } console.log('jQuery modal Loaded'); // 10 function flxCloseDeclinedWithMessage(message) { console.log(message); closeFlexitiModal(); } window.addEventListener('message', function (event) { switch (event.data) { case 'flx-close': flxCloseDeclinedWithMessage('flx-close'); break; case 'flx-apply:declined': flxCloseDeclinedWithMessage('flx-apply:declined'); break; case 'flx-apply:approved': console.log('flx-apply:approved'); $('.flexitiApplyNowLink').hide(); setCookie('flxHasApplied', true); closeFlexitiModal(); break; } }); function setCookie(cname, cvalue, exdays = null) { var expires = ''; if (exdays != null) { var d = new Date(); d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000); expires = 'expires=' + d.toUTCString(); } document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'; } function getCookie(cname) { const name = cname + '='; const ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; if (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return false; } function ThemeException(message) { this.message = message; this.name = 'ThemeException'; } async function loadEasyModal() { return new Promise((resolve, reject) => { if (!myEle) { const urlStaticFlxAppServer = flexitiAppServerUrl + '/static'; var linkElementToAppendScript = document.createElement('script'); linkElementToAppendScript.src = urlStaticFlxAppServer + '/iziModal.js'; linkElementToAppendScript.addEventListener('load', function () { var modalDiv = document.createElement('div'); modalDiv.id = 'flexitiModal'; var body = document.getElementsByTagName('body')[0]; body.insertBefore(modalDiv, body.firstChild); }); document .getElementsByTagName('head')[0] .appendChild(linkElementToAppendScript); var linkElementToAppendCSS = document.createElement('link'); linkElementToAppendCSS.href = urlStaticFlxAppServer + '/iziModal.css'; linkElementToAppendCSS.type = 'text/css'; linkElementToAppendCSS.rel = 'stylesheet'; linkElementToAppendCSS.media = 'screen,print'; document .getElementsByTagName('head')[0] .appendChild(linkElementToAppendCSS); console.log('loading jQuery & css via the app .'); resolve(); } else { console.log('not loading jQuery & css via the app .'); reject(); } }); } function detectThemeAndFlexitiRender() { return new Promise((resolve) => { if (selectedTheme == 'Custom') { try { config = shop.customTheme; } catch (err) { console.log(err); } } else { themesConfig.forEach(function (allowedTheme) { if (selectedTheme == allowedTheme.name) { config = allowedTheme.config; config.css = allowedTheme.css; resolve(config); } }); } if (config == null) { var themeException = new ThemeException('Not allowed Theme.'); throw themeException; } }); } function flexitiCode() { loadThemeCss(); if ( document.readyState === 'complete' || (document.readyState !== 'loading' && !document.documentElement.doScroll) ) { insertPaymentCalculator(); } else { document.addEventListener( 'DOMContentLoaded', insertPaymentCalculator, false, ); } function insertPaymentCalculator() { getCalculatorForProductList(); getCalculatorForProductDetail(); getCalculatorForCart(); } } function getOnlyText($htmlObject) { return $htmlObject .clone() //clone the element .children() //select all the children .remove() //remove all the children .end() //again go back to selected element .text(); } function isGreaterThanZero(regexpMatch) { return ( regexpMatch !== null && regexpMatch[0] !== '0,00' && regexpMatch[0] !== '0.00' && regexpMatch[0] !== '0' ); } function getPaymentCalculatorSnippet(productPrice) { var productPriceAsFloat = getPriceAsFloat(productPrice[0]); return getPaymentCalculatorData(productPriceAsFloat).then(function ( calculator, ) { var strCalculator = calculator || ''; var hasApplied = getCookie('flxHasApplied'); var enabledStyle = hasApplied == 'true' ? "style='display: none;'" : ''; strCalculator = strCalculator .replace('
', '') .replace('
', '') .replace('apply_anonymous flx_apply_now_link', 'flexitiApplyNowLink') .replace('javascript:;"', 'javascript:;"' + enabledStyle); return ( "