document.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('.jh-flash-sale').forEach(function (section) { const track = section.querySelector('.jh-flash-track'); const prev = section.querySelector('.jh-flash-prev'); const next = section.querySelector('.jh-flash-next'); /* =========================== SLIDER NAVIGATION =========================== */ function getScrollAmount() { const card = track.querySelector('.jh-flash-card'); if (!card) return track.clientWidth; const styles = window.getComputedStyle(track); const gap = parseFloat(styles.columnGap || styles.gap) || 0; return card.getBoundingClientRect().width + gap; } if (prev) { prev.addEventListener('click', function () { track.scrollBy({ left: -getScrollAmount(), behavior: 'smooth' }); }); } if (next) { next.addEventListener('click', function () { track.scrollBy({ left: getScrollAmount(), behavior: 'smooth' }); }); } /* =========================== COUNTDOWN =========================== */ const saleEnd = parseInt( section.dataset.saleEnd || '0', 10 ); if (!saleEnd) return; const hourNode = section.querySelector('[data-jh-hours]'); const minuteNode = section.querySelector('[data-jh-minutes]'); const secondNode = section.querySelector('[data-jh-seconds]'); function updateCountdown() { let distance = saleEnd - Date.now(); if (distance <= 0) { hourNode.textContent = '00'; minuteNode.textContent = '00'; secondNode.textContent = '00'; clearInterval(timer); /* * Bisa diganti reload jika ingin section * otomatis hilang setelah flash sale selesai. */ return; } const totalHours = Math.floor(distance / (1000 * 60 * 60)); const minutes = Math.floor( (distance % (1000 * 60 * 60)) / (1000 * 60) ); const seconds = Math.floor( (distance % (1000 * 60)) / 1000 ); hourNode.textContent = String(totalHours).padStart(2, '0'); minuteNode.textContent = String(minutes).padStart(2, '0'); secondNode.textContent = String(seconds).padStart(2, '0'); } updateCountdown(); const timer = setInterval(updateCountdown, 1000); }); });

Tempat Tidur Tingkat

Hubungi Kami ?