Skip to content

Commit

Permalink
Revert "Added Search functionality"
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteashgupta1 authored Oct 18, 2024
1 parent 666571f commit 4ccc405
Show file tree
Hide file tree
Showing 2 changed files with 1,286 additions and 68 deletions.
68 changes: 0 additions & 68 deletions blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ <h2>Forgot Password</h2>
</header>
</div>

<div class="search-container">
<input type="text" id="searchInput" placeholder="Search blogs...">
<button onclick="performSearch()"><i class="fas fa-search"></i></button>
</div>
<!--header-->

<!--mainn-->
Expand Down Expand Up @@ -921,32 +917,6 @@ <h5 class="commenter-name">${comment.name}</h5>
animation: gradient 15s ease infinite;
background-size: 400% 400%;
}

.search-container {
display: flex;
align-items: center;
margin-right: 20px;
margin-top: 50px;
margin-left: 230px;

}

#searchInput {
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px 0 0 4px;
font-size: 16px;
width: 200px;
}

.search-container button {
padding: 8px 12px;
background: #F88379;
color: white;
border: 1px solid #F88379;
border-radius: 0 4px 4px 0;
cursor: pointer;
}
</style>

<!-- Toast Notification -->
Expand Down Expand Up @@ -1329,44 +1299,6 @@ <h2 class="footer-title secondary-title mt-2">Connect with us</h2>
modal.style.display = "none";
}
}


function performSearch() {
const searchQuery = document.getElementById('searchInput').value.toLowerCase();
const blogPosts = document.querySelectorAll('.grid-item');

blogPosts.forEach(post => {
const title = post.querySelector('.text-title').textContent.toLowerCase();
const date = post.querySelector('.secondary-title').textContent.toLowerCase();

if (title.includes(searchQuery) || date.includes(searchQuery)) {
post.style.display = 'block';
} else {
post.style.display = 'none';
}
});
}

// Event listener for real-time search
document.getElementById('searchInput').addEventListener('input', performSearch);

// Function to reset the search
function resetSearch() {
document.getElementById('searchInput').value = '';
const blogPosts = document.querySelectorAll('.grid-item');
blogPosts.forEach(post => {
post.style.display = 'block';
});
}

// Add reset button next to search bar
const searchContainer = document.querySelector('.search-container');
const resetButton = document.createElement('button');
resetButton.innerHTML = '<i class="fas fa-times"></i>';
resetButton.onclick = resetSearch;
resetButton.style.marginLeft = '5px';
searchContainer.appendChild(resetButton);

</script>

<style>
Expand Down
Loading

0 comments on commit 4ccc405

Please sign in to comment.