Spaces:
Running
Running
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 Download script.js from edvinstava/anc-date-wizard: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/edvinstava/anc-date-wizard/resolve/main/script.js
- Command line
-
hf download hf://spaces/edvinstava/anc-date-wizard/script.js
-
curl -L -o script.js https://huggingface.co/spaces/edvinstava/anc-date-wizard/resolve/main/script.js
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`; | |
| }); | |
| }); | |
| }); |