-modern-section'); if(!section) return; const faqItems = section.querySelectorAll('.bt-faq-item'); faqItems.forEach(function(item, index){ const button = item.querySelector('.bt-faq-question'); const answer = item.querySelector('.bt-faq-answer'); if(!button || !answer) return; answer.id = '-faq-answer-final-' + index; button.setAttribute('aria-controls', answer.id); button.setAttribute('aria-expanded', item.classList.contains('active') ? 'true' : 'false'); button.addEventListener('click', function(event){ event.preventDefault(); event.stopPropagation(); const wasOpen = item.classList.contains('active'); faqItems.forEach(function(other){ other.classList.remove('active'); const otherButton = other.querySelector('.bt-faq-question'); if(otherButton) otherButton.setAttribute('aria-expanded','false'); }); if(!wasOpen){ item.classList.add('active'); button.setAttribute('aria-expanded','true'); } }); }); const cards = Array.from(section.querySelectorAll('.bt-review-card')); const dotsWrap = section.querySelector('.bt-dots'); const prev = section.querySelector('.bt-nav-btn.prev'); const next = section.querySelector('.bt-nav-btn.next'); let current = 0; let timer; function render(index){ current = (index + cards.length) % cards.length; cards.forEach(function(card,i){ card.classList.toggle('active',i === current); }); dotsWrap.querySelectorAll('.bt-dot').forEach(function(dot,i){ dot.classList.toggle('active',i === current); }); } cards.forEach(function(_,i){ const dot = document.createElement('button'); dot.type = 'button'; dot.className = 'bt-dot' + (i === 0 ? ' active' : ''); dot.setAttribute('aria-label','Tampilkan review ' + (i + 1)); dot.addEventListener('click',function(){ render(i); restart(); }); dotsWrap.appendChild(dot); }); function restart(){ clearInterval(timer); timer = setInterval(function(){ render(current + 1); },6000); } prev.addEventListener('click',function(){ render(current - 1); restart(); }); next.addEventListener('click',function(){ render(current + 1); restart(); }); restart(); })();