Spaces:
Running
Running
File size: 1,706 Bytes
7b41fa1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// Search functionality
document.addEventListener('DOMContentLoaded', function() {
const searchInput = document.getElementById('searchInput');
if (searchInput) {
searchInput.addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const categoryCards = document.querySelectorAll('.category-card');
categoryCards.forEach(card => {
const title = card.querySelector('h2').textContent.toLowerCase();
const description = card.querySelector('p:not(.count)').textContent.toLowerCase();
if (title.includes(searchTerm) || description.includes(searchTerm)) {
card.style.display = 'flex';
} else {
card.style.display = 'none';
}
});
});
}
// Project search functionality (for category pages)
const projectSearchInput = document.getElementById('projectSearch');
if (projectSearchInput) {
projectSearchInput.addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const projectCards = document.querySelectorAll('.project-card');
projectCards.forEach(card => {
const title = card.querySelector('h3').textContent.toLowerCase();
const description = card.querySelector('p').textContent.toLowerCase();
if (title.includes(searchTerm) || description.includes(searchTerm)) {
card.style.display = 'block';
} else {
card.style.display = 'none';
}
});
});
}
});
|