-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite.html
239 lines (223 loc) · 9.63 KB
/
website.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SASA TARANG Ticket Booking</title>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Round|Material+Icons+Sharp|Material+Icons+Two+Tone"
rel="stylesheet"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<style>
body {
font-family: "Poppins", sans-serif;
background-color: rgb(128, 0, 0);
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.tickets {
width: 1200px;
padding: 20px;
background: white;
color: black;
border-radius: 10px;
box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.2);
overflow: auto;
max-height: 90vh;
}
.title {
font-size: 24px;
text-align: center;
margin-bottom: 20px;
}
.ticket-types {
display: flex;
justify-content: space-around;
margin-bottom: 20px;
}
.ticket-types label {
padding: 10px 20px;
background-color: #ddd;
cursor: pointer;
border-radius: 5px;
border: 1px solid #800000;
font-weight: bold;
}
.ticket-types input[type="radio"] {
display: none;
}
.ticket-types input:checked + label {
background-color: #800000;
color: white;
}
.seats-container {
display: flex;
flex-direction: column;
align-items: center;
}
.row {
display: flex;
justify-content: center;
margin-bottom: 10px;
}
.seat {
width: 30px;
height: 30px;
background-color: #ddd;
border: 1px solid #999;
border-radius: 4px;
cursor: pointer;
text-align: center;
line-height: 30px;
margin: 3px;
}
.seat.booked {
background-color: #999;
cursor: not-allowed;
}
.seat.selected {
background-color: #800000;
color: white;
}
.total-section {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.total-section button {
padding: 10px 20px;
background-color: #800000;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="tickets">
<div class="title">SASA TARANG Event</div>
<!-- Ticket Type Selector -->
<div class="ticket-types">
<input type="radio" id="performer" name="ticket-type" value="10" checked />
<label for="performer">Performer: $10</label>
<input type="radio" id="student" name="ticket-type" value="12" />
<label for="student">Student: $12</label>
<input type="radio" id="adult" name="ticket-type" value="16" />
<label for="adult">Adult: $16</label>
</div>
<!-- Seating Layout -->
<div class="seats-container" id="seats-container">
<!-- Seats will be generated by JavaScript -->
</div>
<!-- Total Amount and Button -->
<div class="total-section">
<div>
<span id="ticket-count">0</span> Tickets - $<span id="total-amount">0</span>
</div>
<button id="book-now">Book Now</button>
</div>
</div>
<script>
const seatsContainer = document.getElementById('seats-container');
const ticketCountDisplay = document.getElementById('ticket-count');
const totalAmountDisplay = document.getElementById('total-amount');
const bookNowButton = document.getElementById('book-now');
let ticketPrice = 10; // Default price is for Performer ($10)
let selectedSeatsCount = 0;
let totalAmount = 0;
const seatingLayout = [
['A1', 'A2', 'A3', 'A4', '', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14', '', 'A15', 'A16', 'A17', 'A18', 'A19', 'A20', 'A21'],
['B1', 'B2', 'B3', 'B4', 'B5', '', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15', 'B16', 'B17', 'B18', 'B19', 'B20', 'B21', '', 'B22', 'B23', 'B24', 'B25', 'B26', 'B27', 'B28', 'B29', 'B30', 'B31'],
['C1', 'C2', 'C3', 'C4', 'C5', '', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17', 'C18', 'C19', 'C20', 'C21', '', 'C22', 'C23', 'C24', 'C25', 'C26', 'C27', 'C28', 'C29', 'C30', 'C31'],
['D1', 'D2', 'D3', 'D4', 'D5', '', 'D6', 'D7', 'D8', 'D9', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15', 'D16', 'D17', 'D18', 'D19', 'D20', 'D21', '', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D28', 'D29', 'D30', 'D31'],
['E1', 'E2', 'E3', 'E4', 'E5', '', 'E6', 'E7', 'E8', 'E9', 'E10', 'E11', 'E12', 'E13', 'E14', 'E15', 'E16', 'E17', 'E18', 'E19', 'E20', 'E21', '', 'E22', 'E23', 'E24', 'E25', 'E26', 'E27', 'E28', 'E29', 'E30', 'E31'],
['F1', 'F2', 'F3', 'F4', 'F5', '', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', '', 'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F30', 'F31'],
['G1', 'G2', 'G3', 'G4', 'G5', '', 'G6', 'G7', 'G8', 'G9', 'G10', 'G11', 'G12', 'G13', 'G14', 'G15', 'G16', 'G17', 'G18', 'G19', 'G20', 'G21', '', 'G22', 'G23', 'G24', 'G25', 'G26', 'G27', 'G28', 'G29', 'G30', 'G31'],
['H1', 'H2', 'H3', '', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13', 'H14', 'H15', 'H16', 'H17', 'H18', 'H19', '', 'H20', 'H21', 'H22', 'H23', 'H24', 'H25', 'H26', 'H27', 'H28', 'H29'],
['I1', 'I2', 'I3', '', 'I4', 'I5', 'I6', 'I7', 'I8', 'I9', 'I10', 'I11', 'I12', 'I13', 'I14', 'I15', 'I16', 'I17', 'I18', 'I19', '', 'I20', 'I21', 'I22', 'I23', 'I24', 'I25', 'I26', 'I27', 'I28', 'I29'],
['K1', 'K2', 'K3', 'K4', '', 'K5', 'K6', 'K7', 'K8', 'K9', '', 'K10', 'K11', 'K12', 'K13', 'K14', '', 'K15', 'K16', 'K17', 'K18', 'K19', 'K20', 'K21', 'K22', 'K23', 'K24'],
['L1', 'L2', 'L3', '', 'L4', 'L5', 'L6', 'L7', 'L8', '', 'L9', 'L10', 'L11', '', 'L12', 'L13', 'L14', 'L15', 'L16', 'L17', 'L18', 'L19', 'L20', 'L21'],
['M1', 'M2', '', 'M3', 'M4', 'M5', 'M6', 'M7', '', 'M8', 'M9', 'M10', '', 'M11', 'M12', 'M13', 'M14', 'M15', 'M16', 'M17', 'M18', 'M19'],
['N1', 'N2', '', 'N3', 'N4', 'N5', 'N6', '', 'N7', 'N8', 'N9', 'N10', 'N11', '', 'N12', 'N13', 'N14', 'N15', 'N16', 'N17', 'N18']
];
// Example of booked seats
const bookedSeats = ['A2', 'A3', 'A8', 'A9', 'A10', 'A11'];
// Generate the seating layout properly by creating a new row for each set of seats
seatingLayout.forEach(row => {
const rowDiv = document.createElement('div'); // Create a row container
rowDiv.classList.add('row'); // Add the class 'row' to make it a flexbox container
row.forEach(seat => {
if (seat === '') {
// Empty space (no seat in this position)
const emptySeat = document.createElement('div');
emptySeat.style.visibility = 'hidden';
emptySeat.style.width = '30px'; // Keep space
rowDiv.appendChild(emptySeat);
} else {
const isBooked = bookedSeats.includes(seat);
const seatElement = document.createElement('div');
seatElement.classList.add('seat');
if (isBooked) {
seatElement.classList.add('booked');
}
seatElement.innerText = seat;
// Add click event listener when creating the seat
seatElement.addEventListener('click', function () {
if (seatElement.classList.contains('booked')) {
return; // Can't select booked seats
}
if (seatElement.classList.contains('selected')) {
seatElement.classList.remove('selected');
selectedSeatsCount--;
totalAmount -= ticketPrice;
} else {
seatElement.classList.add('selected');
selectedSeatsCount++;
totalAmount += ticketPrice;
}
// Update the ticket count and total amount
ticketCountDisplay.innerText = selectedSeatsCount;
totalAmountDisplay.innerText = totalAmount;
});
rowDiv.appendChild(seatElement);
}
});
// Append the row to the seats container
seatsContainer.appendChild(rowDiv);
});
// Update ticket price based on the selected ticket type
document.querySelectorAll('input[name="ticket-type"]').forEach(radio => {
radio.addEventListener('change', function () {
ticketPrice = parseInt(this.value);
// Reset selection when ticket type is changed
document.querySelectorAll('.seat.selected').forEach(seat => {
seat.classList.remove('selected');
});
selectedSeatsCount = 0;
totalAmount = 0;
ticketCountDisplay.innerText = selectedSeatsCount;
totalAmountDisplay.innerText = totalAmount;
});
});
// Book Now button event
bookNowButton.addEventListener('click', function () {
if (selectedSeatsCount === 0) {
alert('Please select at least one seat.');
} else {
alert(`You have booked ${selectedSeatsCount} seat(s) for $${totalAmount}.`);
}
});
</script>
</body>
</html>