RetroDECK-Website/scripts/features.js

23 lines
784 B
JavaScript
Raw Normal View History

2024-04-23 16:16:44 +00:00
featureTitles = document.getElementsByClassName('feature-list-item');
featureDetails = document.getElementsByClassName('feature-detail-container');
for (let i = 0; i < featureTitles.length; i++) {
featureTitles[i].addEventListener('click', function () {
updateActiveFeature(i);
}, false)
2024-04-23 17:14:44 +00:00
if (featureTitles[i].id != 'active-feature-item') {
featureTitles[i].className = 'row feature-list-item rounded-3';
}
2024-04-23 16:16:44 +00:00
}
function updateActiveFeature(i) {
2024-04-23 17:14:44 +00:00
// Reset all
2024-04-23 16:16:44 +00:00
for (let j = 0; j < featureTitles.length; j++) {
featureTitles[j].removeAttribute('id');
featureDetails[j].removeAttribute('id');
}
2024-04-23 17:14:44 +00:00
// Update the active feature
2024-04-23 16:16:44 +00:00
featureTitles[i].id = 'active-feature-item';
featureDetails[i].id = 'active-feature-detail'
}