RetroDECK-Website/scripts/features.js

31 lines
1 KiB
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');
2024-04-23 17:14:44 +00:00
// let currentFeature = 0;
2024-04-23 16:16:44 +00:00
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
featureTitles[j].className = 'row feature-list-item rounded-3';
featureTitles[j].style = '';
2024-04-23 16:16:44 +00:00
}
2024-04-23 17:14:44 +00:00
// currentFeature = i;
// Update the active feature
2024-04-23 16:16:44 +00:00
featureTitles[i].id = 'active-feature-item';
featureDetails[i].id = 'active-feature-detail'
2024-04-23 17:14:44 +00:00
// Handle styles
featureTitles[i].className += ' gradient-spin my-gradient';
2024-04-23 16:16:44 +00:00
}