|
| 1 | +import { setupNavigation, setBoneAndSubbones, disableButtons } from './navigation.js'; |
| 2 | +import { updateDescription } from './description.js'; // Assuming you already have this |
| 3 | + |
| 4 | +document.addEventListener('DOMContentLoaded', () => { |
| 5 | + const prevButton = document.getElementById('prev-button'); |
| 6 | + const nextButton = document.getElementById('next-button'); |
| 7 | + const subboneDropdown = document.getElementById('subbone-dropdown'); |
| 8 | + |
| 9 | + setupNavigation(prevButton, nextButton, subboneDropdown, updateDescription); |
| 10 | + |
| 11 | + // Example: when a new bone is selected |
| 12 | + document.getElementById('bone-dropdown').addEventListener('change', (event) => { |
| 13 | + const selectedBone = event.target.value; |
| 14 | + const selectedSubbones = getSubbonesForBone(selectedBone); // You need to implement this |
| 15 | + |
| 16 | + setBoneAndSubbones(selectedBone, selectedSubbones); |
| 17 | + |
| 18 | + // Update the dropdown options |
| 19 | + populateSubboneDropdown(subboneDropdown, selectedSubbones); |
| 20 | + |
| 21 | + disableButtons(prevButton, nextButton); |
| 22 | + }); |
| 23 | +}); |
| 24 | + |
| 25 | +function populateSubboneDropdown(dropdown, subbones) { |
| 26 | + dropdown.innerHTML = ''; |
| 27 | + subbones.forEach((subbone, index) => { |
| 28 | + const option = document.createElement('option'); |
| 29 | + option.value = index; |
| 30 | + option.textContent = subbone; |
| 31 | + dropdown.appendChild(option); |
| 32 | + }); |
| 33 | +} |
| 34 | + |
| 35 | +// Dummy placeholder for subbones fetching |
| 36 | +function getSubbonesForBone(bone) { |
| 37 | + const exampleData = { |
| 38 | + Humerus: ['Lateral Epicondyle', 'Medial Epicondyle'], |
| 39 | + Ulna: ['Olecranon', 'Coronoid Process'] |
| 40 | + }; |
| 41 | + return exampleData[bone] || []; |
| 42 | +} |
0 commit comments