Skip to content

Commit

Permalink
Friend filter
Browse files Browse the repository at this point in the history
Added filter for finding a specific friend on friends page.
  • Loading branch information
MichaelLaffan1 committed Nov 12, 2023
1 parent 5e7ab51 commit f4f26e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions client/agora/public/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,22 @@ function getOffset( el ) {
};
}

const friendsContainer = document.querySelectorAll( '#friend-card' );

function filterFriends( searchTerm ){

for ( const friend of friendsContainer ){

const friendCard = friend.outerText.toLowerCase();

if ( friendCard.includes( searchTerm.toLowerCase() ) ){
friend.style.display = 'block';
} else {

Check failure on line 1200 in client/agora/public/js/dashboard.js

View workflow job for this annotation

GitHub Actions / ESLint

client/agora/public/js/dashboard.js#L1200

Closing curly brace appears on the same line as the subsequent block (brace-style)
friend.style.display = 'none';
}
}
}

function deleteFriend( friendshipId ) {
if (confirm( "Are you sure you want to remove this friend?") == true){

Check failure on line 1207 in client/agora/public/js/dashboard.js

View workflow job for this annotation

GitHub Actions / ESLint

client/agora/public/js/dashboard.js#L1207

There must be a space after this paren (space-in-parens)

Check failure on line 1207 in client/agora/public/js/dashboard.js

View workflow job for this annotation

GitHub Actions / ESLint

client/agora/public/js/dashboard.js#L1207

There must be a space before this paren (space-in-parens)

Check failure on line 1207 in client/agora/public/js/dashboard.js

View workflow job for this annotation

GitHub Actions / ESLint

client/agora/public/js/dashboard.js#L1207

There must be a space before this paren (space-in-parens)
fetch( "/api/v1/auth/friends/deleteFriend", {
Expand Down
4 changes: 2 additions & 2 deletions client/agora/views/friends/partials/gallery/control-bar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</div> -->
<div class='col-md-4'>
<!--Search bar-->
<input id="topic-search" class="card-search form-control" placeholder="Search"
oninput="queryTopics(document.getElementById('topic-search').value, topicArr) " />
<input id="friend-search" class="card-search form-control" placeholder="Search Friends"
oninput="filterFriends( this.value ) " />
</div>

<div class="btn-toolbar col-md-8" role="toolbar" aria-label="Dashboard Tools">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% if (friends.length > 0) { %>
<% friends.forEach((friend) => { %>
<!-- Friend Card -->
<div class="col mb-3 align-items-stretch gallery-col query-countable a-friend" id="friend-card-<%= friend.friendship_id %>">
<div class="col mb-3 align-items-stretch gallery-col query-countable a-friend" id="friend-card">
<div class="card h-100" id="f-gv-<%= friend.friendship_id %>" data-id="<%= friend.friendship_id %>" onmouseover="toggleMoreOptionsOn(id)" onmouseout="toggleMoreOptionsOff(id)">
<div class="dropdown dropbtn trigger1 trigger2 grid-options" id="f-gv-option-<%= friend.friendship_id %>" data-id="<%= friend.friendship_id %>" style="visibility: hidden">
<img src="/assets/img/buttons/more-options.png" class="dropbtn" />
Expand Down

0 comments on commit f4f26e5

Please sign in to comment.