Skip to content

Commit

Permalink
implemented search functionality in profiles section
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjay singh authored and pranjay singh committed Oct 3, 2024
1 parent 8b5ee69 commit 48deae6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Binary file added .DS_Store
Binary file not shown.
15 changes: 8 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
document.addEventListener("DOMContentLoaded", function() {
const searchInput = document.getElementById('searchInput');
const profiles = document.querySelectorAll('.profile');
const date = document.getElementById('dates')
Expand All @@ -13,15 +14,14 @@ searchInput.addEventListener('input', filterProfiles);

function filterProfiles() {
const query = searchInput.value.toLowerCase();

profiles.forEach((profile) => {
const name = profile.querySelector('.name').textContent.toLowerCase();
const skills = profile.querySelector('.skills').textContent.toLowerCase();

if (name.includes(query) || skills.includes(query)) {
profile.style.display = 'block'; // Show matching profiles
const name = profile.querySelector('.name').textContent.toLowerCase();
const skills = Array.from(profile.querySelectorAll('.skills .skill'))
.map(skill => skill.textContent.toLowerCase());
if (name.includes(query) || skills.some(skill => skill.includes(query))) {
profile.style.display = 'block';
} else {
profile.style.display = 'none'; // Hide non-matching profiles
profile.style.display = 'none';
}
});
}
Expand All @@ -48,3 +48,4 @@ darkMode.addEventListener("click", () => {
button.classList.toggle('bg-color');
});
});
});

0 comments on commit 48deae6

Please sign in to comment.