{{ "accessibility.skip_to_text" | t }}
- Choosing a selection results in a full page refresh.
(function () {
console.log('[light-switch] script start');
const checkbox = document.getElementById('lightCheckbox');
if (!checkbox) {
console.log('[light-switch] checkbox NOT found');
return;
}
const items = [
{
titleText: "Danish Rose Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/511aaec84c4d2e7f0ab227bac8eb92ab.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/944a72ad1f903d21dea0e68af7ad37bc.png"
},
{
titleText: "Modern Floral Glass Wall Lamp",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/169dd5d0eabd2aac415e17c30197a26b-1.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/b608dbb3809ca461b4f6043f028e0484-1.jpg"
},
{
titleText: "Cream Fabric Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3b5c704ea6f72c2a2f1a995c661cfae8.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/190917b0e27d5442524bbee0121c80f7.png"
},
{
titleText: "3D Printed Moon Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/5bc0c497b7864e269cb16229dc27ffab.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/452391ef4a59d7db4bacf8e828a8c494.png"
},
{
titleText: "Crown Feather Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1cc2a71d7d3437197a869fbaa99b35b0.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/c444391653cf250a61b6ed51138f9ed3.png"
},
{
titleText: "Luxury Crystal LED Ceiling Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/8ca0b4e7a73013d541db5f2ab13c2054.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/5ea107fb658f5bda434ad590ae76ff9b.png"
},
{
titleText: "Postmodern Luxury Crystal Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/8a6744293aec47ea7d4be29e87e33642.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3cc264f8f55b76c5b253be9e200b7181.png"
},
{
titleText: "Italian Minimalist Luxury Crystal Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1bac3c73b52facd88003fc2e80e265dd.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3ae383fc43a597b939a88faff76df03f.png"
},
{
titleText: "Postmodern Crystal Pendant Lamp",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/d4e82650754b66855799c85d5cba171d.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/986e3486918bf527213eb5f3991c088a.png"
},
{
titleText: "Nordic Iceberg LED Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/75a8c17459a2f251105c743e97cf6314.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/287978bd89a948a31e22bc73a030c440.png"
},
{
titleText: "Nordic 3-Light LED Dining Pendant",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/17249de0ea5208c93b6428ec0ab9eb65.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/df7d085003148500208d0b4da8ecbe03.jpg"
},
{
titleText: "Italian Minimalist Ring Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/7ca4940904e5b969b0777ad04a0b0851.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/4f5d87b6da61ff531048749c18601911.png"
},
{
titleText: "Modern Cream Ceiling Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/438af712fa17e199fbd1730bbbbc5149.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/d9a7b22c0b39dce58319d739773d362a.png"
},
{
titleText: "Nordic Shell Wall Sconce | Modern Bedroom & Hallway Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/5201a74677e82a87193581dee5612938.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/d082dcea7a5a7bbefd666ab544c8b421.png"
},
{
titleText: "Modern Solid Copper & Spanish Marble Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/0cd75175c341a71729f679972993acee.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/fb6c0038a11fe6885f3a43ddf4310da3.png"
},
{
titleText: "Wind Chime-Inspired Shell Table Lamp | Bedside Decor",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/f061fe7e48e02369c4d01fd978e91048.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/ed45b7901b59cf6f5ec2516fdccc13f5.png"
},
{
titleText: "Solid Copper & Marble Wall Sconce | French Vintage Style",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/fb54246f67321fc1120728fc4df9b208.jpg",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/003ac2a23270e59b050c62cd08f71ae5.png"
},
{
titleText: "Solid Copper Ginkgo Floor Lamp with Ceramic Leaves",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/836b79ae575ba61291ec5920e47555d2.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/40ce5b698f1175cfd6c2d021228f6b03.png"
},
{
titleText: "Modern Linear Glass Chandelier | Dining & Kitchen Island",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/08bb193b5b4975109b02b37eadc8152c.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/abca6072681c1506b7d168add6531e55.png"
},
{
titleText: "Glass Chandelier | Modern Italian Elegance",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/9920ff1a72663d15d0a498cb7ebcdce4.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/b2b1c3c5ca60375261369e59ddfac0d1.png"
},
{
titleText: "Modern 3-Light Linear LED Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/9b842f84d16a750ae849fa74073b1738.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3de3bc1430737adb2b017b1bb592e5b8.png"
},
{
titleText: "Adjustable Nordic LED Pendant Spotlight",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/a9af635debcc564035d00bb7961e8e7f.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/9ae01acf7b8c9910fd46aad1e865f87c.png"
},
{
titleText: "Nordic Glass Globe Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/c8b6f82b660b5cd5a1fe7e569442f603.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/e0898f66e3f5b503ab1fc3669470b89e.png"
},
{
titleText: "Nordic Gold Iron Wall Sconce",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/f51b0321c67ad5857c37348338fb30b1.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/b2274dace6c2ef55848e1e9ab2cedc59.png"
},
{
titleText: "Modern LED Bedside Wall Sconce",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/7836b365096d56cd598beb256a59eb66.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/e978e26124e1533439aa41efa84224af.png"
},
{
titleText: "Nordic Globe Glass LED Wall Lamp",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3d5f01cd6c02bb4c07aa9ffc12532bc7.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/b35df9ea13603c4a81cb5d69b13d7d48.png"
},
{
titleText: "Nordic Glass Globe Wall Sconce",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/30245775955b7e48d5c0a4dd56c3db42.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1c76267ae1c92a3054e9e5cd603e1b36.png"
},
{
titleText: "Nordic Glass Globe Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/2a0bf4cd1c2e3b2dd0035477b0e696e2.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/94acdeb1e2773a5ecbc06f7c111ff033.png"
},
{
titleText: "Modern Linear LED Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/dfc6027a5e5b0137cee11fadc94fd9d5.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/e209f302e06a011476bd49b8832dfe21.png"
},
{
titleText: "Nordic Minimalist Linear LED Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/fcfda6817a27a14733a09ade6da83e4e.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/b87004c324a9a2827b572918d2a33a65.png"
},
{
titleText: "Modern Asian LED Lantern Ceiling Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/80c94ef7a1c49710377fc598d370e7c8.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1ee19b8be5fd37785120ef2ac27d9fd5.png"
},
{
titleText: "Creative Bottle Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/26b41dfb2ef12e5fc2e3817465f38bae.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1351f0d52e3a0195fc937afe96924ea6.png"
},
{
titleText: "Modern Nordic Linear Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/a7d41b738db03da449d5d25b249938b7.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/1e6c52b74fc86700f4a29f7158fb925b.png"
},
{
titleText: "Nordic 3-Light Glass Globe Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/0ae54a6b429c49c8940187997265f641.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/5ea1db9d259322140e666ede68cfea88.png"
},
{
titleText: "Luxury Feather Cloud Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/7e2b6911d0ed66ec9cfa79122bd78a1d.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/62fbf86fa5b78540a3522a74ed30adfc.png"
},
{
titleText: "LED Feather Wall Sconce",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/e51c354059005c6f99c651c9491c50d5.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/3e9239354bdc23afaf43968892796273.png"
},
{
titleText: "Modern Square LED Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/093391faee0d547175d7a8baa432b8f7.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/45fd766427b62c6bc95f518818f05159.png"
},
{
titleText: "Modern Wave Linear Pendant Light",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/e08468bab30f60382f344225e8c408af.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/bac9fc302711f5bdfede73e7be7d791a.png"
},
{
titleText: "French Leaf Crystal Chandelier",
offImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/854e99c27d1f823f8f5e88465c092c66.png",
onImg: "https://cdn.shoppaas.com/uploads/913d837594e38633/d832ef67803a162c107f2a490bdce29f.png"
}
];
const titleMap = {};
items.forEach(item => {
titleMap[item.titleText.toLowerCase().trim()] = item;
});
const listContainerSelector = '#main-collection-product-grid';
const cardSelector = 'li.product.product-masonry-item';
let isLightOn = false;
let overlayRoot = null;
let renderTimer = null;
function findProductByCard(card) {
const titleEl = card.querySelector('h2, h3, p');
if (!titleEl) return null;
const pageText = titleEl.textContent.toLowerCase().trim();
for (const key in titleMap) {
if (pageText.includes(key)) {
return titleMap[key];
}
}
return null;
}
function createOverlayRoot() {
if (overlayRoot) return;
const listWrap = document.querySelector(listContainerSelector);
if (!listWrap) {
console.log('[light-switch] list container NOT found');
return;
}
listWrap.style.position = 'relative';
overlayRoot = document.createElement('div');
overlayRoot.className = 'product-light-overlay-container';
listWrap.appendChild(overlayRoot);
}
function renderOverlays() {
createOverlayRoot();
if (!overlayRoot) return;
overlayRoot.innerHTML = '';
const cards = document.querySelectorAll(cardSelector);
console.log('[light-switch] cards found:', cards.length);
cards.forEach((card, index) => {
const product = findProductByCard(card);
console.log('[light-switch] card', index, 'match:', product ? product.titleText : null);
if (!product) return;
card.style.position = 'relative';
const rect = card.getBoundingClientRect();
const listWrap = document.querySelector(listContainerSelector);
const listRect = listWrap.getBoundingClientRect();
const overlayImg = document.createElement('img');
overlayImg.className = 'product-light-single-img';
overlayImg.src = isLightOn ? product.onImg : product.offImg;
overlayImg.style.width = rect.width + 'px';
overlayImg.style.height = rect.height + 'px';
overlayImg.style.left = (rect.left - listRect.left) + 'px';
overlayImg.style.top = (rect.top - listRect.top) + 'px';
overlayRoot.appendChild(overlayImg);
});
}
function scheduleRender() {
clearTimeout(renderTimer);
renderTimer = setTimeout(renderOverlays, 200);
}
checkbox.addEventListener('change', function () {
isLightOn = checkbox.checked;
console.log('[light-switch] toggle, isLightOn:', isLightOn);
renderOverlays();
});
const observer = new MutationObserver(function () {
scheduleRender();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
window.addEventListener('resize', function () {
scheduleRender();
});
window.addEventListener('load', function () {
scheduleRender();
});
scheduleRender();
})();