This commit is contained in:
@@ -51,14 +51,16 @@ function persistCurrentUser() {
|
||||
}
|
||||
}
|
||||
|
||||
let users = readStorageJson("eagleUsers", []);
|
||||
export let users = readStorageJson("eagleUsers", []);
|
||||
if (!Array.isArray(users)) {
|
||||
users = [];
|
||||
}
|
||||
users = users.map(normalizeUser).filter(Boolean);
|
||||
|
||||
const rawCurrentUser = readStorageJson("currentUser", null);
|
||||
var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
|
||||
|
||||
export var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
|
||||
|
||||
if (currentUser && currentUser.email) {
|
||||
const currentEmail = currentUser.email;
|
||||
const storedMatch = users.find((user: { email: string; }) => {
|
||||
@@ -84,7 +86,7 @@ function getInputValue(id: string): string {
|
||||
return el?.value.trim() ?? "";
|
||||
}
|
||||
|
||||
async function registerUser() {
|
||||
export async function registerUser() {
|
||||
const firstName = getInputValue("reg-firstname");
|
||||
const lastName = getInputValue("reg-lastname");
|
||||
const email = getInputValue("reg-email").toLowerCase();
|
||||
@@ -129,7 +131,7 @@ const password = document.querySelector<HTMLInputElement>("#reg-password")?.valu
|
||||
openAccountDashboard();
|
||||
}
|
||||
|
||||
async function loginUser() {
|
||||
export async function loginUser() {
|
||||
const email = (document.querySelector<HTMLInputElement>("#login-email")?.value.trim() || "").toLowerCase();
|
||||
const password = document.querySelector<HTMLInputElement>("#login-password")?.value || "";
|
||||
const hashedPassword = await hashMessage(password);
|
||||
@@ -148,7 +150,7 @@ async function loginUser() {
|
||||
openAccountDashboard();
|
||||
}
|
||||
|
||||
function openAccountDashboard() {
|
||||
export function openAccountDashboard() {
|
||||
const accountView = document.getElementById("account-view");
|
||||
if (!accountView) {
|
||||
return;
|
||||
@@ -464,3 +466,4 @@ function logoutUser() {
|
||||
persistCurrentUser();
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
let currentBookingContext = null;
|
||||
let currentHallLayout = null;
|
||||
import { seatLayouts, occupiedSeatsData, prices, cart } from "./main"
|
||||
import { renderCart, saveCart } from "./cart";
|
||||
import { renderCheckout } from "./checkout";
|
||||
|
||||
function openBooking(movie, hall, time) {
|
||||
const titleEl = document.getElementById("modal-movie-title");
|
||||
const infoEl = document.getElementById("modal-info-text");
|
||||
let currentBookingContext: any = null;
|
||||
let currentHallLayout: any = null;
|
||||
|
||||
if (titleEl) {
|
||||
titleEl.innerText = movie;
|
||||
}
|
||||
export function openBooking(movie: string, hall: string, time: any) {
|
||||
const titleEl = document.getElementById("modal-movie-title");
|
||||
const infoEl = document.getElementById("modal-info-text");
|
||||
|
||||
if (infoEl) {
|
||||
infoEl.innerText = `${hall} • ${time} Uhr`;
|
||||
}
|
||||
if (titleEl) {
|
||||
titleEl.innerText = movie;
|
||||
}
|
||||
|
||||
currentBookingContext = { movie, hall, time };
|
||||
if (infoEl) {
|
||||
infoEl.innerText = `${hall} • ${time} Uhr`;
|
||||
}
|
||||
|
||||
createSeats(hall, time);
|
||||
renderBookingLegend();
|
||||
updateBookingSummary();
|
||||
currentBookingContext = { movie, hall, time };
|
||||
|
||||
document.getElementById("booking-modal")?.classList.remove("hidden");
|
||||
}
|
||||
createSeats(hall, time);
|
||||
renderBookingLegend();
|
||||
updateBookingSummary();
|
||||
|
||||
function getRowLabel(rowIndex) {
|
||||
document.getElementById("booking-modal")?.classList.remove("hidden");
|
||||
}
|
||||
|
||||
function getRowLabel(rowIndex: number) {
|
||||
return String(rowIndex + 1);
|
||||
}
|
||||
|
||||
function buildHallLayout(hallName, baseConfig) {
|
||||
function buildHallLayout(hallName: string, baseConfig:any) {
|
||||
const rows = Number(baseConfig.rows || 0);
|
||||
const totalCols = Number(baseConfig.left || 0) + Number(baseConfig.right || 0);
|
||||
const isDeluxe = /deluxe/i.test(hallName);
|
||||
@@ -39,7 +43,7 @@ function buildHallLayout(hallName, baseConfig) {
|
||||
const vipRows = rows > 0 ? [rows] : [];
|
||||
|
||||
const dboxMap = new Set();
|
||||
const markDboxRange = (rowNumber, startCol, width) => {
|
||||
const markDboxRange = (rowNumber: number, startCol: number, width: number) => {
|
||||
if (!rowNumber || width <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +56,7 @@ function buildHallLayout(hallName, baseConfig) {
|
||||
|
||||
if (isDeluxe) {
|
||||
const configuredDboxSeats = Array.isArray(baseConfig.dbox)
|
||||
? baseConfig.dbox.reduce((sum, section) => sum + Number(section.w || 0), 0)
|
||||
? baseConfig.dbox.reduce((sum: number, section: any) => sum + Number(section.w || 0), 0)
|
||||
: 0;
|
||||
|
||||
const totalDboxSeats = Math.max(4, configuredDboxSeats || 0);
|
||||
@@ -77,7 +81,7 @@ function buildHallLayout(hallName, baseConfig) {
|
||||
markDboxRange(rowNumber, startCol, seatsForRow);
|
||||
});
|
||||
} else if (Array.isArray(baseConfig.dbox)) {
|
||||
baseConfig.dbox.forEach((section) => {
|
||||
baseConfig.dbox.forEach((section: any) => {
|
||||
const rowNumber = Number(section.r || 0);
|
||||
const width = Number(section.w || 0);
|
||||
const startCol = Number(section.c || 0);
|
||||
@@ -96,7 +100,7 @@ function buildHallLayout(hallName, baseConfig) {
|
||||
};
|
||||
}
|
||||
|
||||
function getSeatType(layout, rowNumber, colNumber) {
|
||||
function getSeatType(layout: any, rowNumber: number, colNumber: number) {
|
||||
if (layout.dboxMap.has(`${rowNumber}-${colNumber}`)) {
|
||||
return "dbox";
|
||||
}
|
||||
@@ -112,7 +116,7 @@ function getSeatType(layout, rowNumber, colNumber) {
|
||||
return "normal";
|
||||
}
|
||||
|
||||
function createSeatElement({ seatId, seatType, occupiedSeats }) {
|
||||
function createSeatElement({seatId, seatType, occupiedSeats }:any) {
|
||||
const seat = document.createElement("button");
|
||||
seat.type = "button";
|
||||
seat.classList.add("seat", seatType);
|
||||
@@ -136,7 +140,7 @@ function createSeatElement({ seatId, seatType, occupiedSeats }) {
|
||||
return seat;
|
||||
}
|
||||
|
||||
function createSeats(hallName, time) {
|
||||
function createSeats(hallName: string, time: any) {
|
||||
const seatGrid = document.getElementById("seat-grid");
|
||||
if (!seatGrid) {
|
||||
return;
|
||||
@@ -144,7 +148,8 @@ function createSeats(hallName, time) {
|
||||
|
||||
seatGrid.innerHTML = "";
|
||||
|
||||
const baseConfig = seatLayouts[hallName];
|
||||
const arrIndex = hallName as keyof typeof seatLayouts;
|
||||
const baseConfig: any = seatLayouts[arrIndex];
|
||||
if (!baseConfig) {
|
||||
currentHallLayout = null;
|
||||
return;
|
||||
@@ -235,7 +240,7 @@ function renderBookingLegend() {
|
||||
}
|
||||
|
||||
function updateBookingSummary() {
|
||||
const selectedSeats = Array.from(document.querySelectorAll("#seat-grid .seat.selected"));
|
||||
const selectedSeats = Array.from(document.querySelectorAll("#seat-grid .seat.selected")) as HTMLElement[];;
|
||||
const summaryPanel = document.getElementById("booking-summary");
|
||||
const summaryItems = document.getElementById("summary-items");
|
||||
const totalEl = document.getElementById("total-price");
|
||||
@@ -245,7 +250,7 @@ function updateBookingSummary() {
|
||||
if (summaryItems) {
|
||||
summaryItems.innerHTML = selectedSeats
|
||||
.map((seat) => {
|
||||
const type = seat.dataset.type || "normal";
|
||||
const type = (seat.dataset.type || "normal") as keyof typeof prices;
|
||||
const seatPrice = Number(prices?.[type] ?? prices?.normal ?? 11);
|
||||
total += seatPrice;
|
||||
|
||||
@@ -272,12 +277,13 @@ function updateBookingSummary() {
|
||||
summaryPanel?.classList.toggle("hidden", selectedSeats.length === 0);
|
||||
}
|
||||
|
||||
function findMoviePoster(movieTitle) {
|
||||
function findMoviePoster(movieTitle: string) {
|
||||
const cards = Array.from(document.querySelectorAll(".movie-card, .detailed-card"));
|
||||
const normalizedTarget = String(movieTitle || "").trim().toLowerCase();
|
||||
|
||||
for (const card of cards) {
|
||||
const title = card.querySelector("h2, h3")?.innerText?.trim().toLowerCase();
|
||||
const currentCard = card.querySelector("h2, h3") as HTMLElement;
|
||||
const title = currentCard.innerText?.trim().toLowerCase();
|
||||
if (title === normalizedTarget) {
|
||||
const imageSrc = card.querySelector("img")?.src;
|
||||
if (imageSrc) {
|
||||
@@ -290,7 +296,7 @@ function findMoviePoster(movieTitle) {
|
||||
}
|
||||
|
||||
function confirmSelectedSeats() {
|
||||
const selectedSeats = Array.from(document.querySelectorAll("#seat-grid .seat.selected"));
|
||||
const selectedSeats = Array.from(document.querySelectorAll("#seat-grid .seat.selected")) as HTMLElement[];
|
||||
|
||||
if (!currentBookingContext || selectedSeats.length === 0) {
|
||||
alert("Bitte waehle mindestens einen Platz aus.");
|
||||
@@ -304,7 +310,7 @@ function confirmSelectedSeats() {
|
||||
const seatId = seat.dataset.seatId;
|
||||
const seatType = seat.dataset.type || "normal";
|
||||
|
||||
const alreadyInCart = cart.some((item) =>
|
||||
const alreadyInCart = cart.some((item: any) =>
|
||||
item.category === "movie" &&
|
||||
item.title === currentBookingContext.movie &&
|
||||
item.hall === currentBookingContext.hall &&
|
||||
@@ -1,8 +1,10 @@
|
||||
function formatEuro(value) {
|
||||
import { cart } from "./main";
|
||||
|
||||
function formatEuro(value: number) {
|
||||
return `${Number(value || 0).toFixed(2).replace(".", ",")} EUR`;
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
function escapeHtml(value: any) {
|
||||
return String(value || "")
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
@@ -11,14 +13,14 @@ function escapeHtml(value) {
|
||||
.replaceAll("'", "'");
|
||||
}
|
||||
|
||||
function buildCartKey(item) {
|
||||
function buildCartKey(item: { category: string; seatId: any; hall: any; time: any; title: any; }) {
|
||||
const infoText = item.category === "movie"
|
||||
? `Sitz: ${item.seatId} (${item.hall})`
|
||||
: item.time;
|
||||
return `${item.title}-${item.hall}-${infoText}`;
|
||||
}
|
||||
|
||||
function isDrinkItem(item) {
|
||||
function isDrinkItem(item: { category: string; title: any; hall: any; }) {
|
||||
if (item.category !== "snack") {
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +41,7 @@ function isDrinkItem(item) {
|
||||
return drinkKeywords.some((word) => title.includes(word)) || size.includes("l");
|
||||
}
|
||||
|
||||
function buildItemInfo(item) {
|
||||
function buildItemInfo(item: { category: any; seatId?: any; hall: any; time?: any; title: any; }) {
|
||||
if (item.category === "movie") {
|
||||
return `
|
||||
<div>Sitzplatz: ${escapeHtml(item.seatId || "-")}</div>
|
||||
@@ -65,7 +67,7 @@ function buildItemInfo(item) {
|
||||
function groupCartItems() {
|
||||
const groups = new Map();
|
||||
|
||||
cart.forEach((item) => {
|
||||
cart.forEach((item: { price?: any; category: string; seatId: any; hall: any; time: any; title: any; }) => {
|
||||
const key = buildCartKey(item);
|
||||
|
||||
if (!groups.has(key)) {
|
||||
@@ -85,12 +87,12 @@ function groupCartItems() {
|
||||
return Array.from(groups.values());
|
||||
}
|
||||
|
||||
function saveCart() {
|
||||
export function saveCart() {
|
||||
localStorage.setItem("eagleCart", JSON.stringify(cart));
|
||||
updateCartBadge();
|
||||
}
|
||||
|
||||
function updateCartBadge() {
|
||||
export function updateCartBadge() {
|
||||
const cartBadge = document.getElementById("cart-badge");
|
||||
|
||||
if (!cartBadge) {
|
||||
@@ -101,7 +103,7 @@ function updateCartBadge() {
|
||||
cartBadge.classList.toggle("hidden", cart.length === 0);
|
||||
}
|
||||
|
||||
function renderCart() {
|
||||
export function renderCart() {
|
||||
const cartList = document.getElementById("cart-items-list");
|
||||
const totalEl = document.getElementById("cart-total-right");
|
||||
const vatEl = document.getElementById("cart-vat-right");
|
||||
@@ -172,22 +174,23 @@ function renderCart() {
|
||||
|
||||
saveCart();
|
||||
}
|
||||
|
||||
window.removeItem = function removeItem(id) {
|
||||
cart = cart.filter((item) => item.id !== id);
|
||||
//@ts-ignore
|
||||
window.removeItem = function removeItem(id: any) {
|
||||
var localCart = cart.filter((item: { id: any; }) => item.id !== id);
|
||||
saveCart();
|
||||
renderCart();
|
||||
};
|
||||
|
||||
window.changeQty = function changeQty(title, delta) {
|
||||
//@ts-ignore
|
||||
window.changeQty = function changeQty(title, delta): void {
|
||||
if (delta > 0) {
|
||||
const item = cart.find((entry) => entry.title === title);
|
||||
const item = cart.find((entry: { title: any; }) => entry.title === title);
|
||||
if (item) {
|
||||
cart.push({ ...item, id: Date.now() + Math.random() });
|
||||
}
|
||||
} else {
|
||||
const index = cart
|
||||
.map((entry) => entry.title)
|
||||
.map((entry: { title: any; }) => entry.title)
|
||||
.lastIndexOf(title);
|
||||
if (index !== -1) {
|
||||
cart.splice(index, 1);
|
||||
@@ -197,3 +200,4 @@ window.changeQty = function changeQty(title, delta) {
|
||||
saveCart();
|
||||
renderCart();
|
||||
};
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
function formatCheckoutEuro(value) {
|
||||
import { currentUser, users } from "./account";
|
||||
import { renderCart, saveCart } from "./cart";
|
||||
import { cart, emptyCart, occupiedSeatsData } from "./main";
|
||||
|
||||
function formatCheckoutEuro(value: number) {
|
||||
return `${Number(value || 0).toFixed(2).replace(".", ",")} EUR`;
|
||||
}
|
||||
|
||||
let selectedPaymentMethod = "";
|
||||
let checkoutEventsBound = false;
|
||||
|
||||
function setCheckoutStep(step) {
|
||||
function setCheckoutStep(step: number) {
|
||||
const step1 = document.getElementById("checkout-step-1");
|
||||
const step2 = document.getElementById("checkout-step-2");
|
||||
const step3 = document.getElementById("checkout-step-3");
|
||||
@@ -27,7 +31,7 @@ function setCheckoutStep(step) {
|
||||
line2?.classList.toggle("active", step >= 3);
|
||||
}
|
||||
|
||||
function renderCheckout() {
|
||||
export function renderCheckout() {
|
||||
const summaryList = document.getElementById("checkout-summary-list");
|
||||
const totalDisplay = document.getElementById("checkout-total-display");
|
||||
const vatDisplay = document.getElementById("checkout-vat-display");
|
||||
@@ -115,7 +119,7 @@ function generateTicket() {
|
||||
`;
|
||||
}
|
||||
|
||||
function saveOrderForCurrentUser(orderItems, orderTotal) {
|
||||
function saveOrderForCurrentUser(orderItems: any[], orderTotal: any) {
|
||||
if (typeof currentUser === "undefined" || !currentUser) {
|
||||
return;
|
||||
}
|
||||
@@ -131,6 +135,7 @@ function saveOrderForCurrentUser(orderItems, orderTotal) {
|
||||
paymentMethod: selectedPaymentMethod || "-"
|
||||
};
|
||||
|
||||
//@ts-ignore
|
||||
const userIndex = users.findIndex((entry) => entry.email === currentUser.email);
|
||||
if (userIndex === -1) {
|
||||
return;
|
||||
@@ -144,7 +149,7 @@ function saveOrderForCurrentUser(orderItems, orderTotal) {
|
||||
localStorage.setItem("eagleUsers", JSON.stringify(users));
|
||||
}
|
||||
|
||||
function reserveSeatsAfterPayment(orderItems) {
|
||||
function reserveSeatsAfterPayment(orderItems: any[]) {
|
||||
const movieItems = orderItems.filter((item) => item.category === "movie");
|
||||
|
||||
movieItems.forEach((item) => {
|
||||
@@ -166,7 +171,7 @@ function completeCheckout() {
|
||||
saveOrderForCurrentUser(orderItems, orderTotal);
|
||||
reserveSeatsAfterPayment(orderItems);
|
||||
|
||||
cart = [];
|
||||
emptyCart?.()
|
||||
saveCart?.();
|
||||
renderCart?.();
|
||||
}
|
||||
@@ -180,7 +185,7 @@ function bindCheckoutEvents() {
|
||||
|
||||
const nextButton = document.getElementById("btn-next-step-2");
|
||||
const backButton = document.getElementById("btn-back-to-step1");
|
||||
const payNowButton = document.getElementById("btn-pay-now");
|
||||
const payNowButton = document.getElementById("btn-pay-now") as HTMLButtonElement;
|
||||
|
||||
document.querySelectorAll(".payment-method").forEach((method) => {
|
||||
method.addEventListener("click", () => {
|
||||
@@ -189,6 +194,7 @@ function bindCheckoutEvents() {
|
||||
});
|
||||
|
||||
method.classList.add("selected");
|
||||
//@ts-ignore
|
||||
selectedPaymentMethod = method.dataset.method || "";
|
||||
nextButton?.classList.remove("hidden");
|
||||
});
|
||||
@@ -1,13 +1,18 @@
|
||||
// Shared app state for legacy script files (account.js, booking.js, cart.js, checkout.js)
|
||||
var prices = { normal: 11.0, imax: 15.0, vip: 12.0, dbox: 16.0 };
|
||||
var seatLayouts = {
|
||||
import { currentUser, loginUser, openAccountDashboard, registerUser } from "./account";
|
||||
import { openBooking } from "./booking";
|
||||
import { renderCart, saveCart, updateCartBadge } from "./cart";
|
||||
import { renderCheckout } from "./checkout";
|
||||
|
||||
// Shared app state for legacy script files (account.js, booking.js, cart.js, checkout.js)
|
||||
export const prices: Record<string, number> = { normal: 11.0, imax: 15.0, vip: 12.0, dbox: 16.0 };
|
||||
export var seatLayouts = {
|
||||
"Kino 1": { rows: 6, left: 3, right: 7, vipRows: [5], dbox: [] },
|
||||
"Kino 2": { rows: 7, left: 5, right: 5, vipRows: [6], dbox: [] },
|
||||
"Deluxe 1": { rows: 10, left: 7, right: 8, vipRows: [9], dbox: [{ r: 4, c: 5, w: 4 }] },
|
||||
IMAX: { rows: 15, left: 10, right: 10, vipRows: [], dbox: [], isImax: true }
|
||||
};
|
||||
var cart = JSON.parse(localStorage.getItem("eagleCart")) || [];
|
||||
var occupiedSeatsData = JSON.parse(localStorage.getItem("eagleOccupied")) || {};
|
||||
export var cart = JSON.parse(localStorage.getItem("eagleCart") || '{}');
|
||||
export var occupiedSeatsData = JSON.parse(localStorage.getItem("eagleOccupied") || '{}');
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const views = {
|
||||
@@ -326,10 +331,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
["13:00", "16:00", "18:20", "20:40"]
|
||||
];
|
||||
|
||||
let movieProgram = [];
|
||||
let heroItems = [];
|
||||
let movieProgram: any = []; // TODO: Find type
|
||||
let heroItems: any = []; // TODO: find Type
|
||||
let heroIndex = 0;
|
||||
let heroTimer = null;
|
||||
let heroTimer:any = null; // TODO: find type
|
||||
|
||||
const weekdayShort = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
|
||||
|
||||
@@ -348,7 +353,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
};
|
||||
|
||||
const showMovieList = (programIndexToFocus = null) => {
|
||||
const showMovieList = (programIndexToFocus:number = NaN) => {
|
||||
hideAllViews();
|
||||
views.list?.classList.remove("hidden");
|
||||
|
||||
@@ -365,7 +370,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
};
|
||||
|
||||
const showStaticView = (viewElement) => {
|
||||
const showStaticView = (viewElement: HTMLElement) => {
|
||||
if (!viewElement) {
|
||||
return;
|
||||
}
|
||||
@@ -394,20 +399,20 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
ui.bookingModal?.classList.add("hidden");
|
||||
};
|
||||
|
||||
const escapeHtml = (value) => String(value || "")
|
||||
const escapeHtml = (value: string) => String(value || "")
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'");
|
||||
|
||||
const formatDateShort = (dateObj) => {
|
||||
const formatDateShort = (dateObj: any) => {
|
||||
const day = String(dateObj.getDate()).padStart(2, "0");
|
||||
const month = String(dateObj.getMonth() + 1).padStart(2, "0");
|
||||
return `${day}.${month}.`;
|
||||
};
|
||||
|
||||
const buildDayMeta = (offset) => {
|
||||
const buildDayMeta = (offset: number) => {
|
||||
const date = new Date();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setDate(date.getDate() + offset);
|
||||
@@ -441,14 +446,15 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
};
|
||||
};
|
||||
|
||||
const buildScheduleForMovie = (movieIndex) => {
|
||||
const buildScheduleForMovie = (movieIndex: number) => {
|
||||
return Array.from({ length: 7 }, (_, dayOffset) => {
|
||||
const dayMeta = buildDayMeta(dayOffset);
|
||||
const pattern = timePatterns[(movieIndex + dayOffset) % timePatterns.length];
|
||||
const pattern = timePatterns[(movieIndex + dayOffset) % timePatterns.length] || "Error reading";
|
||||
const desiredCount = 4 + ((movieIndex + dayOffset) % 2);
|
||||
const showCount = Math.min(pattern.length, desiredCount);
|
||||
|
||||
const showings = pattern.slice(0, showCount).map((time, slotIndex) => {
|
||||
//@ts-ignore
|
||||
const showings = pattern.slice(0, showCount).map((time: any, slotIndex: number) => { // TODO: fix map issue
|
||||
const hall = hallRotation[(movieIndex + dayOffset + slotIndex) % hallRotation.length];
|
||||
return { time, hall };
|
||||
});
|
||||
@@ -468,7 +474,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
heroItems = movieProgram.slice(0, 5);
|
||||
};
|
||||
|
||||
const setHeroSlide = (index) => {
|
||||
const setHeroSlide = (index: number) => {
|
||||
if (!heroItems.length || !ui.heroSlider) {
|
||||
return;
|
||||
}
|
||||
@@ -497,17 +503,18 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.heroSlider.innerHTML = heroItems.map((movie, index) => `
|
||||
ui.heroSlider.innerHTML = heroItems.map((movie: any, index: number) => `
|
||||
<div class="hero-slide ${index === 0 ? "active" : ""}" style="background-image: linear-gradient(118deg, rgba(0,0,0,0.34), rgba(0,0,0,0.04)), url('${escapeHtml(movie.backdrop || movie.poster)}');"></div>
|
||||
`).join("");
|
||||
|
||||
if (ui.heroDots) {
|
||||
ui.heroDots.innerHTML = heroItems.map((_, index) => `
|
||||
ui.heroDots.innerHTML = heroItems.map((_:any, index: number) => `
|
||||
<button type="button" class="hero-dot ${index === 0 ? "active" : ""}" data-hero-index="${index}"></button>
|
||||
`).join("");
|
||||
|
||||
ui.heroDots.addEventListener("click", (event) => {
|
||||
const dot = event.target.closest(".hero-dot");
|
||||
ui.heroDots.addEventListener("click", (event: any) => {
|
||||
const dotTarget = event.target || 0;
|
||||
const dot = dotTarget.closest(".hero-dot");
|
||||
if (!dot) {
|
||||
return;
|
||||
}
|
||||
@@ -538,7 +545,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.nowRunningRow.innerHTML = movieProgram.map((movie, index) => /*html*/`
|
||||
// TODO: implement movie interface
|
||||
ui.nowRunningRow.innerHTML = movieProgram.map((movie: any, index: number) => /*html*/`
|
||||
<article class="running-poster">
|
||||
<img src="${escapeHtml(movie.poster)}" alt="${escapeHtml(movie.title)}">
|
||||
<div class="running-meta">
|
||||
@@ -550,7 +558,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
`).join("");
|
||||
};
|
||||
|
||||
const renderScheduleRows = (programIndex, dayIndex) => {
|
||||
const renderScheduleRows = (programIndex: number, dayIndex: number) => {
|
||||
const movie = movieProgram[programIndex];
|
||||
if (!movie) {
|
||||
return;
|
||||
@@ -562,7 +570,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
body.innerHTML = day.showings.map((showing) => /*html*/`
|
||||
body.innerHTML = day.showings.map((showing: { hall: string; time: string; }) => /*html*/`
|
||||
<button class="schedule-row time-chip program-time-row" data-movie="${escapeHtml(movie.title)}" data-hall="${escapeHtml(showing.hall)}" data-time="${escapeHtml(showing.time)}">
|
||||
<span>${escapeHtml(day.long)}</span>
|
||||
<span class="hall-pill">${escapeHtml(showing.hall)}</span>
|
||||
@@ -576,7 +584,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.movieProgramList.innerHTML = movieProgram.map((movie, programIndex) => {
|
||||
ui.movieProgramList.innerHTML = movieProgram.map((movie: { schedule: any[]; poster: string; title: string; fsk: string; duration: any; genre: string; description: string; }, programIndex: any) => {
|
||||
const dayTabs = movie.schedule.map((day, dayIndex) => /*html*/`
|
||||
<button type="button" class="program-day-tab ${dayIndex === 0 ? "active" : ""}" data-program-index="${programIndex}" data-day-index="${dayIndex}">
|
||||
<span>${escapeHtml(day.short)}</span>
|
||||
@@ -610,7 +618,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
`;
|
||||
}).join("");
|
||||
|
||||
movieProgram.forEach((_, programIndex) => {
|
||||
movieProgram.forEach((_: any, programIndex: number) => {
|
||||
renderScheduleRows(programIndex, 0);
|
||||
});
|
||||
};
|
||||
@@ -658,12 +666,16 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
ui.linkSnacks?.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
if (views.snacks) {
|
||||
showStaticView(views.snacks);
|
||||
}
|
||||
});
|
||||
|
||||
ui.linkAbout?.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
if (views.about) {
|
||||
showStaticView(views.about);
|
||||
}
|
||||
});
|
||||
|
||||
ui.linkCart?.addEventListener("click", (event) => {
|
||||
@@ -693,17 +705,17 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
};
|
||||
|
||||
const bindProgramActions = () => {
|
||||
views.moviesGrid?.addEventListener("click", (event) => {
|
||||
views.moviesGrid?.addEventListener("click", (event:any) => {
|
||||
const trigger = event.target.closest(".open-program-btn");
|
||||
if (!trigger) {
|
||||
return;
|
||||
}
|
||||
|
||||
const programIndex = Number(trigger.dataset.programIndex || 0);
|
||||
const programIndex = Number(trigger.dataset.programIndex) || 0;
|
||||
showMovieList(programIndex);
|
||||
});
|
||||
|
||||
ui.movieProgramList?.addEventListener("click", (event) => {
|
||||
ui.movieProgramList?.addEventListener("click", (event:any) => {
|
||||
const dayButton = event.target.closest(".program-day-tab");
|
||||
if (!dayButton) {
|
||||
return;
|
||||
@@ -713,7 +725,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const dayIndex = Number(dayButton.dataset.dayIndex || 0);
|
||||
|
||||
const tabRow = dayButton.closest(".program-day-tabs");
|
||||
tabRow?.querySelectorAll(".program-day-tab").forEach((tab) => tab.classList.remove("active"));
|
||||
tabRow?.querySelectorAll(".program-day-tab").forEach((tab: { classList: { remove: (arg0: string) => any; }; }) => tab.classList.remove("active"));
|
||||
dayButton.classList.add("active");
|
||||
|
||||
renderScheduleRows(programIndex, dayIndex);
|
||||
@@ -739,7 +751,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
openButtons.forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const targetId = button.getAttribute("data-home-view-open");
|
||||
const targetId = button.getAttribute("data-home-view-open") as keyof typeof targetMap;
|
||||
const target = targetId ? targetMap[targetId] : null;
|
||||
if (target) {
|
||||
showStaticView(target);
|
||||
@@ -792,11 +804,12 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
const THEME_KEY = "eagleTheme";
|
||||
|
||||
const applyTheme = (theme) => {
|
||||
const applyTheme = (theme: any) => {
|
||||
const isLight = theme === "light";
|
||||
document.body.classList.toggle("theme-light", isLight);
|
||||
document.body.classList.toggle("theme-dark", !isLight);
|
||||
ui.themeToggle.classList.toggle("is-light", isLight);
|
||||
//@ts-ignore
|
||||
ui.themeToggle.classList.toggle("is-light", isLight);
|
||||
localStorage.setItem(THEME_KEY, isLight ? "light" : "dark");
|
||||
};
|
||||
|
||||
@@ -812,14 +825,14 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const bindAccountActions = () => {
|
||||
const registerModal = document.getElementById("register-modal");
|
||||
const forgotModal = document.getElementById("forgot-modal");
|
||||
const forgotEmailInput = document.getElementById("forgot-email");
|
||||
const forgotEmailInput = document.getElementById("forgot-email") as HTMLInputElement;
|
||||
const resetMessage = document.getElementById("reset-message");
|
||||
const loginError = document.getElementById("login-error");
|
||||
const loginEmailInput = document.getElementById("login-email");
|
||||
const loginPasswordInput = document.getElementById("login-password");
|
||||
|
||||
const openModal = (modal) => modal?.classList.remove("hidden");
|
||||
const closeModal = (modal) => modal?.classList.add("hidden");
|
||||
const openModal = (modal: HTMLElement | null) => modal?.classList.remove("hidden");
|
||||
const closeModal = (modal: HTMLElement | null) => modal?.classList.add("hidden");
|
||||
const triggerLogin = () => {
|
||||
loginError?.classList.add("hidden");
|
||||
if (typeof loginUser === "function") {
|
||||
@@ -855,7 +868,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
|
||||
document.getElementById("btn-forgot-password")?.addEventListener("click", () => {
|
||||
if (forgotEmailInput) {
|
||||
if (forgotEmailInput != null) {
|
||||
forgotEmailInput.value = "";
|
||||
}
|
||||
resetMessage?.classList.add("hidden");
|
||||
@@ -900,10 +913,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
};
|
||||
|
||||
const bindGlobalDocumentClicks = () => {
|
||||
document.addEventListener("click", (event) => {
|
||||
document.addEventListener("click", (event: any) => {
|
||||
if (event.target.classList.contains("opt-btn")) {
|
||||
const optionGroup = event.target.parentElement;
|
||||
optionGroup?.querySelectorAll(".opt-btn").forEach((button) => button.classList.remove("active"));
|
||||
optionGroup?.querySelectorAll(".opt-btn").forEach((button: { classList: { remove: (arg0: string) => any; }; }) => button.classList.remove("active"));
|
||||
event.target.classList.add("active");
|
||||
}
|
||||
|
||||
@@ -912,15 +925,17 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const row = deleteBtn.closest(".cart-item-row");
|
||||
if (row) {
|
||||
row.classList.add("slide-out-left");
|
||||
row.querySelectorAll("button").forEach((button) => {
|
||||
row.querySelectorAll("button").forEach((button: { disabled: boolean; }) => {
|
||||
button.disabled = true;
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
removeFromCartByKey(deleteBtn.dataset.key);
|
||||
//@ts-ignore
|
||||
removeFromCartByKey(deleteBtn.dataset.key); //TODO: removeFromCartByKey doesnt exist
|
||||
}, 380);
|
||||
} else {
|
||||
removeFromCartByKey(deleteBtn.dataset.key);
|
||||
//@ts-ignore
|
||||
removeFromCartByKey(deleteBtn.dataset.key); //TODO: removeFromCartByKey doesnt exist
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -949,7 +964,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const relatedItem = cart.find((item) => {
|
||||
const relatedItem = cart.find((item: { category: string; seatId: any; hall: any; time: any; title: any; }) => {
|
||||
const infoText = item.category === "movie"
|
||||
? `Sitz: ${item.seatId} (${item.hall})`
|
||||
: item.time;
|
||||
@@ -963,7 +978,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
if (action === "plus") {
|
||||
cart.push({ ...relatedItem, id: Date.now() + Math.random() });
|
||||
} else {
|
||||
const keyList = cart.map((item) => {
|
||||
const keyList = cart.map((item: { category: string; seatId: any; hall: any; time: any; title: any; }) => {
|
||||
const infoText = item.category === "movie"
|
||||
? `Sitz: ${item.seatId} (${item.hall})`
|
||||
: item.time;
|
||||
@@ -982,7 +997,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
};
|
||||
|
||||
const bindSnacksActions = () => {
|
||||
ui.snacksView?.addEventListener("click", (event) => {
|
||||
ui.snacksView?.addEventListener("click", (event:any) => {
|
||||
const sizeChip = event.target.closest(".size-chip");
|
||||
if (!sizeChip) {
|
||||
return;
|
||||
@@ -1026,7 +1041,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}, 800);
|
||||
});
|
||||
|
||||
document.querySelectorAll(".tab-btn").forEach((button) => {
|
||||
document.querySelectorAll(".tab-btn").forEach((button: any) => {
|
||||
button.addEventListener("click", () => {
|
||||
document.querySelectorAll(".tab-btn").forEach((tab) => tab.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
@@ -1063,9 +1078,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.removeFromCartByKey = function removeFromCartByKey(key) {
|
||||
cart = cart.filter((item) => {
|
||||
// @ts-ignore
|
||||
window.removeFromCartByKey = function removeFromCartByKey(key: string) {
|
||||
cart = cart.filter((item: { category: string; seatId: any; hall: any; time: any; title: any; }) => {
|
||||
const infoText = item.category === "movie"
|
||||
? `Sitz: ${item.seatId} (${item.hall})`
|
||||
: item.time;
|
||||
@@ -1090,3 +1105,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
updateCartBadge?.();
|
||||
renderCheckout?.();
|
||||
});
|
||||
|
||||
export function emptyCart() {
|
||||
cart = []
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user