-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12fc6e4
commit 479eb55
Showing
10 changed files
with
105 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,9 +121,7 @@ body { | |
|
||
} | ||
|
||
.card:hover { | ||
transform: scale(1.10); | ||
} | ||
|
||
|
||
|
||
.card-body>ul { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { fetchData } from "./FetchModule.js"; | ||
|
||
const baseUrl = | ||
"https://restcountries.com/v3.1/all?fields=name,population,region,capital,flags"; | ||
|
||
export async function fetchHomePageData(searchResult) { | ||
let url = baseUrl; | ||
if (searchResult) { | ||
url = `https://restcountries.com/v3.1/name/${searchResult}?fields=name,population,region,capital,flags`; | ||
} | ||
const data = await fetchData(url); | ||
return data; | ||
} | ||
|
||
export async function fetchDetailPage(urlCountryName) { | ||
let url = `https://restcountries.com/v3.1/name/${urlCountryName}?fields=name,population,region,subregion,tld,borders,currencies,capital,flags,languages`; | ||
const data = await fetchData(url); | ||
return data; | ||
} | ||
export async function fetchFullBordersName(borders) { | ||
let url = `https://restcountries.com/v3.1/alpha?codes=${borders}`; | ||
const data = await fetchData(url); | ||
return data; | ||
} | ||
export default fetchHomePageData; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { isLoading } from "../Api/LoadingSpinner.js"; | ||
|
||
const cardContainer = document.getElementById("cardContainer"); | ||
const searchInput = document.getElementById("input"); | ||
|
||
|
||
export function clearCardContainer() { | ||
cardContainer.innerHTML = ""; | ||
} | ||
export function appendChildToCardContainer(child) { | ||
cardContainer.appendChild(child); | ||
} | ||
export function noResultFound() { | ||
cardContainer.innerHTML = `<h2 class="text-center">No result Found.</h2>`; | ||
} | ||
|
||
export function loading() { | ||
isLoading(cardContainer, true); | ||
} | ||
export function loaded() { | ||
isLoading(cardContainer, false); | ||
} | ||
|
||
export function debounce(cb, delay) { | ||
let timer; | ||
return function (...args) { | ||
clearTimeout(timer); | ||
timer = setTimeout(() => { | ||
cb.apply(this, args); | ||
}, delay); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function handleSearch(event) { | ||
clearTimeout(searchTimer); | ||
searchTimer = setTimeout(() => { | ||
const searchResult = event.target.value.trim(); | ||
!searchResult ? handleData() : handleData(searchResult); | ||
}, 500); | ||
} |