Spaces:
Running
Running
File size: 1,433 Bytes
387cb67 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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`;
});
});
}); |