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

review requested #1

Open
wants to merge 49 commits into
base: for-review
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
813d08b
added name and github user name
Junitalama Apr 26, 2023
c6696d5
level 100 done
Junitalama Apr 27, 2023
bc05c6f
added style
Junitalama Apr 27, 2023
3044dac
added searchbar and select menu
Junitalama May 1, 2023
a44ad91
Update script.js
Junitalama May 2, 2023
72351c2
Update script.js
Junitalama May 2, 2023
a22bacb
added styling
Junitalama May 2, 2023
fc31628
style added
Junitalama May 2, 2023
9f98877
footer
Junitalama May 3, 2023
0014953
level 200 done
Junitalama May 3, 2023
84532e9
level 300 done
Junitalama May 8, 2023
40ebf7f
Update script.js
Junitalama May 8, 2023
2b9dbd6
Update script.js
Junitalama May 12, 2023
e1cb0be
level 350 done
Junitalama May 15, 2023
4ffee05
350 done
Junitalama May 15, 2023
6999652
Update script.js
Junitalama May 15, 2023
66ea2f7
level 400
Junitalama May 16, 2023
8ee867d
Update script.js
Junitalama May 16, 2023
4cafd5f
400
Junitalama May 16, 2023
ea98648
fixed 400
Junitalama May 18, 2023
4579ae3
fixed bug
Junitalama May 18, 2023
c8cc93a
added styling
Junitalama May 18, 2023
356c2a3
Update index.html
Junitalama May 19, 2023
c595902
Update index.html
Junitalama May 19, 2023
181d9c6
Update style.css
Junitalama May 19, 2023
8c176c0
Update style.css
Junitalama May 19, 2023
5586705
Update style.css
Junitalama May 19, 2023
5bde5eb
Update script.js
Junitalama May 19, 2023
7d1263e
Update script.js
Junitalama May 19, 2023
1ac596c
500
Junitalama May 22, 2023
2a9013c
fixing bugs in 500
Junitalama May 22, 2023
02f412a
Update style.css
Junitalama May 22, 2023
eeacbbb
Update style.css
Junitalama May 22, 2023
20bfc82
500
Junitalama May 22, 2023
9cf33d2
style-500
Junitalama May 23, 2023
10b4abb
Update style.css
Junitalama May 23, 2023
7e6c407
Update script.js
Junitalama May 23, 2023
a9699f0
Update index.html
Junitalama May 23, 2023
9dabbb0
Update script.js
Junitalama May 23, 2023
5d52c2e
Update style.css
Junitalama May 24, 2023
fbd06bd
Update style.css
Junitalama May 24, 2023
46ef940
Update style.css
Junitalama May 24, 2023
f00a753
Update style.css
Junitalama May 24, 2023
6556e99
Update style.css
Junitalama May 24, 2023
b93df4d
Update style.css
Junitalama May 24, 2023
77696bf
Update style.css
Junitalama May 25, 2023
fbaa50e
500 updated
Junitalama May 25, 2023
50cc630
Update script.js
Junitalama May 26, 2023
6354dc5
Update style.css
Junitalama May 26, 2023
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
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/script.js"
}
]
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS code settings are usually not committed, you could add this file to your gitignore.

10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TV Show Project | My Name (My GitHub username)</title>
<title>TV Show Project | Junita Lama (Junitalama)</title>
<link href="style.css" rel="stylesheet" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>

<body>
<div id="selectBar">
<select id="selector" class="form-control">
</select>
<input id="search" type="text" class="input" placeholder="search..."/>
<label for="search" >Displaying <span id="num">73</span>/73 episodes</label>

</div>
<div id="root">
</div>
<div id = "footer"></div>

<!-- Loads a provided function called getAllEpisodes() which returns all episodes -->
<script src="episodes.js"></script>
Expand Down
98 changes: 94 additions & 4 deletions script.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job getting everything working up to level-300!

I think it was optional anyway, but the only thing missing in terms of functionality is being able to easily go back to seeing all episodes after using the dropdown - the only way to get them back right now is to start typing and then delete again.

I think in terms of style/readability, it's good to break up code into some smaller sub-functions - it can make the code much easier to read (because usually a function says what it does), and easier for you to think about too. There is a lot happening in these functions! And the 300 level bit could be put ("encapsulated") in a function.

Original file line number Diff line number Diff line change
@@ -1,12 +1,102 @@
//You can edit ALL of the code here
let allEpisodes = getAllEpisodes();
function setup() {
const allEpisodes = getAllEpisodes();
//let allEpisodes = getAllEpisodes();
makePageForEpisodes(allEpisodes);
}

//level 100
//showing all episodes

function makePageForEpisodes(episodeList) {
const rootElem = document.getElementById("root");
rootElem.textContent = `Got ${episodeList.length} episode(s)`;
let rootElem = document.getElementById("root");
// rootElem.textContent = `Got ${episodeList.length} episode(s)`;
rootElem.innerHTML = "";
for(let episode of episodeList) {
let divEle = document.createElement("div");
divEle.className = "card";

const episodeName =document.createElement("h1");
episodeName.innerText = `${episode.name}-S${(String(episode.season).padStart(2,'0'))}E${String(episode.number).padStart(2,'0')}`;
const lineEle = document.createElement("div");
lineEle.className = "l";


const image = document.createElement("img");
image.src = episode.image.medium;

const episodeSummary = document.createElement("p");
episodeSummary.innerHTML = episode.summary;

divEle.append(
episodeName,
lineEle,
image,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i learn from you too :) i didn't know you can add them all at one go, cool!!

episodeSummary,
);
rootElem.append(divEle)
};
}
window.onload = setup;

//level 200
//search bar

searchEle = document.querySelector("#search")
searchEle.addEventListener("input", searchEpisode);

function searchEpisode(){
const searchInput = searchEle.value.toLowerCase();
const filteredEpisodes = allEpisodes.filter(episode => {
if (episode.name.toLowerCase().includes(searchInput) || episode.summary.toLowerCase().includes(searchInput)){
return episode;
}
})

document.querySelector("#num").innerText = filteredEpisodes.length;
makePageForEpisodes(filteredEpisodes);

}

//level 300
//select bar

let selectEle = document.querySelector("#selector");
let optionEle = document.createElement("option")
optionEle.innerText= "Select Episodes";
selectEle.appendChild(optionEle);

allEpisodes.forEach(el => {
let options = document.createElement("option");
options.value = el.name;
options.innerText = `${el.name} - S${el.season.toString().padStart(2, "0")}E${el.number.toString().padStart(2, "0")}`;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wise approach for padStart()

selectEle.appendChild(options);
});

selectEle.addEventListener("change", function () {
let selected = selectEle.value;
let episodes = Array.from(document.getElementsByClassName("card"));

episodes.forEach((episode) => {
let h1Element = episode.querySelector("h1");
if (h1Element.innerText.includes(selected)) {
episode.style.display = "block";
document.querySelector("#num").innerText = 1;

} else {
episode.style.display = "none";
}
});
});

//footer

let footerEle= document.getElementById("footer");
const footerLink = document.createElement("a");
footerLink.href = "https://www.tvmaze.com/"
footerLink.textContent = "data from tvmaze.com";
footerEle.appendChild(footerLink);

window.onload = setup;


54 changes: 53 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
#root {
color: red;
color:black;
display: flex;
flex-wrap: wrap;
justify-content: center;
}

.card {
display: flex;
flex-direction: column;
margin : 10px;
padding : 32px;
background-color:azure;
max-width: 300px;
border-radius: 3%;
border: 1px solid orchid;

}



h1{
font-size: 20px;
}

.l {
margin-bottom: 20px;
border: 1px solid orchid;

}


img {
align-self: center;
}

p{
text-align: justify;
}

#search , #selector {
color: green;
padding: 10px;
border: 2px solid orchid;
margin-bottom: 20px;
}

#footer {
display: flex;
flex-direction: row;
justify-content: center;
font-size: 20px;
font-family: cursive;
color: red;
}