PageSourceSearch

https://www.firstmats.co.uk/cdn/shop/t/342/assets/fm-vat.js?v=28987010322174842631785509108

js firstmats.co.uk collected 2026-10-02 05:29:00 UTC 3,314 bytes, 2 lines download raw bytes

1(function(){"use strict";var STORAGE_KEY="fm_vat_mode",MODE_EX="ex",MODE_INC="inc",fmApplying=!1;function isVatInclusiveLanding(){var params=new URLSearchParams(window.location.search);return!!((params.get("incl_vat")||"").toLowerCase()==="true"||params.get("gclid")||(params.get("utm_source")||"").toLowerCase()==="google"&&(params.get("utm_medium")||"").toLowerCase()==="cpc")}function fmDeriveInc(exStr){return exStr&&exStr.replace(/(\d[\d,]*(?:\.\d+)?)/,function(match){var n=parseFloat(match.replace(/,/g,""));return isNaN(n)?match:(n*1.2).toFixed(2)})}function getMode(){try{return sessionStorage.getItem(STORAGE_KEY)||MODE_EX}catch(e){return MODE_EX}}function setMode(mode){try{sessionStorage.setItem(STORAGE_KEY,mode)}catch(e){}}function applyMode(mode){var isInc=mode===MODE_INC;fmApplying=!0,setTimeout(function(){fmApplying=!1},0),document.documentElement.setAttribute("data-vat-mode",mode);for(var prices=document.querySelectorAll("[data-ex-price]"),i=0;i<prices.length;i++){var el=prices[i],exVal=el.getAttribute("data-ex-price"),incVal=el.getAttribute("data-inc-price");incVal||(incVal=fmDeriveInc(exVal)),el.textContent=isInc?incVal:exVal}for(var labels=document.querySelectorAll(".fm-vat-label"),j=0;j<labels.length;j++){var lbl=labels[j];lbl.textContent=isInc?lbl.getAttribute("data-inc-label")||"Inc. VAT":lbl.getAttribute("data-ex-label")||"+ VAT"}for(var notes=document.querySelectorAll(".fm-cart-vat-note"),k=0;k<notes.length;k++){var note=notes[k];note.textContent=isInc?note.getAttribute("data-inc-note")||"Inc. VAT":note.getAttribute("data-ex-note")||"Ex. VAT \u2014 VAT added at checkout"}var toggle=document.getElementById("fm-vat-toggle");if(toggle){toggle.setAttribute("data-mode",mode),toggle.setAttribute("aria-pressed",isInc?"true":"false");var exBtn=toggle.querySelector('[data-vat-btn="ex"]'),incBtn=toggle.querySelector('[data-vat-btn="inc"]');exBtn&&exBtn.classList.toggle("fm-vat-toggle__btn--active",!isInc),incBtn&&incBtn.classList.toggle("fm-vat-toggle__btn--active",isInc)}window.fmVatMode=mode,document.dispatchEvent(new CustomEvent("fm:vat-changed",{detail:{mode:mode}}))}function handleToggleClick(e){var btn=e.target.closest("[data-vat-btn]");if(btn){var newMode=btn.getAttribute("data-vat-btn");newMode!==getMode()&&(setMode(newMode),applyMode(newMode))}}function observeCartDrawer(){if(window.MutationObserver){var seen=[],targets=[document.querySelector("cart-drawer")||document.getElementById("CartDrawer"),document.getElementById("main-cart-items")];targets.forEach(function(target){if(target){for(var i=0;i<seen.length;i++)if(seen[i].contains(target)||target.contains(seen[i]))return;seen.push(target);var debounce=null,obs=new MutationObserver(function(){fmApplying||debounce||(debounce=setTimeout(function(){debounce=null,applyMode(getMode())},30))});obs.observe(target,{childList:!0,subtree:!0})}})}}function init(){try{localStorage.removeItem(STORAGE_KEY)}catch(e){}isVatInclusiveLanding()&&setMode(MODE_INC);var mode=getMode();applyMode(mode);var toggle=document.getElementById("fm-vat-toggle");toggle&&toggle.addEventListener("click",handleToggleClick),observeCartDrawer()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/342/assets/fm-vat.js.map?v=28987010322174842631785509108

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.