before config state

This commit is contained in:
zino
2021-05-14 13:48:13 +02:00
parent 126b9be7ea
commit e7242594b4
9 changed files with 299 additions and 251 deletions

View File

@@ -6,21 +6,21 @@ export function sendMessage(data: I.Message, to: string): void {
if (to === "parent")
window.parent.postMessage(JSON.stringify(data), '*');
else {
if (document.getElementById(to) === null) {
console.log("trying to send to child");
const child: any = document.getElementById(to);
if (child === null) {
console.log(`Element with ID ${to} does not exist`);
return;
}
const receiver: any = document.getElementById(to);
if (receiver.contentWindow !== null)
receiver.contentWindow.postMessage(JSON.stringify(data), "*")
if (child.contentWindow !== null)
child.contentWindow.postMessage(JSON.stringify(data), "*")
}
}
export function listenToMessages(inHandler?: CallableFunction): void {
export function listenToMessages(inHandler: CallableFunction): void {
window.addEventListener('message', (e: any): void => {
if (inHandler)
inHandler(e);
inHandler(e);
});
}
@@ -68,13 +68,26 @@ export function needSeatmapXML(inID: string) {
sendMessage(message, "parent");
}
export function showBookingBtnParent(): void {
console.log("child completely ready");
const message: I.Message = {
message: null,
from: "child",
event: "child_seatmap_ready",
date: Date.now()
};
sendMessage(message, "parent");
// export function showSeatmapBtnParent(): void {
// console.log("child completely ready");
// const message: I.Message = {
// message: null,
// from: "child",
// event: "child_seatmap_ready",
// date: Date.now()
// };
// sendMessage(message, "parent");
// }
export function cancelCheckout(inUrl: string) {
// use fetch instead of axios because of 302 redirect
// see https://github.com/axios/axios/issues/932
fetch(inUrl, {
redirect: "manual"
}).then(() => {
console.log(`${inUrl} canceled`);
}).catch(function (error) {
console.log("error");
console.log(error);
});
}

View File

@@ -15,5 +15,13 @@ export const config: I.Config = {
urlCSSJSCMaster: "https://tickets.zinomedia.de/libs/jQuery-Seat-Charts/jquery.seat-charts.css",
urlCSSjQueryUI: "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
childHasVenueXML: false,
maxSelectedSeats: 10
maxSelectedSeats: 10,
state: {
priceOverall: "",
cartChanged: false,
selectedSeatsArr: [],
selectedSeatsObj: {},
layoutRows: {},
isValidSeatSelection: false
}
}

View File

@@ -0,0 +1,19 @@
import * as Communication from "./communication";
import * as UI from "./ui";
export function addCloseModal() {
const btnCloseModal: HTMLElement | undefined = jQuery("#btnCloseModal").get(0);
if (btnCloseModal)
btnCloseModal.addEventListener("click", () => Communication.sendEventToParent("child_closeDialog"));
}
export function addDropdownSeatmap(inPanzoom: any) {
const dropdownSeatmap: HTMLElement | null = document.getElementById("dropdownSeatmap");
if (dropdownSeatmap) {
dropdownSeatmap.addEventListener("change", function (this: HTMLSelectElement) {
UI.controlLoftloader("show");
UI.destroyCurrentSeatmap("#containerSeatmapInner", inPanzoom);
Communication.needSeatmapXML(this.value);
});
}
}

View File

@@ -73,4 +73,18 @@ export function getVenueImage(): { venueImageSrc: string, venueImageHeight: numb
}
return undefined;
}
export function getSMAP(): string | undefined {
if (jQuery("#seating_map_url").length === 0)
return undefined;
const str: string = jQuery("#seating_map_url a").attr("onclick");
const re = /openNewWindow\(\'(\d+)\'/;
const found: RegExpMatchArray | null = str.match(re);
if (found)
return found[1];
else
return undefined;
}

View File

@@ -4,6 +4,7 @@ import Panzoom from '@panzoom/panzoom';
import { PanzoomObject } from "@panzoom/panzoom/dist/src/types";
import { config } from "./config";
export function setOptionSelect(inSeatmapListing: I.Seatmap[], inId: string) {
const seatmapDropdown: HTMLElement | null = document.getElementById(inId);
if (seatmapDropdown) {
@@ -151,4 +152,23 @@ export function addPanzoom(inSelector: string, inBtnZoomIn: string | null = null
export function changeVenueImage(inInputsWithValue: I.InputsWithValue) {
if (inInputsWithValue.venueImageSrc !== undefined)
jQuery("#venueImage img").attr("src", inInputsWithValue.venueImageSrc);
}
export function showHideBtnCartLoading(inSwitch: string) {
if (inSwitch === "show") {
jQuery("#modalCart .uabb-button").css("pointer-events", "none");
jQuery("#modalCart i").hide();
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
}
else if (inSwitch === "hide") {
jQuery("#modalCart i").show();
jQuery("#modalCart .uabb-button-text").removeClass("dot-pulse");
jQuery("#modalCart .uabb-button").css("pointer-events", "all");
}
}
export function showModalCart() {
jQuery("#modalCart-overlay").fadeIn(300);
Communication.sendEventToParent("child_hide_dialog_titlebar");
}

View File

@@ -2,6 +2,7 @@ import axios, { AxiosResponse } from 'axios';
var xml2jsParser = require('xml2js').parseString;
import * as I from "../types/types";
import Utils from './utils';
//import { state } from "../seatmap";
export function getXMLPromise(url: string): Promise<unknown> {
return axios.get(url)
@@ -57,4 +58,5 @@ export function getEventInfo(inVenueXML: I.VenueXML): I.EventInfo {
let eventInfo: I.EventInfo = { ...eventObj, ...eventExtend };
return eventInfo;
}
}