Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish sort functions #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finish search Box
  • Loading branch information
mohamedelhefni committed May 4, 2020
commit 74591d79b36e93ae5c662fd9bb21d796b6ca6d25
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In this repo you will find some given express server configured to make some bas
- [x] Show list of requests below the form. (API: GET -> `/video-request`)
- [x] Vote up and down on each request. (API: PUT -> `/video-request/vote`)
- [x] Sorting options `new first` the default one, and `top voted first`.
- [ ] Search box to search for vide requests.
- [x] Search box to search for vide requests.
- [ ] Client-side validation for the fields with \* as required and for the email field, topic title should be max 100 length.
- [ ] Add signup/login form with email.
- [ ] Make votes unique so no one could cheat, using unique user, enhance the voting experience.
Expand Down
23 changes: 17 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,24 @@
</div>
<hr />
<h1 class="mb-4">List of requested videos</h1>
<div class="d-flex">
<div class="d-flex justify-content-between">
<div class="form-group">
<label for="sortList">Sort By</label>
<select class="form-control" id="sortList">
<option data-list-sort-by-new> new first</option>
<option data-list-sort-by-votes> top voted first</option>
</select>
<button class="btn btn-primary" data-list-sort-by-new>
Sort By New First
</button>
<button class="btn btn-primary" data-list-sort-by-votes>
Sort By Top Voted First
</button>
</div>
<div class="form-group">
<input
type="text"
name="search"
id="search"
placeholder="Search For Video Title"
class="form-control"
data-search-for-video
/>
</div>
</div>
<div id="listOfRequests">
Expand Down
16 changes: 15 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@ const videoForm = document.querySelector("[data-video-form-request]");
const videoRequestsContainer = document.getElementById("listOfRequests");
const sortByVotesBtn = document.querySelector("[data-list-sort-by-votes]");
const sortByNewBtn = document.querySelector("[data-list-sort-by-new]");
const searchForVideo = document.querySelector("[data-search-for-video]");

// search section

searchForVideo.addEventListener("keyup", () => {
let videoTitleValue = searchForVideo.value.toUpperCase();
for (let video of videoRequestsContainer.children) {
let videoTitle = video.querySelector("h3").textContent;
if (videoTitle.toUpperCase().indexOf(videoTitleValue) > -1) {
video.style.display = "";
} else {
video.style.display = "none";
}
}
});

// sort btn section

sortByVotesBtn.addEventListener("click", () => {
render("sortByVotes");
});
Expand Down