(function () { /* START: customization for the image size + positioning within each spin wheel pie */ function getSlatRotationDeg(slat) { const style = slat.getAttribute("style") || ""; const m = style.match(/rotate\(([-\d.]+)deg\)/i); return m ? Number(m[1]) : null; } /** * update image attributes inside a slot (svg.slat), filtered by image href */ function updateSlotImageByRotation(rotationDeg, targetHref, attrs) { const wheel = document.querySelector(".wheel"); if (!wheel) return false; const slats = [...wheel.querySelectorAll("svg.slat")]; const slat = slats.find(s => getSlatRotationDeg(s) === rotationDeg); if (!slat) return false; const images = [...slat.querySelectorAll("image")]; const img = images.find((node) => { const href = node.getAttribute("href") || node.getAttributeNS("http://www.w3.org/1999/xlink", "href") || ""; return href.includes(targetHref); }); if (!img) return false; if (attrs.x != null) img.setAttribute("x", String(attrs.x)); if (attrs.y != null) img.setAttribute("y", String(attrs.y)); if (attrs.width != null) img.setAttribute("width", String(attrs.width)); if (attrs.height != null) img.setAttribute("height", String(attrs.height)); return true; } // function runWhenWheelReady(cb) { // const ready = () => document.querySelector(".wheel svg.slat image"); // if (ready()) return cb(); // const obs = new MutationObserver(() => { // if (ready()) { // obs.disconnect(); // cb(); // } // }); // obs.observe(document.documentElement, { childList: true, subtree: true }); // } function runWhenWheelReady(cb) { const ready = () => document.querySelector(".wheel svg.slat image"); if (ready()) cb(); // keep watching indefinitely — the wheel's slats get destroyed and // rebuilt on every spin (spinwin-renderer.js removes+recreates .slat), // so the fix needs to reapply each time, not just once on page load const obs = new MutationObserver(() => { if (ready()) cb(); }); obs.observe(document.documentElement, { childList: true, subtree: true }); } /** * per-slot configuration: * - rotationDeg: match the slat's rotate(...) value * - targetHref: a unique part of that image URL * - attrs: the x/y/width/height you want (only x is set here — width/height * are already handled correctly for all platforms via frontend-custom.css) */ const SLOT_IMAGE_TWEAKS = [ { rotationDeg: 0, targetHref: "wheel-prize-macbook-neo-1783956868-203949983.png", attrs: { x: "46%" } }, { rotationDeg: 60, targetHref: "wheel-prize-tngrm1-1783956877-1473334494.png", attrs: { x: "46%" } }, { rotationDeg: 120, targetHref: "wheel-prize-fujifilm-1783956892-1994672803.png", attrs: { x: "46%" } }, { rotationDeg: 180, targetHref: "wheel-prize-tngrm8-1783956899-1944890562.png", attrs: { x: "46%" } }, { rotationDeg: 240, targetHref: "wheel-prize-jd-sports-1783956917-1349143758.png", attrs: { x: "46%" } }, { rotationDeg: 300, targetHref: "wheel-prize-tngrm5-1783956927-139511838.png", attrs: { x: "46%" } }, ]; function applyAllSlotTweaks() { SLOT_IMAGE_TWEAKS.forEach(cfg => { updateSlotImageByRotation(cfg.rotationDeg, cfg.targetHref, cfg.attrs); }); } runWhenWheelReady(() => { applyAllSlotTweaks(); }); /* END: customization for the image size + positioning within each spin wheel pie */ })(); /* START: default country code dropdowns to Malaysia */ function initCountryCodes(dropdown_el, default_country) { const my = { call_code: '60', name: 'Malaysia' }; setTimeout(function() { if ($(dropdown_el).hasClass('select2-hidden-accessible')) { $(dropdown_el).select2('destroy'); } $(dropdown_el).find('option').remove(); var myOption = new Option('+' + my.call_code, my.call_code, true, true); $(dropdown_el).append(myOption); if ($(dropdown_el).hasClass('select2-hidden-accessible')) { $(dropdown_el).select2(); } $(dropdown_el).trigger('change'); }, 100); } /* END: default country code dropdowns to Malaysia */