Buttons on MovieViewList now change between active and not active if their clicked
All checks were successful
Gitea CI-CD Pipeline / test (push) Successful in 21s
Gitea CI-CD Pipeline / build-and-deploy (push) Has been skipped

This commit is contained in:
Jannis Heydemann
2026-05-06 09:06:11 +02:00
parent 945dda0506
commit 78f40bc5c7
2 changed files with 21 additions and 0 deletions

View File

@@ -199,10 +199,22 @@ const movieProgram = movieCatalog?.map((movie, movieIndex) => ({
</section>
<script>
import { length } from "astro:schema";
const movieProgramList = document.getElementById("movie-program-list");
movieProgramList?.addEventListener("click", (event: any) => {
const dayButton = event.target.closest(".program-day-tab");
let dayButtonsAll = document.getElementsByClassName("program-day-tab");
let dayButtons: any[] = [];
//only select the daybuttons for this movie
for (let i = 0; i < dayButtonsAll.length; i++) {
if (dayButtonsAll[i].getAttribute("data-program-index") == dayButton.getAttribute("data-program-index")) {
dayButtons.push(dayButtonsAll[i])
}
}
if (dayButton) {
const programIndex = dayButton.getAttribute("data-program-index");
const dayIndex = parseInt(dayButton.getAttribute("data-day-index"));
@@ -225,6 +237,14 @@ const movieProgram = movieCatalog?.map((movie, movieIndex) => ({
`,
)
.join("");
dayButton.setAttribute("class", dayButton.getAttribute("class") + " active")
for (let i = 0; i < dayButtons.length; i++) {
// check if current button is the one needed
if (dayButtons[i].getAttribute("data-day-index") != dayIndex.toString()) {
dayButtons[i].setAttribute("class", "program-day-tab");
}
}
}
});

View File

@@ -80,6 +80,7 @@ export interface BaseCartItem {
export interface MovieCartItem extends BaseCartItem {
category: "movie";
seatId: string;
poster?: string;
}
export interface SnackCartItem extends BaseCartItem {