Repository navigation
Expand file tree
/
Copy pathproduct.html
More file actions
591 lines (520 loc) · 25 KB
/
Copy pathproduct.html
File metadata and controls
591 lines (520 loc) · 25 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
<!DOCTYPE html>
<html lang="ta">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Product Details</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
/* --- VARIABLES (Matches Front Page) --- */
:root {
--primary: #2874f0;
--orange: #fb641b;
--whatsapp: #25D366; /* NEW: WhatsApp Official Color */
--white: #ffffff;
--grey: #878787;
--light-grey: #f0f0f0;
--green: #388e3c;
--bg: #f1f3f6;
--text-dark: #212121;
--card-border: #e0e0e0;
}
* { box-sizing: border-box; }
body {
font-family: 'Inter', sans-serif;
margin: 0;
background-color: var(--bg);
padding-bottom: 80px;
-webkit-tap-highlight-color: transparent;
color: var(--text-dark);
}
/* --- HEADER --- */
header {
background: var(--primary);
height: 60px;
padding: 0 16px;
position: sticky;
top: 0;
z-index: 1000;
display: flex;
align-items: center;
gap: 20px;
color: white;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
transition: transform 0.3s ease;
}
.header-title {
font-size: 18px; font-weight: 600; white-space: nowrap;
overflow: hidden; text-overflow: ellipsis; flex: 1; letter-spacing: 0.3px;
}
.icon-btn {
font-size: 20px; cursor: pointer; color: white; padding: 8px; position: relative;
}
/* Badge Style */
#headerWishlistBadge {
position: absolute; top: 0; right: 0;
background: #ff4444; color: white; border-radius: 50%;
padding: 2px 5px; font-size: 10px; font-weight: bold;
display: none; border: 1px solid white;
}
/* --- SLIDER --- */
.slider-wrapper {
background: white; position: relative; width: 100%;
aspect-ratio: 4/3; border-bottom: 1px solid #e0e0e0;
}
.slider {
display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
height: 100%; scrollbar-width: none;
}
.slider::-webkit-scrollbar { display: none; }
.slide {
flex: 0 0 100%; scroll-snap-align: center; display: flex;
align-items: center; justify-content: center; background: white;
}
.slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dots-container {
position: absolute; bottom: 12px; left: 0; right: 0;
display: flex; justify-content: center; gap: 8px; z-index: 10;
}
.dot {
width: 8px; height: 8px; background: rgba(0,0,0,0.2);
border-radius: 50%; transition: all 0.3s ease;
}
.dot.active { background: var(--primary); width: 20px; border-radius: 10px; }
.share-fab {
position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
background: white; border-radius: 50%; display: flex;
align-items: center; justify-content: center;
box-shadow: 0 4px 12px rgba(0,0,0,0.15); color: #555; z-index: 20;
cursor: pointer; transition: transform 0.2s;
}
.share-fab:active { transform: scale(0.9); }
/* --- INFO CARD --- */
.card {
background: white; padding: 16px; margin-bottom: 8px;
border-bottom: 1px solid #e0e0e0; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.p-cat {
font-size: 13px; color: var(--grey); font-weight: 600;
text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px;
}
.p-title {
font-size: 18px; color: var(--text-dark); font-weight: 500;
margin: 0 0 12px; line-height: 1.4;
}
.price-box { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.p-price { font-size: 26px; font-weight: 700; color: #212121; }
.p-mrp { font-size: 15px; color: var(--grey); text-decoration: line-through; }
.p-off { font-size: 15px; color: var(--green); font-weight: 700; }
.features {
display: flex; justify-content: space-between;
border-top: 1px solid var(--light-grey); padding-top: 16px;
}
.feat-item { text-align: center; font-size: 11px; color: #666; flex: 1; font-weight: 500;}
.feat-icon { font-size: 22px; color: var(--primary); margin-bottom: 6px; display: block; }
.desc-head { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--text-dark); }
.desc-content { font-size: 15px; color: #444; line-height: 1.7; white-space: pre-line; }
/* --- SIMILAR PRODUCTS SCROLL VIEW --- */
.scroll-row {
display: flex; gap: 10px; overflow-x: auto;
padding: 4px 4px 12px 4px; scrollbar-width: none;
}
.scroll-row::-webkit-scrollbar { display: none; }
/* Mini Card matching Front Page Design */
.mini-card {
min-width: 160px; width: 160px;
background: white; border-radius: 6px; overflow: hidden;
border: 1px solid var(--card-border);
display: flex; flex-direction: column; flex-shrink: 0;
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.mini-img-container {
width: 100%; aspect-ratio: 16/9; overflow: hidden; position: relative;
}
.mini-img {
width: 100%; height: 100%; object-fit: cover; display: block;
}
.mini-details { padding: 8px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.mini-title {
font-size: 13px; font-weight: 500; color: #212121; margin-bottom: 4px;
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-price-row { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.mini-price { font-size: 14px; font-weight: 600; color: #212121; }
.mini-off { font-size: 10px; color: var(--green); font-weight: 700; }
/* --- BOTTOM NAV (Auto Hide) --- */
.bottom-nav {
position: fixed; bottom: 0; left: 0; width: 100%; height: 60px;
background: white; display: flex;
box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
z-index: 999;
transition: transform 0.3s ease-in-out;
}
.bottom-nav.hidden {
transform: translateY(100%); /* Hides the bar */
}
.btn {
flex: 1; border: none; font-size: 16px; font-weight: 600;
cursor: pointer; display: flex; align-items: center;
justify-content: center; text-transform: uppercase;
transition: all 0.2s;
}
.btn-wishlist { background: white; color: var(--text-dark); border-top: 1px solid #e0e0e0; }
.btn-wishlist.active i { color: #ff4444; animation: pulse 0.3s ease-in-out; }
.btn-wishlist.active span { color: #ff4444; }
/* NEW WHATSAPP BUTTON THEME */
.btn-buy { background: var(--whatsapp); color: white; }
.btn:active { transform: scale(0.98); }
/* --- TOAST --- */
.toast-message {
position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
background: rgba(33, 33, 33, 0.95); color: white;
padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 500;
z-index: 3000; animation: fadeInOut 2s ease; white-space: nowrap;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
display: flex; align-items: center; gap: 8px;
}
@keyframes fadeInOut {
0% { opacity: 0; bottom: 60px; }
10% { opacity: 1; bottom: 80px; }
90% { opacity: 1; bottom: 80px; }
100% { opacity: 0; bottom: 60px; }
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
/* --- MODAL --- */
.modal-overlay {
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.5); z-index: 2999; display: none;
backdrop-filter: blur(2px);
}
.modal-overlay.active { display: block; }
.wishlist-modal {
position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
width: 90%; max-width: 500px; max-height: 80vh;
background: white; border-radius: 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 3000;
display: none; flex-direction: column; overflow: hidden;
}
.wishlist-modal.active { display: flex; animation: popUp 0.3s ease; }
@keyframes popUp { from { transform: translate(-50%, -40%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.wishlist-modal-header {
display: flex; justify-content: space-between; align-items: center;
padding: 16px 20px; background: var(--primary); color: white;
}
.wishlist-modal-body { padding: 20px; overflow-y: auto; max-height: 60vh; background: white; }
.wishlist-item-row {
display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0;
}
.wishlist-item-img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; }
.wishlist-item-info { flex: 1; }
.wishlist-item-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.wishlist-item-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.wishlist-item-remove { color: #999; cursor: pointer; padding: 6px; }
.wishlist-item-remove:hover { color: #ff4444; }
/* Loader */
.loader {
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: white; z-index: 2000; display: flex;
align-items: center; justify-content: center; color: var(--primary);
}
</style>
</head>
<body>
<header id="mainHeader">
<div class="icon-btn" onclick="history.back()"><i class="fas fa-arrow-left"></i></div>
<div class="header-title">Product Details</div>
<div class="icon-btn" onclick="openWishlistModal()">
<i class="fas fa-heart"></i>
<span id="headerWishlistBadge">0</span>
</div>
</header>
<div id="loading" class="loader">
<div style="text-align:center;">
<i class="fas fa-circle-notch fa-spin fa-3x"></i>
<p style="margin-top:15px; font-weight:500; color:#666;">Loading Product...</p>
</div>
</div>
<div id="mainContent" style="display:none;">
<div class="slider-wrapper">
<div class="share-fab" onclick="shareLink()"><i class="fas fa-share-alt"></i></div>
<div class="slider" id="imgSlider" onscroll="updateDots()"></div>
<div class="dots-container" id="dots"></div>
</div>
<div class="card">
<div class="p-cat" id="cat">Category</div>
<h1 class="p-title" id="title">Loading Title...</h1>
<div class="price-box">
<div class="p-price" id="price">₹0</div>
<div class="p-mrp" id="mrp">₹0</div>
<div class="p-off" id="off">0% off</div>
</div>
<div class="features">
<div class="feat-item"><i class="fas fa-check-circle feat-icon"></i>100% Original</div>
<div class="feat-item"><i class="fas fa-bolt feat-icon"></i>Instant Access</div>
<div class="feat-item"><i class="fas fa-shield-alt feat-icon"></i>Secure Pay</div>
</div>
</div>
<div class="card">
<div class="desc-head">Description</div>
<div class="desc-content" id="desc">No description available.</div>
</div>
<div class="card" style="margin-bottom: 0; padding-bottom: 20px;">
<div class="desc-head">Similar Products</div>
<div class="scroll-row" id="similar">
</div>
</div>
</div>
<div class="bottom-nav" id="bottomNav">
<button class="btn btn-wishlist" id="wishlistBtn" onclick="toggleCurrentProductWishlist()">
<i id="wishlistBtnIcon" class="far fa-heart" style="margin-right:8px; font-size: 18px;"></i>
<span id="wishlistBtnText">Wishlist</span>
</button>
<button class="btn btn-buy" id="buyBtn">
<i class="fab fa-whatsapp" style="margin-right:8px; font-size: 20px;"></i> Buy via WhatsApp
</button>
</div>
<div id="modalOverlay" class="modal-overlay" onclick="closeWishlistModal()"></div>
<div id="wishlistModal" class="wishlist-modal">
<div class="wishlist-modal-header">
<h3><i class="fas fa-heart"></i> Your Wishlist</h3>
<div onclick="closeWishlistModal()" style="cursor:pointer; font-size:24px;">×</div>
</div>
<div id="wishlistModalBody" class="wishlist-modal-body"></div>
</div>
<script>
const REPO = "Subeesh-Zero/ProjectAxis-user";
const BASE_URL = `https://raw.githubusercontent.com/${REPO}/main`;
let allProducts = [];
let currentProduct = null;
let currentFinalPrice = 0;
let globalOffer = 0;
let storeWhatsappNumber = ""; // NEW: Global variable for WhatsApp number
// --- SCROLL LOGIC FOR BOTTOM NAV ---
let lastScrollY = 0;
const bottomNav = document.getElementById('bottomNav');
window.addEventListener('scroll', () => {
const currentScrollY = window.scrollY;
// Hide on Scroll Down, Show on Scroll Up
if (currentScrollY > lastScrollY && currentScrollY > 50) {
bottomNav.classList.add('hidden');
} else {
bottomNav.classList.remove('hidden');
}
lastScrollY = currentScrollY;
});
window.onload = async () => {
const params = new URLSearchParams(window.location.search);
const id = params.get('id');
if(!id) { alert("Invalid Product"); window.location.href = 'index.html'; return; }
await loadProduct(id);
updateHeaderBadge();
};
async function loadProduct(pid) {
const ts = new Date().getTime();
try {
// Fetch Settings (including WhatsApp number)
try {
const sRes = await fetch(`${BASE_URL}/settings.json?v=${ts}`);
if(sRes.ok) {
const s = await sRes.json();
if(s.wholeWebsiteOffer) globalOffer = parseInt(s.wholeWebsiteOffer);
if(s.whatsappNumber) storeWhatsappNumber = s.whatsappNumber; // NEW: Fetch WhatsApp number
}
} catch(e) {}
const res = await fetch(`${BASE_URL}/all_products.json?v=${ts}`);
if(!res.ok) throw new Error("Network Error");
allProducts = await res.json();
currentProduct = allProducts.find(p => p.id == pid);
if(currentProduct) {
renderUI(currentProduct);
renderSimilar(currentProduct.category, pid);
checkWishlistStatus();
} else {
alert("Product not found");
window.location.href = 'index.html';
}
} catch(e) {
console.error(e);
document.getElementById('loading').innerHTML = `<p style="text-align:center; padding:20px;">Error Loading.</p>`;
}
}
// --- NEW: WhatsApp Checkout Logic ---
function buyViaWhatsApp(productId, productTitle, productPrice) {
if (!storeWhatsappNumber) {
alert("Store contact is not available right now. Please try again later.");
return;
}
// Get current URL
const productUrl = window.location.href;
// Create formatted message
const message = `Hello! I would like to order this product:\n\n📦 *Item:* ${productTitle}\n💰 *Price:* ₹${productPrice}\n🔗 *Link:* ${productUrl}`;
// Open WhatsApp
const whatsappUrl = `https://wa.me/${storeWhatsappNumber}?text=${encodeURIComponent(message)}`;
window.open(whatsappUrl, '_blank');
}
function renderUI(p) {
let originalPrice = parseInt(p.price);
let pOffer = parseInt(p.offer) || 0;
let finalOffer = Math.max(globalOffer, pOffer);
currentFinalPrice = Math.floor(originalPrice - (originalPrice * finalOffer / 100));
document.getElementById('cat').innerText = p.category;
document.getElementById('title').innerText = p.title;
document.getElementById('price').innerText = `₹${currentFinalPrice}`;
document.getElementById('mrp').innerText = `₹${originalPrice}`;
document.getElementById('off').innerText = `${finalOffer}% off`;
if(finalOffer === 0) {
document.getElementById('mrp').style.display = 'none';
document.getElementById('off').style.display = 'none';
}
if(p.description) document.getElementById('desc').innerText = p.description;
// NEW: BUY BUTTON LOGIC LINKED TO WHATSAPP
const buyBtn = document.getElementById('buyBtn');
buyBtn.onclick = () => {
buyViaWhatsApp(p.id, p.title, currentFinalPrice);
};
// Slider
const slider = document.getElementById('imgSlider');
const dots = document.getElementById('dots');
let images = (p.images && p.images.length > 0) ? p.images : [p.image];
images.forEach((img, index) => {
slider.innerHTML += `<div class="slide"><img src="${img}" onerror="this.src='https://via.placeholder.com/400x300?text=No+Image'"></div>`;
if(images.length > 1) dots.innerHTML += `<div class="dot ${index===0?'active':''}"></div>`;
});
document.getElementById('loading').style.display = 'none';
document.getElementById('mainContent').style.display = 'block';
}
// --- RENDER SIMILAR (Matches Front Page Cards) ---
function renderSimilar(cat, currentId) {
const container = document.getElementById('similar');
const similar = allProducts.filter(p => p.category === cat && p.id != currentId);
if(similar.length === 0) {
document.querySelector('.card:last-child').style.display = 'none';
return;
}
similar.forEach(p => {
let price = parseInt(p.price);
let pOffer = parseInt(p.offer) || 0;
let finalOffer = Math.max(globalOffer, pOffer);
let finalPrice = Math.floor(price - (price * finalOffer / 100));
let img = (p.images && p.images.length > 0) ? p.images[0] : p.image;
// Layout matching Front Page Grid exactly
container.innerHTML += `
<div class="mini-card" onclick="window.location.href='product.html?id=${p.id}'">
<div class="mini-img-container">
<img src="${img}" class="mini-img" onerror="this.src='https://via.placeholder.com/150?text=No+Image'">
</div>
<div class="mini-details">
<div class="mini-title">${p.title}</div>
<div class="mini-price-row">
<span class="mini-price">₹${finalPrice}</span>
${finalOffer > 0 ? `<span class="mini-off">${finalOffer}% off</span>` : ''}
</div>
</div>
</div>
`;
});
}
function updateDots() {
const slider = document.getElementById('imgSlider');
const dots = document.querySelectorAll('.dot');
if(dots.length === 0) return;
const activeIndex = Math.round(slider.scrollLeft / slider.offsetWidth);
dots.forEach((dot, index) => {
if(index === activeIndex) dot.classList.add('active');
else dot.classList.remove('active');
});
}
// --- WISHLIST LOGIC ---
function getWishlist() { return JSON.parse(localStorage.getItem('VPECom_Wishlist')) || []; }
function saveWishlist(list) { localStorage.setItem('VPECom_Wishlist', JSON.stringify(list)); updateHeaderBadge(); }
function updateHeaderBadge() {
const list = getWishlist();
const badge = document.getElementById('headerWishlistBadge');
if(list.length > 0) { badge.style.display = 'inline'; badge.innerText = list.length; }
else { badge.style.display = 'none'; }
}
function checkWishlistStatus() {
if(!currentProduct) return;
const list = getWishlist();
const exists = list.some(item => String(item.id) === String(currentProduct.id));
const btn = document.getElementById('wishlistBtn');
const icon = document.getElementById('wishlistBtnIcon');
if(exists) {
btn.classList.add('active');
icon.classList.remove('far'); icon.classList.add('fas');
document.getElementById('wishlistBtnText').innerText = "Added";
} else {
btn.classList.remove('active');
icon.classList.remove('fas'); icon.classList.add('far');
document.getElementById('wishlistBtnText').innerText = "Wishlist";
}
}
function toggleCurrentProductWishlist() {
if(!currentProduct) return;
let list = getWishlist();
const exists = list.some(item => String(item.id) === String(currentProduct.id));
if(exists) {
list = list.filter(item => String(item.id) !== String(currentProduct.id));
showToast("Removed from Wishlist");
} else {
let img = (currentProduct.images && currentProduct.images.length > 0) ? currentProduct.images[0] : currentProduct.image;
list.push({
id: currentProduct.id, title: currentProduct.title, price: currentFinalPrice, image: img || 'https://via.placeholder.com/150'
});
showToast("❤️ Added to Wishlist");
}
saveWishlist(list);
checkWishlistStatus();
if(document.getElementById('wishlistModal').classList.contains('active')) renderWishlistModal();
}
function removeFromWishlist(pid) {
let list = getWishlist().filter(item => String(item.id) !== String(pid));
saveWishlist(list);
renderWishlistModal();
if(currentProduct && String(currentProduct.id) === String(pid)) checkWishlistStatus();
showToast("Removed from Wishlist");
}
// --- MODAL & TOAST ---
function openWishlistModal() { document.getElementById('modalOverlay').classList.add('active'); document.getElementById('wishlistModal').classList.add('active'); renderWishlistModal(); }
function closeWishlistModal() { document.getElementById('modalOverlay').classList.remove('active'); document.getElementById('wishlistModal').classList.remove('active'); }
function renderWishlistModal() {
const list = getWishlist();
const body = document.getElementById('wishlistModalBody');
if(list.length === 0) { body.innerHTML = '<p style="text-align:center; color:#999; padding:20px;">Your wishlist is empty</p>'; return; }
let html = '';
list.forEach(item => {
html += `
<div class="wishlist-item-row">
<img src="${item.image}" class="wishlist-item-img" onclick="window.location.href='product.html?id=${item.id}'">
<div class="wishlist-item-info">
<div class="wishlist-item-title">${item.title}</div>
<div class="wishlist-item-price">₹${item.price}</div>
</div>
<div class="wishlist-item-remove" onclick="removeFromWishlist('${item.id}')"><i class="fas fa-trash"></i></div>
</div>
`;
});
body.innerHTML = html;
}
function showToast(message) {
const existingToast = document.querySelector('.toast-message');
if (existingToast) existingToast.remove();
const toast = document.createElement('div');
toast.className = 'toast-message';
toast.innerHTML = message;
document.body.appendChild(toast);
setTimeout(() => { toast.remove(); }, 2000);
}
// --- SHARE FUNCTION (SHARES CURRENT URL) ---
function shareLink() {
if(navigator.share) {
navigator.share({ title: document.getElementById('title').innerText, url: window.location.href });
} else {
navigator.clipboard.writeText(window.location.href);
showToast("Link Copied!");
}
}
</script>
</body>
</html>