From f63a6e9efb066151b9a726c2c3f3e61565b48314 Mon Sep 17 00:00:00 2001 From: samiulislam09 Date: Wed, 2 Mar 2022 14:13:43 +0600 Subject: [PATCH] added show more button --- index.html | 4 +++- js/script.js | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5531a5f..9013294 100644 --- a/index.html +++ b/index.html @@ -39,7 +39,9 @@ - +
+ +

No phone found😒

diff --git a/js/script.js b/js/script.js index c0ad9a8..1d01a2b 100644 --- a/js/script.js +++ b/js/script.js @@ -26,6 +26,7 @@ const displayPhone = (data) => { cards.textContent = ""; document.getElementById('not-found').style.display = 'block'; toggleLoading('none'); + document.getElementById('show-more').style.display = 'none'; const feature = document.getElementById('feature'); feature.style.display = 'none' } else { @@ -33,7 +34,14 @@ const displayPhone = (data) => { cards.textContent = ""; document.getElementById('feature').textContent = ''; const allData = data.data; - const firstData = data.data.slice(0, 20); + const firstData = allData.slice(0, 20); + if (allData.length > 20) { + const showMore = document.getElementById('show-more'); + div = document.createElement('div'); + div.classList.add('col-12'); + div.innerHTML = ``; + showMore.appendChild(div) + } for (let item of firstData) { const div = document.createElement('div'); div.classList.add('col-12'); @@ -59,6 +67,13 @@ const displayPhone = (data) => { } } + +// show remaining items + +// const showRemainingData = () => { + +// } + // load details data in ui const loadDetail = (id) => { const url = `https://openapi.programming-hero.com/api/phone/${id}` @@ -68,11 +83,11 @@ const loadDetail = (id) => { }; // phone spec detail section const specDetails = (data) => { - console.log(data); const featureSection = document.getElementById('feature'); featureSection.style.display = 'block' const div = document.createElement('div'); featureSection.textContent = ''; + div.classList.add('feature') div.innerHTML = `

Details