anc-date-wizard / script.js
edvinstava's picture
That's an excellent choice. **TypeScript** will significantly improve the development of this plugin, especially for managing the complex date logic and the multi-tier scheduling rules you provided. It will help catch errors related to dates, numbers, and the custom data structure early on.
387cb67 verified
Raw History Blame Contribute Delete
1.43 kB
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`;
});
});
});