document.addEventListener('DOMContentLoaded', function() { // Calculate button functionality const calculateBtn = document.querySelector('button'); const dateInput = document.querySelector('input[type="date"]'); const tableRows = document.querySelectorAll('tbody tr'); calculateBtn.addEventListener('click', function() { if (!dateInput.value) { alert('Please enter a valid LMP date'); return; } // Add animation to button this.classList.add('animate-pulse-once'); setTimeout(() => { this.classList.remove('animate-pulse-once'); }, 500); // Here would be the actual calculation logic // For now, we'll just simulate it with random dates const lmpDate = new Date(dateInput.value); const today = new Date(); tableRows.forEach((row, index) => { const visitNum = index + 1; const daysToAdd = visitNum * 14 + Math.floor(Math.random() * 7); const visitDate = new Date(lmpDate); visitDate.setDate(visitDate.getDate() + daysToAdd); const gaWeeks = Math.floor(daysToAdd / 7); const gaDays = daysToAdd % 7; row.cells[1].textContent = visitDate.toLocaleDateString(); row.cells[2].textContent = `${gaWeeks}+${gaDays} weeks`; }); }); });