-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (27 loc) · 988 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const categoriUrl = './images/catogories/';
const offersUrl = './images/offers/';
const imageContaier = document.getElementById('content');
const brandItems = document.getElementById('brands');
const itemCount = document.getElementById('itemCount');
// CATEGORIES IMAGES PUTTING IN DOM
addItemsDOM(imageContaier, 10, categoriUrl, '.jpg');
// OFFER IMAGES PUTTING IN DOM
addItemsDOM(brandItems, 12, offersUrl, '.png');
function addItemsDOM(container, imgCount, rootUrl, ext){
for(let i = 1; i<=imgCount; i++){
container.innerHTML += `
<a href="./shopping.html"><img class="w-36 my-3 sm:w-60 cursor-pointer" src="${rootUrl+i+ext}"></img></a>`
};
}
let bagStr = localStorage.getItem('bag');
if(bagStr){
bag = JSON.parse(bagStr);
if(bag.length > 0){
itemCount.style.display = 'block';
itemCount.innerHTML = bag.length;
}else{
itemCount.style.display = 'none';
}
}else{
itemCount.style.display = 'none';
}