-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstore.js
More file actions
129 lines (101 loc) · 4.05 KB
/
Copy pathstore.js
File metadata and controls
129 lines (101 loc) · 4.05 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
const buyButtons = document.querySelectorAll('.buy-btn');
buyButtons.forEach(button => {
button.addEventListener('click', () => {
openStripeModal();
});
});
function openStripeModal() {
document.getElementById("stripe-modal").style.display = "flex";
}
function closeStripeModal() {
document.getElementById("stripe-modal").style.display = "none";
}
function processPayment() {
const cardNumber = document.getElementById('card-number').value;
const expiryDate = document.getElementById('expiry-date').value;
const cvv = document.getElementById('cvv').value;
if (cardNumber && expiryDate && cvv) {
alert("Payment Successful! Thank you for your purchase.");
closeStripeModal();
} else {
alert("Please complete the payment information.");
}
}
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("modal").addEventListener("click", (e) => {
if (e.target.classList.contains("modal")) {
closeModal();
}
});
});
function openModal(imageSrc, title, description, isLootbox, price, defaultQuantity = 1) {
const modal = document.getElementById("modal");
const quantityContainer = document.getElementById("quantity-container");
const purchaseSelect = document.getElementById("purchase-select");
const customQuantityInput = document.getElementById("custom-quantity");
document.getElementById("modal-image").src = imageSrc;
document.getElementById("modal-title").innerText = title;
document.getElementById("modal-description").innerText = description;
if (isLootbox) {
quantityContainer.style.display = "block";
purchaseSelect.style.display = "block";
customQuantityInput.style.display = "none";
purchaseSelect.value = defaultQuantity.toString();
updatePrice(price);
} else {
quantityContainer.style.display = "none";
updatePrice(price);
}
document.getElementById("modal").classList.add("show");
customQuantityInput.addEventListener("input", () => updatePrice(price));
purchaseSelect.addEventListener("change", () => updatePrice(price));
}
function closeModal() {
document.getElementById("modal").classList.remove("show");
}
function handleQuantityChange() {
const select = document.getElementById("purchase-select");
const customQuantity = document.getElementById("custom-quantity");
if (select.value === "other") {
customQuantity.style.display = "inline-block";
customQuantity.value = "1";
} else {
customQuantity.style.display = "none";
updatePrice(parseInt(select.value));
}
}
function validateCustomQuantity() {
const input = document.getElementById("custom-quantity");
const value = parseInt(input.value);
if (isNaN(value) || value < 1 || value > 100) {
input.value = "";
} else {
updatePrice(value);
}
}
function updatePrice(price) {
const select = document.getElementById("purchase-select");
const customQuantityInput = document.getElementById("custom-quantity");
let quantity = parseInt(select.value);
if (select.value === "other") {
quantity = parseInt(customQuantityInput.value) || 1;
}
const totalPrice = quantity * price;
document.getElementById("modal-price").innerText = `Price: $${totalPrice.toFixed(2)}`;
}
function openTab(tabName, event) {
const tabButtons = document.querySelectorAll(".tab-button");
const tabContents = document.querySelectorAll(".tab-content");
const tabContainer = document.querySelector(".tab-content-container");
// Get index of clicked tab
currentIndex = [...tabButtons].indexOf(event.currentTarget);
// Update active tab button
tabButtons.forEach(button => button.classList.remove("active"));
event.currentTarget.classList.add("active");
// Slide content container
tabContainer.style.transform = `translateX(-${currentIndex * (100/3)}%)`;
// Update tab visibility
tabContents.forEach((tab, index) => {
tab.classList.toggle("active", index === currentIndex);
});
}