PageSourceSearch

https://www.dermalogica.co.uk/cdn/shop/t/333/assets/custom-loyalty.js?v=24431845219337841301755759441

js dermalogica.co.uk collected 2026-09-24 21:06:08 UTC 4,777 bytes, 2 lines download raw bytes

1document.addEventListener("DOMContentLoaded",function(){var loyaltyBlocks=document.querySelectorAll("[data-loyalty-block]");if(!loyaltyBlocks||loyaltyBlocks.length===0)return;function parseNumber(value){var n=parseFloat(value);return isNaN(n)?0:n}function isSubscriptionSelected(){try{const widgets=document.querySelectorAll("recharge-subscription-widget");for(const widget of widgets){const sr=widget.shadowRoot;if(!sr)continue;const subInput=sr.querySelector('.rc-purchase-option__input[value="subscription"]');if(subInput&&subInput.checked)return!0}}catch{}return!1}function updatePointsForBlock(blockEl,priceCents){var pointValue=parseNumber(blockEl.getAttribute("data-point-value"))||0,major=priceCents/100,multiplier=isSubscriptionSelected()?2:1,points=Math.round(major*pointValue*multiplier),pointsEl=blockEl.querySelector("[data-loyalty-points-total]"),hiddenInput=blockEl.querySelector("[data-loyalty-current-price]");pointsEl&&(pointsEl.textContent=points),hiddenInput&&(hiddenInput.value=points),blockEl.dataset.lastPriceCents=String(priceCents)}loyaltyBlocks.forEach(function(blockEl){var initialPrice=parseNumber(blockEl.getAttribute("data-initial-price"))||0;updatePointsForBlock(blockEl,initialPrice);var productForm=blockEl.closest('form[action*="/cart/add"], form[data-product-form], [data-product-form]');if(productForm){var variantInput=productForm.querySelector('select[name="id"], input[name="id"]');variantInput&&productForm.addEventListener("change",function(evt){var priceEl=productForm.querySelector("[data-product-price], .price, .product__price"),priceCents=null;priceEl&&priceEl.hasAttribute("data-cents")&&(priceCents=parseNumber(priceEl.getAttribute("data-cents")));var selected=productForm.querySelector('input[name="id"]:checked, select[name="id"]');selected&&selected.dataset&&selected.dataset.price&&(priceCents=parseNumber(selected.dataset.price)),priceCents===null&&window.Shopify&&window.Shopify.activeVariant&&window.Shopify.activeVariant.price!==void 0&&(priceCents=parseNumber(window.Shopify.activeVariant.price)),priceCents!==null&&updatePointsForBlock(blockEl,priceCents)});var mo=new MutationObserver(function(mutations){mutations.forEach(function(mutation){var priceEl=productForm.querySelector("[data-product-price], .price, .product__price");if(priceEl){var priceCents=null;if(priceEl.hasAttribute("data-cents"))priceCents=parseNumber(priceEl.getAttribute("data-cents"));else if(priceEl.dataset&&priceEl.dataset.cents)priceCents=parseNumber(priceEl.dataset.cents);else{var text=priceEl.textContent||"",extracted=text.replace(/[^0-9\.\,]/g,"").replace(",","."),floatVal=parseFloat(extracted);isNaN(floatVal)||(priceCents=Math.round(floatVal*100))}priceCents!==null&&updatePointsForBlock(blockEl,priceCents)}})});mo.observe(productForm,{attributes:!0,childList:!0,subtree:!0})}["variant:change","variant:changed","variantChange","variant:changed.local","product:price-update","variant:selected","variant:update"].forEach(function(evtName){document.addEventListener(evtName,function(evt){var priceCents=null;if(evt&&evt.detail){var variantObj=evt.detail.variant||evt.detail.resource&&evt.detail.resource;variantObj&&variantObj.price!==void 0&&(priceCents=parseNumber(variantObj.price))}priceCents!=null&&updatePointsForBlock(blockEl,priceCents)})});var variantPickerForm=document.querySelector(".variant-picker__form");variantPickerForm&&variantPickerForm.addEventListener("change",function(){var activeRadio=variantPickerForm.querySelector('input[type="radio"][data-variant-id]:checked');if(activeRadio){var variantId=activeRadio.getAttribute("data-variant-id"),variantDataScript=document.querySelector("script[data-product-variants-json]");if(variantDataScript)try{var variants=JSON.parse(variantDataScript.textContent||"[]"),found=variants.find(function(v){return String(v.id)===String(variantId)});if(found&&found.price!=null){updatePointsForBlock(blockEl,parseNumber(found.price));return}}catch{}}var priceEl=document.querySelector("[data-product-price]");priceEl&&priceEl.hasAttribute("data-cents")&&updatePointsForBlock(blockEl,parseNumber(priceEl.getAttribute("data-cents")))}),document.addEventListener("recharge:widget:loaded",function(){var currentPrice
1=parseNumber(blockEl.getAttribute("data-initial-price"))||0;updatePointsForBlock(blockEl,currentPrice)})});var lastSubState=null;setInterval(function(){var sub=(function(){try{return isSubscriptionSelected()}catch{return!1}})();sub!==lastSubState&&(lastSubState=sub,loyaltyBlocks.forEach(function(blockEl){var basePrice=parseNumber(blockEl.dataset.lastPriceCents)||parseNumber(blockEl.getAttribute("data-initial-price"))||0;updatePointsForBlock(blockEl,basePrice)}))})});
2//# sourceMappingURL=/cdn/shop/t/333/assets/custom-loyalty.js.map?v=24431845219337841301755759441

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.