diff --git a/css/style.css b/css/style.css index e6b1649..87d3f53 100644 --- a/css/style.css +++ b/css/style.css @@ -1,7 +1,6 @@ .card{ margin-bottom: 15px; transition: all 0.2s ease-in-out; - cursor: pointer; box-shadow: 0 0 10px; border-radius: 10px; border: none; @@ -22,4 +21,8 @@ width: 45vh; margin: 0 auto; display: none; +} +.show-more{ + display: none; + margin: 20px 0; } \ No newline at end of file diff --git a/images/Firefox Installer.exe b/images/Firefox Installer.exe new file mode 100644 index 0000000..e757d10 Binary files /dev/null and b/images/Firefox Installer.exe differ diff --git a/index.html b/index.html index 8cec91a..eb31f1c 100644 --- a/index.html +++ b/index.html @@ -13,17 +13,13 @@
-
- - - \ No newline at end of file diff --git a/js/script.js b/js/script.js index 215fd5f..8442381 100644 --- a/js/script.js +++ b/js/script.js @@ -1,34 +1,37 @@ +document.getElementById('loading').style.display = "none"; +// fetch data const phoneData = () => { const inputFromuser = document.getElementById('name-input').value; const phoneName = inputFromuser.toLowerCase(); - toggleLoading('block') fetch(`https://openapi.programming-hero.com/api/phones?search=${phoneName}`) .then(res => res.json()) .then(data => displayPhone(data)) - toggleNotFound('none'); + toggleLoading('block') + document.getElementById('not-found').style.display = "none"; } - +// not found handler const toggleNotFound = (input) => { const notFound = document.getElementById('not-found'); notFound.style.display = input; } - +// loading handler const toggleLoading = (input) => { const loading = document.getElementById('loading'); loading.style.display = input; } - +// displaying data const displayPhone = (data) => { - const cards = document.getElementById('cards'); - cards.textContent = ''; - toggleNotFound('none') - if (data.status == false) { - toggleNotFound('block'); - toggleLoading('none'); + cards.textContent = ""; + document.getElementById('not-found').style.display = 'block'; + toggleLoading('none') } else { - for (let item of data.data) { + const cards = document.getElementById('cards'); + cards.textContent = ""; + const allData = data.data; + const firstData = data.data.slice(0, 20); + for (let item of firstData) { const div = document.createElement('div'); div.classList.add('col-12'); div.classList.add('col-md-3'); @@ -36,19 +39,21 @@ const displayPhone = (data) => { div.classList.add('justify-content-center'); div.classList.add('text-center'); div.innerHTML = ` -
- ${item.brand} mobile image -
-
${item.brand}
-

${item.phone_name}

-
+
+ ${item.brand} mobile image +
+
${item.brand}
+

${item.phone_name}

+
- ` +
+ ` cards.appendChild(div) } - toggleLoading('none') + + + toggleNotFound('none'); + toggleLoading('none'); } - - } \ No newline at end of file