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

Tomer #14

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Tomer #14

wants to merge 5 commits into from

Conversation

tomergol15
Copy link

i'm sending a pull request about the exercise. In the commits, you can see the acts I did.

@GilHeller GilHeller self-requested a review December 19, 2024 06:39
Copy link

@GilHeller GilHeller left a comment

Choose a reason for hiding this comment

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

Overall great job
Please see my comments

index.html Outdated
Comment on lines 58 to 63
<li data-region="all" onclick="filterByRegion(event)">All</li>
<li data-region="africa" onclick="filterByRegion(event)">Africa</li>
<li data-region="americas" onclick="filterByRegion(event)">America</li>
<li data-region="asia" onclick="filterByRegion(event)"v>Asia</li>
<li data-region="europe" onclick="filterByRegion(event)">Europe</li>
<li data-region="oceania" onclick="filterByRegion(event)">Oceania</li>

Choose a reason for hiding this comment

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

consider to insert the li elements from the js code with map().
Imagine you have a large list of regions - we will want the computer to calculate the presented list and not to insert it one by one,

index.html Outdated
Comment on lines 99 to 143
<!--

<a
href="#"
class="country scale-effect"
data-country-name="Åland Islands"
>
<div class="country-flag">
<img src="https://flagcdn.com/ax.svg" alt="Åland Islands FLag" />
</div>
<div class="country-info">
<h2 class="country-title">Åland Islands</h2>
<ul class="country-brief">
<li><strong>population: </strong>28875</li>
<li><strong>Region: </strong>Europe</li>
<li><strong>capital: </strong>Mariehamn</li>
</ul>
</div>
</a>
<a href="#" class="country scale-effect" data-country-name="Aruba">
<div class="country-flag">
<img src="https://flagcdn.com/aw.svg" alt="Aruba FLag" />
</div>
<div class="country-info">
<h2 class="country-title">Aruba</h2>
<ul class="country-brief">
<li><strong>population: </strong>106766</li>
<li><strong>Region: </strong>Americas</li>
<li><strong>capital: </strong>Oranjestad</li>
</ul>
</div>
</a>
<a href="#" class="country scale-effect" data-country-name="Belize">
<div class="country-flag">
<img src="https://flagcdn.com/bz.svg" alt="Belize FLag" />
</div>
<div class="country-info">
<h2 class="country-title">Belize</h2>
<ul class="country-brief">
<li><strong>population: </strong>397621</li>
<li><strong>Region: </strong>Americas</li>
<li><strong>capital: </strong>Belmopan</li>
</ul>
</div>
</a> -->

Choose a reason for hiding this comment

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

remove redundant comments

JS/index.js Outdated
Comment on lines 127 to 180
// const containerCountries = document.querySelector(".countries-grid");
// const countryCard = document.querySelector(".country.scale-effect");
// const cards= document.querySelectorAll(".country");

// fetch('./CountriesData.json')
// .then((res) => {
// if (!res.ok) {
// throw new Error
// (`HTTP error! Status: ${res.status}`);
// }
// return res.json();
// })
// .then((data) => {
// countries = data;
// console.log(data);
// duplicateCard();
// innerTextIntoCardDetails(countries);
// })
// .catch((error) =>
// console.error("Unable to fetch data:", error));

// const duplicateCard = () =>{
// const lenArray = countries.length;

// for(i=1;i<lenArray;i++){
// const cloneCard = countryCard.cloneNode(true);
// containerCountries.appendChild(cloneCard);
// }
// }
// const innerTextIntoCardDetails = (array) =>{
// const cards= document.querySelectorAll(".country"); //take after the duplicate

// for(i=0;i<countries.length;i++){
// const titleElement = cards[i].querySelector(".country-title");
// const flagImage = cards[i].querySelector(".country-flag img"); //choost the img in the selector
// const countryInfo = cards[i].querySelectorAll(".country-brief li");

// countryInfo.forEach((item)=>{
// const label = item.querySelector("strong").textContent.trim().replace(":", "");
// if(label==="population"){
// item.innerHTML = countries[i].population;
// }
// else if(label==="Region"){
// item.innerHTML = countries[i].region;
// }
// else if(label==="capital"){
// item.innerHTML = countries[i].capital;
// }
// })
// titleElement.innerHTML = countries[i].name;
// flagImage.src = countries[i].flag;
// flagImage.alt = `${countries[i].name}`;
// }
// }

Choose a reason for hiding this comment

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

remove redundant comments

JS/index.js Outdated
console.log("enter");
const currentColor = getComputedStyle(document.body).backgroundColor;

if (currentColor === "rgb(33, 37, 41)") {

Choose a reason for hiding this comment

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

consider to assign the hard-coded values: "rgb(33, 37, 41)" and "rgb(255, 255, 255)" to constant variables.

consider to create a new file for your application constants: const.js

Comment on lines +71 to +76
const matchValues = (country, input) => {
return (country.name.toLowerCase().includes(input) ||
country.population.toString().includes(input)) ||
country.region.toLowerCase().includes(input) ||
country.capital.toLowerCase().includes(input)
}

Choose a reason for hiding this comment

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

NICE!

Consider a case where the user enters " Israel " (with spaces and tabs before and after the word)
https://www.geeksforgeeks.org/string-strip-in-javascript/

JS/index.js Outdated
Comment on lines 32 to 38
titleElement.innerHTML = country.name;
flagImage.src = country.flag;
flagImage.alt = `${country.name}`;

countryInfo[0].innerHTML = `<strong>Population:</strong> ${country.population}`;
countryInfo[1].innerHTML = `<strong>Region:</strong> ${country.region}`;
countryInfo[2].innerHTML = `<strong>Capital:</strong> ${country.capital}`;

Choose a reason for hiding this comment

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

The usage of innerHTML is not recommended due to security vulnerabilities.

https://medium.com/@jasen.miyamoto/appending-to-the-dom-and-the-dangers-of-using-innerhtml-debd77e53e70

…hange from innerHtml in innerDetailsIntoCards func and more
@tomergol15
Copy link
Author

i did the changes you asked from me and did commit on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants