PageSourceSearch

https://www.firstmats.co.uk/cdn/shop/t/342/assets/fm-color-picker.js?v=180545357769466037461785238569

js firstmats.co.uk collected 2026-10-02 05:29:13 UTC 5,618 bytes, 2 lines download raw bytes

1(function(){"use strict";function hsvToRgb(h,s,v){var c=v*s,hp=h/60,x=c*(1-Math.abs(hp%2-1)),r1=0,g1=0,b1=0;hp>=0&&hp<1?(r1=c,g1=x,b1=0):hp>=1&&hp<2?(r1=x,g1=c,b1=0):hp>=2&&hp<3?(r1=0,g1=c,b1=x):hp>=3&&hp<4?(r1=0,g1=x,b1=c):hp>=4&&hp<5?(r1=x,g1=0,b1=c):hp>=5&&hp<6&&(r1=c,g1=0,b1=x);var m=v-c;return{r:Math.round((r1+m)*255),g:Math.round((g1+m)*255),b:Math.round((b1+m)*255)}}function rgbToHsv(r,g,b){r/=255,g/=255,b/=255;var max=Math.max(r,g,b),min=Math.min(r,g,b),d=max-min,h;d===0?h=0:max===r?h=60*((g-b)/d%6):max===g?h=60*((b-r)/d+2):h=60*((r-g)/d+4),h<0&&(h+=360);var s=max===0?0:d/max,v=max;return{h:h,s:s,v:v}}function hexToRgb(hex){return hex=(hex||"").replace(/^#/,""),hex.length===3&&(hex=hex.split("").map(function(c){return c+c}).join("")),/^[0-9A-Fa-f]{6}$/.test(hex)?{r:parseInt(hex.substring(0,2),16),g:parseInt(hex.substring(2,4),16),b:parseInt(hex.substring(4,6),16)}:null}function rgbToHex(r,g,b){function pad(n){var s=Math.max(0,Math.min(255,n|0)).toString(16).toUpperCase();return s.length===1?"0"+s:s}return pad(r)+pad(g)+pad(b)}var dialog,panel,sv,svThumb,hue,hueThumb,hexInput,rIn,gIn,bIn,preview,applyBtn,hsv={h:0,s:1,v:1},onCommitCb=null,lastTrigger=null;function init(){return dialog=document.getElementById("fmColourPicker"),dialog?(panel=dialog.querySelector(".fm-color-picker__panel"),sv=dialog.querySelector("[data-fm-cp-sv]"),svThumb=dialog.querySelector("[data-fm-cp-sv-thumb]"),hue=dialog.querySelector("[data-fm-cp-hue]"),hueThumb=dialog.querySelector("[data-fm-cp-hue-thumb]"),hexInput=dialog.querySelector("[data-fm-cp-hex]"),rIn=dialog.querySelector("[data-fm-cp-r]"),gIn=dialog.querySelector("[data-fm-cp-g]"),bIn=dialog.querySelector("[data-fm-cp-b]"),preview=dialog.querySelector("[data-fm-cp-preview]"),applyBtn=dialog.querySelector("[data-fm-cp-apply]"),dialog.querySelectorAll("[data-fm-cp-close]").forEach(function(el){el.addEventListener("click",close)}),document.addEventListener("keydown",function(e){e.key==="Escape"&&!dialog.hasAttribute("hidden")&&(e.preventDefault(),close())}),bindDrag(sv,function(x,y,w,h){hsv.s=Math.max(0,Math.min(1,x/w)),hsv.v=Math.max(0,Math.min(1,1-y/h)),syncFromHsv()}),bindDrag(hue,function(x,_y,w){hsv.h=Math.max(0,Math.min(360,x/w*360)),syncFromHsv()}),hexInput&&hexInput.addEventListener("input",function(){var v=(hexInput.value||"").replace(/[^0-9A-Fa-f]/g,"").slice(0,6).toUpperCase();v!==hexInput.value&&(hexInput.value=v),v.length===6&&syncFromHex(v)}),[rIn,gIn,bIn].forEach(function(el){el&&el.addEventListener("input",function(){var r=clamp255(parseInt(rIn.value,10)),g=clamp255(parseInt(gIn.value,10)),b=clamp255(parseInt(bIn.value,10));syncFromRgb(r,g,b)})}),applyBtn&&applyBtn.addEventListener("click",function(){var hex=currentHex(),cb=onCommitCb;close(),typeof cb=="function"&&cb(hex)}),!0):!1}function clamp255(n){return isNaN(n)?0:Math.max(0,Math.min(255,n))}function bindDrag(el,onUpdate){if(!el)return;var dragging=!1;function update(clientX,clientY){var rect=el.getBoundingClientRect(),x=clientX-rect.left,y=clientY-rect.top;onUpdate(x,y,rect.width,rect.height)}function onDown(e){dragging=!0,el.setPointerCapture&&el.setPointerCapture(e.pointerId),update(e.clientX,e.clientY),e.preventDefault()}function onMove(e){dragging&&(update(e.clientX,e.clientY),e.preventDefault())}function onUp(e){if(dragging){dragging=!1;try{el.releasePointerCapture&&el.releasePointerCapture(e.pointerId)}catch(_e){}}}el.addEventListener("pointerdown",onDown),el.addEventListener("pointermove",onMove),el.addEventListener("pointerup",onUp),el.addEventListener("pointercancel",onUp),document.addEventListener("pointermove",function(e){dragging&&update(e.clientX,e.clientY)}),document.addEventListener("pointerup",function(){dragging=!1})}function syncFromHsv(){renderAll()}function syncFromRgb(r,g,b){hsv=rgbToHsv(r,g,b),renderAll()}function syncFromHex(hex){var rgb=hexToRgb(hex);rgb&&syncFromRgb(rgb.r,rgb.g,rgb.b)}function currentHex(){var rgb=hsvToRgb(hsv.h,hsv.s,hsv.v);return rgbToHex(rgb.r,rgb.g,rgb.b)}function renderAll(){var rgb=hsvToRgb(hsv.h,hsv.s,hsv.v),hex=rgbToHex(rgb.r,rgb.g,rgb.b),huePure=hsvToRgb(hsv.h,1,1);sv&&(sv.style.backgroundColor="rgb("+huePure.r+","+huePure.g+","+huePure.b+")"),svThumb&&(svThumb.style.left=hsv.s*100+"%",svThumb.style.top=(1-hsv.v)*100+"%",svThumb.style.borderColor=hsv.v>.65?"#222329":"#ffffff"),hueThumb&&(hueThumb.style.left=hsv.h/360*100+"%"),preview&&(preview.style.backgroundColor="#"+hex),hexInput&&document.activeElement!==hexInput&&(hexInput.value=hex),rIn&&document.activeElement!==rIn&&(rIn.value=rgb.r),gIn&&document.activeElement!==gIn&&(gIn.value=rgb.g),bIn&&document.activeElement!==bIn&&(bIn.value=rgb.b)}function open(seedHex,onCommit){if(dialog){onCommitCb=onCommit,lastTrigger=document.activeElement;var rgb=hexToRgb(seedHex)||{r:255,g:0,b:0};hsv=rgbToHsv(rgb.r,rgb.g,rgb.b),isNaN(hsv.h)&&(hsv.h=0),renderAll(),dialog.removeAttribute("hidden"),applyBtn&&applyBtn.focus({preventScroll:!0});var trigger=document.getElementById("backgroundCustomColourTrigger");trigger&&trigger.setAttribute("aria-expanded","true")}}function close(){if(!(!dialog||dialog.hasAttribute("hidden"))){dialog.setAttribute("hidden",""),onCommitCb=null;var trigger=document.getElementById("backgroundCustomColourTrigger");
1trigger&&trigger.setAttribute("aria-expanded","false"),lastTrigger&&typeof lastTrigger.focus=="function"&&lastTrigger.focus({preventScroll:!0})}}window.FMColourPicker={open:open,close:close},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/342/assets/fm-color-picker.js.map?v=180545357769466037461785238569

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.