From 48deae6f423dd27b5dd4f2e9ef6766fadbe15d41 Mon Sep 17 00:00:00 2001 From: pranjay singh Date: Thu, 3 Oct 2024 21:38:15 +0530 Subject: [PATCH] implemented search functionality in profiles section --- .DS_Store | Bin 0 -> 6148 bytes script.js | 15 ++++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b2db5aee5e949b284269a4175ba9bead8c141240 GIT binary patch literal 6148 zcmeHK!Ab)$5Pi`Fi+U(}DdHgq51zy#3f|VTet`7gMX0n}TA}L}YJ1*4Q1I?2c<>_x z|He<~Op>)5*DanzWd@R$oy;V!Z`n)(K((fE6Q~2IQDY3&sr$lso?FRQoQIPYuQ3`l z+r2aymm3Wx%~Q33Pe;{XHP;LiJgw_e_eaFEX>X%uxwX_tJptKE}}&gJWwKOZlh z9}f#>!}dFCv6iomA*SehyCZlmM-(~S&kl1ApVmpz1(WJ1j}LUtXNC!SND-s&^TEF3 zQ-~U}5P z8 zb*}&C)%SltNuERjQQ%)Gpn|9!wdg0g+FJT?Tx&J8Yiev9msvC^)VXqO23(38)Qr)b X<^f^oFtbP=GWjE5WROl2_)!JsUd)SY literal 0 HcmV?d00001 diff --git a/script.js b/script.js index ce9acbd..ed32f5f 100644 --- a/script.js +++ b/script.js @@ -1,3 +1,4 @@ +document.addEventListener("DOMContentLoaded", function() { const searchInput = document.getElementById('searchInput'); const profiles = document.querySelectorAll('.profile'); const date = document.getElementById('dates') @@ -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'; } }); } @@ -48,3 +48,4 @@ darkMode.addEventListener("click", () => { button.classList.toggle('bg-color'); }); }); +}); \ No newline at end of file