generated from CodeYourFuture/tv-show-dom-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Chizim - tv-show-project #10
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
Open
scarabeo7
wants to merge
65
commits into
for-review
Choose a base branch
from
master
base: for-review
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
a301099
Completed level 100
scarabeo7 19dfbd3
Added search bar function
scarabeo7 11e671b
done level 300
scarabeo7 22b075a
added fetch function
scarabeo7 189ec73
added fetch request
scarabeo7 ab1736b
Added workflow folder and file for git action
scarabeo7 d2ed663
Removed and added new config for AWS
scarabeo7 0a13a61
Refactoring code
scarabeo7 d7d2b41
creating and copying file to s3
scarabeo7 6a94329
added aws region for s3
scarabeo7 b8b3608
testing aws
scarabeo7 d0aa19d
test 2
scarabeo7 eaffd93
test 3
scarabeo7 f512e99
test 4
scarabeo7 8b64594
test 6
scarabeo7 03694b7
Added html label tag for list of tv-shows
scarabeo7 26bdcff
Created functions to sort and display all shows
scarabeo7 5893ee8
Added styling to page
scarabeo7 b4aa01e
Added html label tag for list of tv-shows
scarabeo7 9d34ed9
Added styling to page
scarabeo7 bad4f37
Created functions to sort and display all shows
scarabeo7 0c0d649
Merge pull request #1 from scarabeo7/tv-show-test
scarabeo7 4e598f0
Added disclaimer to page
scarabeo7 d7d3348
Merge pull request #2 from scarabeo7/tv-show-test
scarabeo7 5ae033c
removed ls command
scarabeo7 1da018d
Merge pull request #3 from scarabeo7/tv-show-test
scarabeo7 2749df1
refactored index.html
scarabeo7 e253ecc
changed css id names
scarabeo7 c159b10
completed level 400
scarabeo7 0ce3f5a
Merge pull request #5 from scarabeo7/tv-show-test
scarabeo7 14da13b
Added styling
scarabeo7 aae1ae2
Merge pull request #6 from scarabeo7/tv-show-test
scarabeo7 26c6dc0
Added styling to episode header
scarabeo7 8c45466
Refactored and added comments on code
scarabeo7 024539f
Merge pull request #7 from scarabeo7/tv-show-test
scarabeo7 106c2cd
Added show titletag on to display on page
scarabeo7 921b170
Refactored and displayed show name on page
scarabeo7 e60e5d1
Added show titletag on to display on page
scarabeo7 2d1a5d1
Refactored and displayed show name on page
scarabeo7 2082033
Merge branch 'master' into tv-show-test
scarabeo7 fe7a047
Merge pull request #8 from scarabeo7/tv-show-test
scarabeo7 93c875d
Added css media query for responsiveness
scarabeo7 760a30f
Merge pull request #9 from scarabeo7/tv-show-test
scarabeo7 052adc2
Working on level 500
scarabeo7 3a99f09
Merge branch 'tv-show-test' of githubcom:scarabeo7
scarabeo7 8b5f226
Merge pull request #11 from scarabeo7/tv-show-test
scarabeo7 b5c81de
Added show search bar
scarabeo7 80dc49f
Corrected git push mistakes
scarabeo7 47496a6
Merge pull request #12 from scarabeo7/tv-show-test
scarabeo7 033eaf8
formatting and refactoring, work in progress still
scarabeo7 370c911
Merge pull request #13 from scarabeo7/tv-show-test
scarabeo7 c238921
Added styling to shows ratings
scarabeo7 b0577af
Merge pull request #14 from scarabeo7/tv-show-test
scarabeo7 deff775
Fixed episode dropdown issue. L500 completed
scarabeo7 634d853
Merge pull request #15 from scarabeo7/tv-show-test
scarabeo7 cc04098
Refactored shows details panel
scarabeo7 436863a
Merge pull request #16 from scarabeo7/tv-show-test
scarabeo7 bcd8706
Added button to return to all shows
scarabeo7 e4392ad
Merge pull request #17 from scarabeo7/tv-show-test
scarabeo7 83376da
Changed and added styling
scarabeo7 fe1b76e
Merge pull request #18 from scarabeo7/tv-show-test
scarabeo7 91f0983
Refactored and formatted codes
scarabeo7 228ea86
Merge pull request #19 from scarabeo7/tv-show-test
scarabeo7 202f621
Updated media querry
scarabeo7 e2ac891
Merge pull request #20 from scarabeo7/tv-show-test
scarabeo7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: AWS deploy | ||
|
|
||
| # Run this workflow every time a new commit pushed to your repository | ||
| on: push | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Testing to Amazon S3 | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Configure AWS credentials from Test account | ||
| uses: aws-actions/configure-aws-credentials@v1 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: eu-west-1 | ||
|
|
||
| - name: Copy files to the test website with the AWS CLI | ||
| run: | | ||
| aws s3 sync . s3://tv-show-chizim | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "liveServer.settings.port": 5501 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,218 @@ | ||
| //You can edit ALL of the code here | ||
| const mainElem = document.getElementById("main-container"); | ||
| const showDropDown = document.getElementById("show-dropdown"); | ||
| const searchWrapper = document.getElementById("search-wrapper"); | ||
| const searchBar = document.getElementById("searchBar"); | ||
| const showSearchBar = document.getElementById("searchShow"); | ||
| const select = document.createElement("select"); | ||
| const seeAllElements = document.createElement("option"); | ||
| const paragraph = document.getElementById("display-text"); | ||
| const homeButton = document.getElementById("button"); | ||
| let allShows = getAllShows(); | ||
|
|
||
| // function to display all shows on when page loads | ||
| function displayShows(allShows) { | ||
| showsInformation(allShows); | ||
| document.querySelectorAll(".show-container").forEach((show) => { | ||
| let showId = show.getAttribute("data-id"); | ||
| show.addEventListener("click", () => { | ||
| showDropDown.value = showId; | ||
| showSearchBar.style.display = "none"; | ||
| select.style.display = "block"; | ||
| homeButton.style.display = "block"; | ||
| episodeSet(showId); | ||
| }); | ||
| }); | ||
| paragraph.innerHTML = `Displaying ${allShows.length} of ${allShows.length} shows`; | ||
|
|
||
| showSearchBar.addEventListener("input", searchShow); | ||
| } | ||
|
|
||
| function setup() { | ||
| const allEpisodes = getAllEpisodes(); | ||
| makePageForEpisodes(allEpisodes); | ||
| displayShows(allShows); | ||
|
|
||
| // Creates show DropDown Options | ||
| showList = allShows.forEach((show) => { | ||
| showDropDown.innerHTML += ` | ||
| <option value= "${show.id}"> | ||
| ${show.name} | ||
| </option> | ||
| `; | ||
| }); | ||
| } | ||
|
|
||
| // Return to all shows button event | ||
| homeButton.style.display = "none"; | ||
| homeButton.addEventListener("click", () => { | ||
| displayShows(allShows); | ||
| select.style.display = "none"; | ||
| homeButton.style.display = "none"; | ||
| searchBar.style.display = "none"; | ||
| showSearchBar.style.display = "block"; | ||
| }); | ||
|
|
||
| // sorts the show dropDown in alphabetical order | ||
| allShows.sort((a, b) => { | ||
| if (a.name.toLowerCase() > b.name.toLowerCase()) { | ||
| return 1; | ||
| } else if (b.name.toLowerCase() > a.name.toLowerCase()) { | ||
| return -1; | ||
| } else { | ||
| return 0; | ||
| } | ||
| }); | ||
|
|
||
| // markup function that holds shows data to display (level 500) | ||
| function showListMarkup(show) { | ||
| const imageMarkUp = show.image | ||
| ? `<img src = "${show.image.medium}" alt "Show image">` | ||
| : ""; | ||
| const showMarkUp = `<div class = "show-container" data-id = "${ | ||
| show.id | ||
| }"><h2>${show.name}</h2> | ||
| ${imageMarkUp} <div class = "show-summary">${ | ||
| show.summary | ||
| }</div><div class = "ratings"><p><strong>Rated:</strong> ${ | ||
| show.rating.average | ||
| }</p><p><strong>Genres:</strong> ${show.genres.join( | ||
| " | " | ||
| )}</p><p><strong>Status:</strong> ${ | ||
| show.status | ||
| }</p><p><strong>Runtime:</strong> ${show.runtime}</p></div></div>`; | ||
| return showMarkUp; | ||
| } | ||
|
|
||
| // function that loads shows contents (level 500) | ||
| function showsInformation(showList) { | ||
| let showContent = ""; | ||
| showList.forEach((show) => { | ||
| showContent += showListMarkup(show); | ||
| }); | ||
| mainElem.innerHTML = showContent; | ||
| } | ||
|
|
||
| // function adds "0" to number to give it a double digit // | ||
| function zeroPadded(episodeCode) { | ||
| return episodeCode.toString().padStart(2, 0); | ||
| } | ||
|
|
||
| // markup function that holds each shows episodes data to display | ||
| function helperMarkup(episode) { | ||
| const imageMarkUp = episode.image | ||
| ? `<img src = "${episode.image.medium}" alt "Show image">` | ||
| : ""; | ||
| const markUp = `<div class = "episode-container"><h2>${ | ||
| episode.name | ||
| } - S${zeroPadded(episode.season)} E${zeroPadded(episode.number)}</h2> | ||
| ${imageMarkUp} ${episode.summary !== null ? episode.summary : ""}</div>`; | ||
| return markUp; | ||
| } | ||
|
|
||
| // function to fetch shows from API and displays episodes | ||
| function episodeSet(selectedShow) { | ||
| fetch(`https://api.tvmaze.com/shows/${selectedShow}/episodes`) | ||
| .then((response) => response.json()) | ||
| .then((data) => { | ||
| allEpisodes = data; | ||
| searchBar.addEventListener("input", searchFunction); | ||
| addSelectOption(allEpisodes); | ||
| makePageForEpisodes(allEpisodes); | ||
| paragraph.innerHTML = `Displaying ${allEpisodes.length} of ${allEpisodes.length} episodes`; | ||
| }) | ||
| .catch((error) => console.log(error)); | ||
| } | ||
|
|
||
| showDropDown.addEventListener("change", (e) => { | ||
| if (e.target.value === "all") { | ||
| displayShows(allShows); | ||
| searchBar.style.display = "none"; | ||
| paragraph.innerHTML = `Displaying ${allShows.length} of ${allShows.length} shows`; | ||
| select.style.display = "none"; | ||
| showSearchBar.style.display = "block"; | ||
| homeButton.style.display = "none"; | ||
| } else { | ||
| episodeSet(e.target.value); | ||
| select.style.display = "block"; | ||
| showSearchBar.style.display = "none"; | ||
| homeButton.style.display = "block"; | ||
| } | ||
| }); | ||
|
|
||
| // function to load episode contents | ||
| function makePageForEpisodes(episodeList) { | ||
| const rootElem = document.getElementById("root"); | ||
| rootElem.textContent = `Got ${episodeList.length} episode(s)`; | ||
| let pageContent = ""; | ||
| episodeList.forEach((episode) => { | ||
| pageContent += helperMarkup(episode); | ||
| }); | ||
| mainElem.innerHTML = pageContent; | ||
| searchBar.style.display = "block"; | ||
| } | ||
|
|
||
| function episodeCount(filteredInput) { | ||
| paragraph.innerHTML = `Displaying ${filteredInput.length} of ${allEpisodes.length} episodes`; | ||
| } | ||
|
|
||
| function showCount(filteredInput) { | ||
| paragraph.innerHTML = `Displaying ${filteredInput.length} of ${allShows.length} shows`; | ||
| } | ||
|
|
||
| // function to search through episode list | ||
| function searchFunction(e) { | ||
| let searchString = e.target.value.toLowerCase(); | ||
| let filteredInput = allEpisodes.filter((char) => { | ||
| return ( | ||
| char.name.toLowerCase().includes(searchString) || | ||
| char.summary.toLowerCase().includes(searchString) | ||
scarabeo7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| }); | ||
| mainElem.innerHTML = ""; | ||
| makePageForEpisodes(filteredInput); | ||
| episodeCount(filteredInput); | ||
| } | ||
|
|
||
| // function to search through show list | ||
| function searchShow(e) { | ||
| let searchString = e.target.value.toLowerCase(); | ||
| let filteredInput = allShows.filter((char) => { | ||
| return ( | ||
| char.name.toLowerCase().includes(searchString) || | ||
| char.genres.join(" ").toLowerCase().includes(searchString) || | ||
| char.summary.toLowerCase().includes(searchString) | ||
| ); | ||
| }); | ||
| mainElem.innerHTML = ""; | ||
| displayShows(filteredInput); | ||
| showCount(filteredInput); | ||
| } | ||
|
|
||
| searchBar.style.display = "none"; | ||
| searchBar.addEventListener("input", searchFunction); | ||
|
|
||
| // function to select episode from episode dropdown | ||
| function addSelectOption(episodeList) { | ||
| select.innerHTML = ""; | ||
| seeAllElements.innerHTML = `See all episodes`; | ||
| select.appendChild(seeAllElements); | ||
| episodeList.forEach((episode) => { | ||
| let option = document.createElement("option"); | ||
| option.value = episode.name; | ||
| option.innerHTML = `${episode.name} - S${zeroPadded( | ||
| episode.season | ||
| )} E${zeroPadded(episode.number)}`; | ||
| select.appendChild(option); | ||
| }); | ||
| select.addEventListener("change", (e) => { | ||
| let selectedEpisode; | ||
| if (e.target.value === "See all episodes") { | ||
| selectedEpisode = episodeList; | ||
| } else { | ||
| selectedEpisode = episodeList.filter((episode) => { | ||
| return episode.name === e.target.value; | ||
| }); | ||
| } | ||
| makePageForEpisodes(selectedEpisode); | ||
| episodeCount(selectedEpisode); | ||
| }); | ||
| searchWrapper.appendChild(select); | ||
| } | ||
|
|
||
| window.onload = setup; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.