-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
284 lines (255 loc) · 8.97 KB
/
Copy pathscript.js
File metadata and controls
284 lines (255 loc) · 8.97 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Products Data
const products = [
{
id: 1,
title: "פוסטר דיגיטלי - השראה יומית",
description: "פוסטר מעוצב בסגנון מינימליסטי עם ציטוט מעורר השראה",
price: 29,
image: "🎨",
category: "פוסטרים"
},
{
id: 2,
title: "תבנית עיצוב - מצגת עסקית",
description: "תבנית PowerPoint מקצועית לעסקים ויזמים",
price: 49,
image: "📊",
category: "תבניות"
},
{
id: 3,
title: "מדריך PDF - שיווק דיגיטלי",
description: "מדריך מקיף לשיווק דיגיטלי ברשתות החברתיות",
price: 79,
image: "📚",
category: "מדריכים"
},
{
id: 4,
title: "חבילת אייקונים - טכנולוגיה",
description: "100 אייקונים וקטוריים בנושא טכנולוגיה ועיצוב",
price: 39,
image: "🔧",
category: "אייקונים"
},
{
id: 5,
title: "פוסטר אמנותי - גיאומטריה",
description: "עיצוב אמנותי מודרני עם צורות גיאומטריות",
price: 35,
image: "🔷",
category: "פוסטרים"
},
{
id: 6,
title: "תבנית אתר - פורטפוליו",
description: "תבנית HTML/CSS מוכנה לאתר פורטפוליו אישי",
price: 89,
image: "💻",
category: "תבניות"
}
];
// Cart functionality
let cart = JSON.parse(localStorage.getItem('infinityCart')) || [];
// DOM Elements
const productsGrid = document.getElementById('products-grid');
const cartModal = document.getElementById('cart-modal');
const cartCount = document.getElementById('cart-count');
const cartItems = document.getElementById('cart-items');
const cartTotal = document.getElementById('cart-total');
const checkoutBtn = document.getElementById('checkout-btn');
const cartBtn = document.querySelector('.cart-btn');
const closeModal = document.querySelector('.close');
// Initialize
document.addEventListener('DOMContentLoaded', function() {
renderProducts();
updateCartUI();
setupEventListeners();
setupSmoothScrolling();
});
// Render products
function renderProducts() {
productsGrid.innerHTML = products.map(product => `
<div class="product-card" data-aos="fade-up">
<div class="product-image">${product.image}</div>
<h3 class="product-title">${product.title}</h3>
<p class="product-description">${product.description}</p>
<div class="product-price">₪${product.price}</div>
<button class="add-to-cart" onclick="addToCart(${product.id})">
הוסף לעגלה
</button>
</div>
`).join('');
}
// Add to cart
function addToCart(productId) {
const product = products.find(p => p.id === productId);
const existingItem = cart.find(item => item.id === productId);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({ ...product, quantity: 1 });
}
localStorage.setItem('infinityCart', JSON.stringify(cart));
updateCartUI();
showAddToCartAnimation();
}
// Remove from cart
function removeFromCart(productId) {
cart = cart.filter(item => item.id !== productId);
localStorage.setItem('infinityCart', JSON.stringify(cart));
updateCartUI();
renderCartItems();
}
// Update quantity
function updateQuantity(productId, change) {
const item = cart.find(item => item.id === productId);
if (item) {
item.quantity += change;
if (item.quantity <= 0) {
removeFromCart(productId);
} else {
localStorage.setItem('infinityCart', JSON.stringify(cart));
updateCartUI();
renderCartItems();
}
}
}
// Update cart UI
function updateCartUI() {
const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0);
const totalPrice = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
cartCount.textContent = totalItems;
cartTotal.textContent = totalPrice;
// Add animation to cart count
if (totalItems > 0) {
cartCount.style.background = 'linear-gradient(45deg, #ff6b35, #ffd700)';
cartCount.style.animation = 'pulse 0.5s ease';
}
}
// Render cart items
function renderCartItems() {
if (cart.length === 0) {
cartItems.innerHTML = '<p style="text-align: center; color: #cccccc;">העגלה שלך ריקה</p>';
return;
}
cartItems.innerHTML = cart.map(item => `
<div class="cart-item">
<div style="display: flex; align-items: center; gap: 1rem;">
<span style="font-size: 2rem;">${item.image}</span>
<div>
<h4 style="color: #ffd700;">${item.title}</h4>
<p style="color: #cccccc;">₪${item.price}</p>
</div>
</div>
<div style="display: flex; align-items: center; gap: 1rem;">
<button onclick="updateQuantity(${item.id}, -1)" style="background: #8b5cf6; color: white; border: none; padding: 0.5rem; border-radius: 5px; cursor: pointer;">-</button>
<span style="color: #ffd700; font-weight: bold;">${item.quantity}</span>
<button onclick="updateQuantity(${item.id}, 1)" style="background: #8b5cf6; color: white; border: none; padding: 0.5rem; border-radius: 5px; cursor: pointer;">+</button>
<button onclick="removeFromCart(${item.id})" style="background: #ff4757; color: white; border: none; padding: 0.5rem; border-radius: 5px; cursor: pointer;">🗑️</button>
</div>
</div>
`).join('');
}
// Show add to cart animation
function showAddToCartAnimation() {
const notification = document.createElement('div');
notification.innerHTML = '✅ נוסף לעגלה!';
notification.style.cssText = `
position: fixed;
top: 100px;
right: 20px;
background: linear-gradient(45deg, #8b5cf6, #3b82f6);
color: white;
padding: 1rem 2rem;
border-radius: 10px;
z-index: 3000;
animation: slideIn 0.5s ease;
border: 1px solid rgba(255, 215, 0, 0.3);
`;
document.body.appendChild(notification);
setTimeout(() => {
notification.style.animation = 'slideOut 0.5s ease';
setTimeout(() => notification.remove(), 500);
}, 2000);
}
// Setup event listeners
function setupEventListeners() {
// Cart modal
cartBtn.addEventListener('click', (e) => {
e.preventDefault();
cartModal.style.display = 'block';
renderCartItems();
});
closeModal.addEventListener('click', () => {
cartModal.style.display = 'none';
});
window.addEventListener('click', (e) => {
if (e.target === cartModal) {
cartModal.style.display = 'none';
}
});
// Checkout
checkoutBtn.addEventListener('click', () => {
if (cart.length === 0) {
alert('העגלה שלך ריקה!');
return;
}
window.location.href = 'checkout.html';
});
}
// Smooth scrolling
function setupSmoothScrolling() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
}
// Add CSS animations
const style = document.createElement('style');
style.textContent = `
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
from { transform: translateX(0); opacity: 1; }
to { transform: translateX(100%); opacity: 0; }
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.2); }
100% { transform: scale(1); }
}
`;
document.head.appendChild(style);
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe product cards when they're created
setTimeout(() => {
document.querySelectorAll('.product-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(50px)';
card.style.transition = 'all 0.6s ease';
observer.observe(card);
});
}, 100);