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

Lian countries #10

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

Conversation

lianhersh
Copy link

No description provided.

Copy link
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

Please remove all of your non user event listners after finish using them

<script src="./js/common.js"></script>
<script src="./js/details.js"></script>
<!-- <script src="./js/common.js"></script>
<script src="./js/details.js"></script> -->
</body>
Copy link
Member

Choose a reason for hiding this comment

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

Don`t use comments, remove non used code

const urlParams = new URLSearchParams(window.location.search);
const name = urlParams.get("name");
const flag = urlParams.get("flag");
const population = urlParams.get("population");
Copy link
Member

Choose a reason for hiding this comment

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

You should extract this into service and use his methods from there, for example :

paramsService.getValue()


countryDetailsSection.innerHTML = cardHTML;
loader.style.display = "none";
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use innerHTML its a dangerous method

Also don`t change elements styles from js, use classes.

@@ -0,0 +1,63 @@
document.addEventListener("DOMContentLoaded", () => {
fetch("CountriesData.json")
.then(response => {
Copy link
Member

Choose a reason for hiding this comment

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

Hardcoded strings should be extracted into constant service

card.setAttribute("href", `details.html?name=${encodeURIComponent(country.name)}&flag=${encodeURIComponent(country.flag)}&population=${country.population}&region=${encodeURIComponent(country.region)}&capital=${encodeURIComponent(country.capital || "N/A")}`);
card.querySelector(".country-image").src = country.flag;
card.querySelector(".country-image").alt = `${country.name} Flag`;
card.querySelector(".country-title").textContent = country.name;
Copy link
Member

Choose a reason for hiding this comment

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

You should save your element and not use 2 querySelectors

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