-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathelectronics.html
More file actions
175 lines (150 loc) · 5.41 KB
/
electronics.html
File metadata and controls
175 lines (150 loc) · 5.41 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Electronics | Better Gadgets</title>
<link rel="stylesheet" href="style.css" />
<style>
button.added {
background-color: #4CAF50 !important;
color: white !important;
cursor: not-allowed;
border: none;
transition: 0.3s ease;
}
</style>
</head>
<body>
<!-- Header -->
<header class="header">
<div class="logo">
<img src="img/printer.jpeg" alt="Logo">
<h1>Better Electronic Gadgets</h1>
<h2>Our website. Our marketplace. Our goods.</h2>
<h3>Discover top Electronics - Laptops, Printers, Smart Tech.</h3>
</div>
<div class="search-bar">
<input type="search" placeholder="Search for an electronic..." />
</div>
</header>
<!-- Navigation -->
<nav class="navbar">
<a href="index.html">Home</a>
<a href="kitchen.html">Kitchen</a>
<a href="electronics.html" class="active">Electronics</a>
<a href="motorvehicle.html">Motor Vehicles</a>
<a href="Bedroom_layout.html">Bedroom Layouts</a>
<a href="cart.html" class="cart-link">
<span id="cart-logo">🛒</span>Cart
<span id="cart-count" class="cart-count">0</span>
</a>
</nav>
<!-- Main Section -->
<main class="products">
<div class="product-card">
<img src="img/dell.jpeg" alt="Dell Laptop">
<h2>Dell Windows 11</h2>
<p><strong>Price:</strong> $35<br>Core i5, 16GB RAM, 526GB Storage, 3000W</p>
<button data-id="1" onclick="addToCart({id:1,name:'Dell Windows 11',price:35,image:'img/dell.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/printer.jpeg" alt="Printer">
<h2>KLC Modern Printer</h2>
<p><strong>Price:</strong> $32<br>Durable and efficient</p>
<button data-id="2" onclick="addToCart({id:2,name:'KLC Modern Printer',price:32,image:'img/printer.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/smartwatch.jpeg" alt="Smartwatch">
<h2>Modern Smartwatch</h2>
<p><strong>Price:</strong> $18<br>Bluetooth type, Durable</p>
<button data-id="3" onclick="addToCart({id:3,name:'Modern Smartwatch',price:18,image:'img/smartwatch.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/headphone.jpeg" alt="Headphones">
<h2>Headphone 121e Model</h2>
<p><strong>Price:</strong> $20<br>240V Power</p>
<button data-id="4" onclick="addToCart({id:4,name:'Headphones 121e Model',price:20,image:'img/headphone.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/Watches.jpeg" alt="Nano Watch">
<h2>Nano Watch</h2>
<p><strong>Price:</strong> $15<br>Bluetooth type, Durable</p>
<button data-id="5" onclick="addToCart({id:5,name:'Nano Watch',price:15,image:'img/Watches.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/Modified blender.jpeg" alt="Blender">
<h2>HQ Modern Blender</h2>
<p><strong>Price:</strong> $25, 2L, 240V<br>Durable</p>
<button data-id="6" onclick="addToCart({id:6,name:'HQ Modern Blender',price:25,image:'img/Modified blender.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/smartglasses.jpeg" alt="Smart Glasses">
<h2>Smart Glasses</h2>
<p><strong>Price:</strong> $37<br>Modern tech eyewear</p>
<button data-id="7" onclick="addToCart({id:7,name:'Smart Glasses',price:37,image:'img/smartglasses.jpeg'}, this)">
Add to Cart
</button>
</div>
<div class="product-card">
<img src="img/blender.jpg" alt="Blender">
<h2>Blender</h2>
<p><strong>Price:</strong> $23, 2L, 240V<br>Good and wonderful</p>
<button data-id="8" onclick="addToCart({id:8,name:'Blender',price:23,image:'img/blender.jpg'}, this)">
Add to Cart
</button>
</div>
</main>
<!-- Footer -->
<footer>
<p>© 2025 Maximall. All rights reserved. | Designed with 💙 by Billy & White Wizard.</p>
</footer>
<!-- ============================== -->
<!-- FINAL CART SCRIPT (BUTTON RESET VERSION) -->
<!-- ============================== -->
<script>
function addToCart(product, button) {
let cart = JSON.parse(localStorage.getItem("cart")) || [];
// Add item only once
if (!cart.some(item => item.id === product.id)) {
cart.push(product);
localStorage.setItem("cart", JSON.stringify(cart));
}
// Instantly update button
button.textContent = "Added to Cart";
button.classList.add("added");
button.disabled = true;
updateCartCount();
}
// Updates cart counter
function updateCartCount() {
let cart = JSON.parse(localStorage.getItem("cart")) || [];
document.getElementById("cart-count").textContent = cart.length;
}
// Reset buttons after page reload
document.addEventListener("DOMContentLoaded", () => {
// Reset all buttons to default state
document.querySelectorAll("button[data-id]").forEach(button => {
button.textContent = "Add to Cart";
button.classList.remove("added");
button.disabled = false;
});
// Cart count remains correct
updateCartCount();
});
</script>
<script src="Cart.js"></script>
</body>
</html>