-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (69 loc) · 2.46 KB
/
script.js
File metadata and controls
77 lines (69 loc) · 2.46 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
function filterCategory(category) {
const cards = document.querySelectorAll('.menu-card');
const listItems = document.querySelectorAll('.menu-categories li');
// Update active class in sidebar
listItems.forEach(li => {
li.classList.remove('active');
if (li.innerText === category) li.classList.add('active');
});
// Show/Hide cards
cards.forEach(card => {
if (category === 'All' || card.getAttribute('data-category') === category) {
card.style.display = 'block';
} else {
card.style.display = 'none';
}
});
}
// Tab Switching
const loginTab = document.getElementById('loginTab');
const signupTab = document.getElementById('signupTab');
const loginForm = document.getElementById('loginForm');
const signupForm = document.getElementById('signupForm');
loginTab.addEventListener('click', () => {
loginTab.classList.add('active');
signupTab.classList.remove('active');
loginForm.classList.remove('hidden');
signupForm.classList.add('hidden');
});
signupTab.addEventListener('click', () => {
signupTab.classList.add('active');
loginTab.classList.remove('active');
signupForm.classList.remove('hidden');
loginForm.classList.add('hidden');
});
// Password Toggle
document.querySelectorAll('.toggle-pass').forEach(btn => {
btn.addEventListener('click', function() {
const targetId = this.getAttribute('data-target');
const input = document.getElementById(targetId);
if (input.type === "password") {
input.type = "text";
this.textContent = "visibility_off";
} else {
input.type = "password";
this.textContent = "visibility";
}
});
});
function addToCart(itemId, itemName, itemPrice) {
// Create form data to send to the PHP logic at the top of menu.php
let formData = new FormData();
formData.append('id', itemId);
formData.append('name', itemName);
formData.append('price', itemPrice);
fetch('menu.php', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(cartCount => {
// Update the cart count in the header (if you have a span with id="cart-count")
const countBadge = document.getElementById('cart-count');
if (countBadge) {
countBadge.innerText = cartCount;
}
alert(itemName + " added to cart!");
})
.catch(error => console.error('Error:', error));
}