-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
140 lines (115 loc) · 5.51 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Repfind</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="styles/main.css" />
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<h1 style="margin-top: 100px;" class="title center fw-bold">Repfind</h1>
<div class="container-main center">
<input type="text" class="searchinput" placeholder="Search for product" oninput="filterProductsBySearch(this.value)">
</div>
<div class="category-btns">
<button class="btn" id="all" onclick="showAllProducts()">All</button>
<button class="btn" id="agent" onclick="showProductsByCategory(this.id)">Agents</button>
<button class="btn" id="pants" onclick="showProductsByCategory(this.id)">Pants</button>
<button class="btn" id="shorts" onclick="showProductsByCategory(this.id)">Shorts</button>
<button class="btn" id="tees" onclick="showProductsByCategory(this.id)">Tees</button>
<button class="btn" id="shoes" onclick="showProductsByCategory(this.id)">Shoes</button>
<button class="btn" id="jackets" onclick="showProductsByCategory(this.id)">Jackets</button>
<button class="btn" id="hoodies" onclick="showProductsByCategory(this.id)">Hoodies</button>
<button class="btn" id="jewels" onclick="showProductsByCategory(this.id)">Jewels</button>
<button class="btn" id="others" onclick="showProductsByCategory(this.id)">Others</button>
<button class="btn" id="sellers" onclick="showProductsByCategory(this.id)">Sellers</button>
</div>
<div id="products-container">
</div>
</body>
<script>
let productsList = [];
function returnStar(product) {
const isStarred = product.starred
if (isStarred) {
return '<i class="golden-gradient bi bi-star-fill"></i>'
} else {
return ""
}
}
function showProductsByCategory(category) {
const productsContainer = document.getElementById('products-container');
productsContainer.innerHTML = '';
const filteredProducts = productsList.filter(product => product.category.toLowerCase() === category.toLowerCase());
if (filteredProducts.length > 0) {
filteredProducts.forEach(product => {
const productHTML = `
<div data-aos="fade-up" class="product" id="${product.category}">
<img src="${product.image}" alt="${product.name}">
<h3>${product.name} ${returnStar(product)}</h3>
<p>Category: ${product.category}</p>
<p class="product-price">Price: ${product.prices.cny}¥ (~$${product.prices.usd})</p>
<a class="btn" href="view.html?id=${product.id}">View Product</a>
</div>
`;
productsContainer.innerHTML += productHTML;
});
}
}
function showAllProducts() {
const productsContainer = document.getElementById('products-container');
productsContainer.innerHTML = '';
if (productsList.length > 0) {
productsList.forEach(product => {
const productHTML = `
<div data-aos="fade-up" class="product" id="${product.category}">
<img src="${product.image}" alt="${product.name}">
<h3>${product.name} ${returnStar(product)}</h3>
<p>Category: ${product.category}</p>
<p class="product-price">Price: ${product.prices.cny}¥ (~$${product.prices.usd})</p>
<a class="btn" href="view.html?id=${product.id}">Show Product</a>
</div>
`;
productsContainer.innerHTML += productHTML;
});
}
}
function filterProductsBySearch(searchQuery) {
const filteredProducts = productsList.filter(product => product.name.toLowerCase().includes(searchQuery.toLowerCase()));
showFilteredProducts(filteredProducts);
}
function showFilteredProducts(filteredProducts) {
const productsContainer = document.getElementById('products-container');
productsContainer.innerHTML = '';
if (filteredProducts.length > 0) {
filteredProducts.forEach(product => {
const productHTML = `
<div data-aos="fade-up" class="product" id="${product.category}">
<img src="${product.image}" alt="${product.name}">
<h3>${product.name} ${returnStar(product)}</h3>
<p>Category: ${product.category}</p>
<p class="product-price">Price: ${product.prices.cny}¥ (~$${product.prices.usd})</p>
<a class="btn" href="view.html?id=${product.id}">View Product</a>
</div>
`;
productsContainer.innerHTML += productHTML;
console.log(productHTML);
});
}
}
function initProducts() {
fetch('data/products.json')
.then(response => response.json())
.then(products => {
productsList = products;
showProductsByCategory("Agent");
swal("Information", "Many product has been taken from HAULED website on github, if you want to add product then join our discord and ask in the dedicated channel.", 'info');
})
}
AOS.init();
initProducts();
</script>
</html>