-
Notifications
You must be signed in to change notification settings - Fork 28
Ofek countries #16
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
base: main
Are you sure you want to change the base?
Ofek countries #16
Conversation
GilHeller
left a comment
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.
Overall great job.
Consider to write comments only when they are truly needed.
See my comments
js/common.js
Outdated
| * @param {string} param - The name of the query parameter containing the country name. | ||
| * @returns {string|null} - The country name, or null if the parameter doesn't exist. | ||
| */ | ||
| function getQueryParameter(param) { |
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.
use arrow functions
js/details.js
Outdated
| function logError(message) { | ||
| console.error(message); | ||
| } |
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.
redundant
js/details.js
Outdated
|
|
||
| /** Finds a country by name in a list of countries. */ | ||
| function findCountryByName(countries, name) { | ||
| return countries.find((country) => country.name === name) || null; |
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.
Why do you return null? When find not finds a match it returns undefined
js/details.js
Outdated
| fetchData(jsonFilePath) | ||
| .then((countries) => { | ||
| const country = findCountryByName(countries, countryName); | ||
| if (!country) throw new Error(`Country with name "${countryName}" not found!`); | ||
|
|
||
| clearElementContent(countryDetailsSection); | ||
| countryDetailsSection.appendChild(createCountryElement(country, {isGrid: false})); | ||
| }) | ||
| .catch((error) => logError(error.message || 'Error fetching country details')) | ||
| .finally(() => hideLoader(loader)); | ||
| }); |
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.
consider using the await syntax instead
js/common.js
Outdated
| toast.style.position = 'fixed'; | ||
| toast.style.bottom = '10px'; | ||
| toast.style.left = '50%'; | ||
| toast.style.transform = 'translateX(-50%)'; | ||
| toast.style.backgroundColor = '#444'; | ||
| toast.style.color = '#fff'; | ||
| toast.style.padding = '8px 15px'; | ||
| toast.style.borderRadius = '4px'; | ||
| toast.style.fontSize = '14px'; | ||
| toast.style.display = 'none'; |
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.
move to a css file as a class
js/common.js
Outdated
| // Toggle theme on button click | ||
| toggleButton.addEventListener('click', () => { | ||
| const isDark = body.classList.toggle('dark-theme'); // Toggle dark theme class | ||
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); // Save updated theme in localStorage |
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.
save the hard coded dark mode and light mode values as a const variable.
js/details.js
Outdated
|
|
||
| /** Clears the content of an HTML element. */ | ||
| function clearElementContent(element) { | ||
| if (element) element.innerHTML = ''; |
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.
Consider using removeChild() instead
const parent = document.getElementById("parent");
const child = document.getElementById("child");
const throwawayNode = parent.removeChild(child);|
changes are in [Remove .idea .DS_Stor from tracking] commit |
done with region button and search box filtering