-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: main
Are you sure you want to change the base?
Lian countries #10
Conversation
There was a problem hiding this 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> |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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}®ion=${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; |
There was a problem hiding this comment.
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
No description provided.