before config state
This commit is contained in:
@@ -7,18 +7,63 @@ import * as Parser from './modules/parser';
|
|||||||
import * as UI from "./modules/ui";
|
import * as UI from "./modules/ui";
|
||||||
import { config } from "./modules/config";
|
import { config } from "./modules/config";
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
//require("jbox/dist/jBox.all.css");
|
||||||
|
|
||||||
let inputsWithValue: I.InputsWithValue;
|
let inputsWithValue: I.InputsWithValue;
|
||||||
|
|
||||||
function messagesHandler(e: any) {
|
window.addEventListener('load', () => {
|
||||||
|
// Parse (hidden) inputs and their values
|
||||||
|
const content: string = new XMLSerializer().serializeToString(document);
|
||||||
|
inputsWithValue = { ...inputsWithValue, ...Parser.getInputs(content) };
|
||||||
|
|
||||||
|
console.log(inputsWithValue);
|
||||||
|
console.log(`trxstate: ${inputsWithValue["trxstate"]}`);
|
||||||
|
|
||||||
|
// "posturl" in function showMap() only available if "pvmapse" PVO code is true.
|
||||||
|
// "pvmapse" false disables seatmap
|
||||||
|
const posturlAvail: boolean = /posturl:"(.+?)"/.test(content);
|
||||||
|
|
||||||
|
console.log(`posturl available: ${posturlAvail}`);
|
||||||
|
|
||||||
|
// Only inject on page with trxstate 20 and if seatmap is enabled with PVO code "pvmapse"
|
||||||
|
if (inputsWithValue["trxstate"] !== "20" || posturlAvail === false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Inject parent CSS
|
||||||
|
// Parent = trxstate 20
|
||||||
|
Utils.inject(config.urlCSSParentStaging, "css", "body");
|
||||||
|
|
||||||
|
// Start message handler to be able to receive messages from child
|
||||||
|
Communication.listenToMessages(messageHandler);
|
||||||
|
|
||||||
|
// We are on trxstate 20 page so get more needed inputs
|
||||||
|
inputsWithValue = { ...inputsWithValue, ...Parser.getAdditionalInputs(content) };
|
||||||
|
inputsWithValue = { ...inputsWithValue, ...Parser.getVenueImage() };
|
||||||
|
inputsWithValue = { ...inputsWithValue, ...Parser.getImportantNote() };
|
||||||
|
inputsWithValue["smap"] = Parser.getSMAP();
|
||||||
|
|
||||||
|
// Inject and point seatmap button to new location
|
||||||
|
UI.injectBookingBtn();
|
||||||
|
|
||||||
|
// Create an jQuery dialog into an iframe which is opened on clicking seatmap button
|
||||||
|
// https://api.jqueryui.com/dialog/
|
||||||
|
UI.createDialog();
|
||||||
|
|
||||||
|
console.log(inputsWithValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
function messageHandler(e: any) {
|
||||||
if (typeof (e.data) !== 'string')
|
if (typeof (e.data) !== 'string')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Decode JSON postMessage data
|
||||||
const data: I.Message = JSON.parse(e.data);
|
const data: I.Message = JSON.parse(e.data);
|
||||||
|
|
||||||
console.log(`parent: received from ${data.from}`);
|
console.log(`parent: received from ${data.from}`);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
switch (data.event) {
|
switch (data.event) {
|
||||||
|
|
||||||
case "child_init_needInputsWithValue": {
|
case "child_init_needInputsWithValue": {
|
||||||
const message: I.Message = {
|
const message: I.Message = {
|
||||||
message: inputsWithValue,
|
message: inputsWithValue,
|
||||||
@@ -29,70 +74,79 @@ function messagesHandler(e: any) {
|
|||||||
Communication.sendMessage(message, "iframeSeatmap");
|
Communication.sendMessage(message, "iframeSeatmap");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_init_needVenueXML": {
|
case "child_init_needVenueXML": {
|
||||||
Communication.sendXML(inputsWithValue["posturl"], "iframeSeatmap", "parent_init_sendVenueXML", "parent");
|
Communication.sendXML(inputsWithValue["posturl"], "iframeSeatmap", "parent_init_sendVenueXML", "parent");
|
||||||
config.childHasVenueXML = true;
|
config.childHasVenueXML = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_needSeatmapXML": {
|
case "child_needSeatmapXML": {
|
||||||
const seatmapUrl: string = `${inputsWithValue["posturlRawDecoded"]}&inclseatmap=Y&seatmap=${data.message}`;
|
const seatmapUrl: string = `${inputsWithValue["posturlRawDecoded"]}&inclseatmap=Y&seatmap=${data.message}`;
|
||||||
Communication.sendXML(seatmapUrl, "iframeSeatmap", "parent_sendSeatmapXML", "parent");
|
Communication.sendXML(seatmapUrl, "iframeSeatmap", "parent_sendSeatmapXML", "parent");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_seatmap_ready": {
|
case "child_seatmap_ready": {
|
||||||
jQuery("#containerBookingBtn").show();
|
jQuery("#containerBookingBtn").show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_needCheckoutResponse": {
|
case "child_needCheckoutResponse": {
|
||||||
const inUrl: string = data.message.url;
|
const inUrl: string = data.message.url;
|
||||||
|
|
||||||
axios.get(inUrl, {
|
axios.get(inUrl, {
|
||||||
maxRedirects: 0
|
maxRedirects: 0
|
||||||
}).then(function (response) {
|
|
||||||
let isValidSeatSelection: boolean = false;
|
|
||||||
const content: string = response.data;
|
|
||||||
const parsedHTML: Node[] = jQuery.parseHTML(content);
|
|
||||||
const orderkey: string | undefined = jQuery(parsedHTML).find("#orderkey").val();
|
|
||||||
console.log(`orderkey: ${orderkey}`);
|
|
||||||
|
|
||||||
if (orderkey) {
|
|
||||||
isValidSeatSelection = true;
|
|
||||||
const cancelUrl = generateCheckoutCancelUrl(orderkey);
|
|
||||||
cancelCheckout(cancelUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
const message: I.Message = {
|
|
||||||
message: {
|
|
||||||
"isValidSeatSelection": isValidSeatSelection,
|
|
||||||
"parsedHTML": parsedHTML,
|
|
||||||
"url": inUrl,
|
|
||||||
// "selectedSeat": inSelectedSeat
|
|
||||||
},
|
|
||||||
from: "parent",
|
|
||||||
event: "parent_sendCheckoutResponse",
|
|
||||||
date: Date.now()
|
|
||||||
};
|
|
||||||
Communication.sendMessage(message, "iframeSeatmap");
|
|
||||||
})
|
})
|
||||||
|
.then((inE) => {
|
||||||
|
let isValidSeatSelection: boolean = false;
|
||||||
|
const content: string = inE.data;
|
||||||
|
const parsedHTML: Node[] = jQuery.parseHTML(content);
|
||||||
|
const orderkey: string | undefined = jQuery(parsedHTML).find("#orderkey").val();
|
||||||
|
|
||||||
|
console.log(`orderkey: ${orderkey}`);
|
||||||
|
|
||||||
|
if (orderkey) {
|
||||||
|
isValidSeatSelection = true;
|
||||||
|
const cancelUrl = `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue["user_context"]}&pid=${inputsWithValue["pid"]}&orderkey=${orderkey}&trxstate=92`;
|
||||||
|
Communication.cancelCheckout(cancelUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
const message: I.Message = {
|
||||||
|
message: {
|
||||||
|
"isValidSeatSelection": isValidSeatSelection,
|
||||||
|
"parsedHTML": parsedHTML,
|
||||||
|
"url": inUrl,
|
||||||
|
},
|
||||||
|
from: "parent",
|
||||||
|
event: "parent_sendCheckoutResponse",
|
||||||
|
date: Date.now()
|
||||||
|
};
|
||||||
|
Communication.sendMessage(message, "iframeSeatmap");
|
||||||
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log("error");
|
console.log("error in child_needCheckoutResponse");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_hide_dialog_titlebar": {
|
case "child_hide_dialog_titlebar": {
|
||||||
jQuery(".ui-dialog-titlebar").hide();
|
jQuery(".ui-dialog-titlebar").hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_show_dialog_titlebar": {
|
case "child_show_dialog_titlebar": {
|
||||||
jQuery(".ui-dialog-titlebar").show();
|
jQuery(".ui-dialog-titlebar").show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_click_checkout": {
|
case "child_click_checkout": {
|
||||||
const inUrl: string = data.message.url;
|
const inUrl: string = data.message.url;
|
||||||
window.location.href = inUrl;
|
window.location.href = inUrl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "child_closeDialog": {
|
case "child_closeDialog": {
|
||||||
jQuery(".ui-dialog-titlebar-close").click();
|
jQuery(".ui-dialog-titlebar-close").click();
|
||||||
break;
|
break;
|
||||||
@@ -102,65 +156,3 @@ function messagesHandler(e: any) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelCheckout(inUrl: string) {
|
|
||||||
// use fetch instead of axios because of 302 redirect
|
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateCheckoutCancelUrl(inOrderkey: string) {
|
|
||||||
return `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue["user_context"]}&pid=${inputsWithValue["pid"]}&orderkey=${inOrderkey}&trxstate=92`;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('load', function () {
|
|
||||||
const content: string = new XMLSerializer().serializeToString(document);
|
|
||||||
inputsWithValue = { ...inputsWithValue, ...Parser.getInputs(content) };
|
|
||||||
console.log(inputsWithValue);
|
|
||||||
|
|
||||||
console.log(inputsWithValue["trxstate"]);
|
|
||||||
console.log(/posturl:"(.+?)"/.test(content));
|
|
||||||
|
|
||||||
// posturl absent if pvmapse === false
|
|
||||||
if (inputsWithValue["trxstate"] !== "20" || /posturl:"(.+?)"/.test(content) === false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Utils.inject(config.urlCSSParentStaging, "css", "body");
|
|
||||||
Communication.listenToMessages(messagesHandler);
|
|
||||||
inputsWithValue = { ...inputsWithValue, ...Parser.getAdditionalInputs(content) };
|
|
||||||
inputsWithValue = { ...inputsWithValue, ...Parser.getVenueImage() };
|
|
||||||
|
|
||||||
// const importantNote = Parser.getImportantNote();
|
|
||||||
// if (importantNote)
|
|
||||||
// inputsWithValue = { ...inputsWithValue, ...importantNote };
|
|
||||||
|
|
||||||
inputsWithValue = { ...inputsWithValue, ...Parser.getImportantNote() };
|
|
||||||
inputsWithValue["smap"] = getSMAP();
|
|
||||||
|
|
||||||
|
|
||||||
UI.injectBookingBtn();
|
|
||||||
UI.createDialog();
|
|
||||||
|
|
||||||
console.log(inputsWithValue);
|
|
||||||
});
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -6,21 +6,21 @@ export function sendMessage(data: I.Message, to: string): void {
|
|||||||
if (to === "parent")
|
if (to === "parent")
|
||||||
window.parent.postMessage(JSON.stringify(data), '*');
|
window.parent.postMessage(JSON.stringify(data), '*');
|
||||||
else {
|
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`);
|
console.log(`Element with ID ${to} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const receiver: any = document.getElementById(to);
|
if (child.contentWindow !== null)
|
||||||
if (receiver.contentWindow !== null)
|
child.contentWindow.postMessage(JSON.stringify(data), "*")
|
||||||
receiver.contentWindow.postMessage(JSON.stringify(data), "*")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listenToMessages(inHandler?: CallableFunction): void {
|
export function listenToMessages(inHandler: CallableFunction): void {
|
||||||
window.addEventListener('message', (e: any): 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");
|
sendMessage(message, "parent");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showBookingBtnParent(): void {
|
// export function showSeatmapBtnParent(): void {
|
||||||
console.log("child completely ready");
|
// console.log("child completely ready");
|
||||||
const message: I.Message = {
|
// const message: I.Message = {
|
||||||
message: null,
|
// message: null,
|
||||||
from: "child",
|
// from: "child",
|
||||||
event: "child_seatmap_ready",
|
// event: "child_seatmap_ready",
|
||||||
date: Date.now()
|
// date: Date.now()
|
||||||
};
|
// };
|
||||||
sendMessage(message, "parent");
|
// 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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -15,5 +15,13 @@ export const config: I.Config = {
|
|||||||
urlCSSJSCMaster: "https://tickets.zinomedia.de/libs/jQuery-Seat-Charts/jquery.seat-charts.css",
|
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",
|
urlCSSjQueryUI: "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
|
||||||
childHasVenueXML: false,
|
childHasVenueXML: false,
|
||||||
maxSelectedSeats: 10
|
maxSelectedSeats: 10,
|
||||||
|
state: {
|
||||||
|
priceOverall: "",
|
||||||
|
cartChanged: false,
|
||||||
|
selectedSeatsArr: [],
|
||||||
|
selectedSeatsObj: {},
|
||||||
|
layoutRows: {},
|
||||||
|
isValidSeatSelection: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
19
client/src/modules/events.ts
Normal file
19
client/src/modules/events.ts
Normal 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,3 +74,17 @@ export function getVenueImage(): { venueImageSrc: string, venueImageHeight: numb
|
|||||||
|
|
||||||
return undefined;
|
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;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import Panzoom from '@panzoom/panzoom';
|
|||||||
import { PanzoomObject } from "@panzoom/panzoom/dist/src/types";
|
import { PanzoomObject } from "@panzoom/panzoom/dist/src/types";
|
||||||
import { config } from "./config";
|
import { config } from "./config";
|
||||||
|
|
||||||
|
|
||||||
export function setOptionSelect(inSeatmapListing: I.Seatmap[], inId: string) {
|
export function setOptionSelect(inSeatmapListing: I.Seatmap[], inId: string) {
|
||||||
const seatmapDropdown: HTMLElement | null = document.getElementById(inId);
|
const seatmapDropdown: HTMLElement | null = document.getElementById(inId);
|
||||||
if (seatmapDropdown) {
|
if (seatmapDropdown) {
|
||||||
@@ -152,3 +153,22 @@ export function changeVenueImage(inInputsWithValue: I.InputsWithValue) {
|
|||||||
if (inInputsWithValue.venueImageSrc !== undefined)
|
if (inInputsWithValue.venueImageSrc !== undefined)
|
||||||
jQuery("#venueImage img").attr("src", inInputsWithValue.venueImageSrc);
|
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");
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import axios, { AxiosResponse } from 'axios';
|
|||||||
var xml2jsParser = require('xml2js').parseString;
|
var xml2jsParser = require('xml2js').parseString;
|
||||||
import * as I from "../types/types";
|
import * as I from "../types/types";
|
||||||
import Utils from './utils';
|
import Utils from './utils';
|
||||||
|
//import { state } from "../seatmap";
|
||||||
|
|
||||||
export function getXMLPromise(url: string): Promise<unknown> {
|
export function getXMLPromise(url: string): Promise<unknown> {
|
||||||
return axios.get(url)
|
return axios.get(url)
|
||||||
@@ -58,3 +59,4 @@ export function getEventInfo(inVenueXML: I.VenueXML): I.EventInfo {
|
|||||||
|
|
||||||
return eventInfo;
|
return eventInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import * as I from "./types/types";
|
|||||||
import * as UI from "./modules/ui";
|
import * as UI from "./modules/ui";
|
||||||
import * as JSC from "./modules/jsc";
|
import * as JSC from "./modules/jsc";
|
||||||
import { config } from "./modules/config";
|
import { config } from "./modules/config";
|
||||||
import Utils from './modules/utils';
|
import Utils from "./modules/utils";
|
||||||
import { PanzoomObject } from "@panzoom/panzoom";
|
import { PanzoomObject } from "@panzoom/panzoom";
|
||||||
import jBox from 'jbox';
|
import jBox from "jbox";
|
||||||
require('jbox/dist/jBox.all.css');
|
import * as Events from "./modules/events";
|
||||||
|
require("jbox/dist/jBox.all.css");
|
||||||
|
|
||||||
let inputsWithValue: I.InputsWithValue;
|
let inputsWithValue: I.InputsWithValue;
|
||||||
let seatmap: any;
|
let seatmap: any;
|
||||||
@@ -24,8 +25,111 @@ export let state: I.State = {
|
|||||||
isValidSeatSelection: false
|
isValidSeatSelection: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
// Inject JSC (jQuery Seat Charts) and inject CSS for JSC, child and jQuery dialog
|
||||||
|
Utils.inject(config.urlJSCStaging, "js", "head");
|
||||||
|
Utils.inject(config.urlCSSJSCStaging, "css", "body");
|
||||||
|
Utils.inject(config.urlCSSChildStaging, "css", "body");
|
||||||
|
Utils.inject(config.urlCSSjQueryUI, "css", "body");
|
||||||
|
|
||||||
function messagesHandler(inE: any) {
|
// Start message handler to be able to receive messages from parent
|
||||||
|
Communication.listenToMessages(messageHandler);
|
||||||
|
|
||||||
|
// Div with ID "containerSeatmap" is not yet ready, wait for it, then display seatmap button on trxstate 20
|
||||||
|
Utils.waitForSeatmap(showSeatmapBtnParent);
|
||||||
|
|
||||||
|
// Modal overlay for cart is not yet ready, wait for it, then initialize
|
||||||
|
Utils.waitForElement("#modalCart-overlay", initModalCart);
|
||||||
|
|
||||||
|
Events.addCloseModal();
|
||||||
|
//Events.addCart(inputsWithValue);
|
||||||
|
Events.addDropdownSeatmap(panzoom);
|
||||||
|
|
||||||
|
const btnCart: HTMLElement | undefined = jQuery("#modalCart .uabb-button").get(0);
|
||||||
|
if (btnCart) {
|
||||||
|
btnCart.addEventListener("click", () => {
|
||||||
|
if (!state.selectedSeatsArr.length)
|
||||||
|
showJBoxNotice(`Sie haben bislang keinen Platz ausgewählt.`);
|
||||||
|
else if (state.cartChanged)
|
||||||
|
isValidSeatSelection(inputsWithValue);
|
||||||
|
else if (!state.cartChanged && state.isValidSeatSelection)
|
||||||
|
UI.showModalCart();
|
||||||
|
else if (!state.cartChanged && !state.isValidSeatSelection)
|
||||||
|
showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function showJBoxNotice(inContent: string, inAutoClose: number | boolean | undefined = 5000) {
|
||||||
|
new jBox('Notice', {
|
||||||
|
position: { x: 'center', y: 'top' },
|
||||||
|
offset: { x: 0, y: 320 },
|
||||||
|
content: inContent,
|
||||||
|
autoClose: inAutoClose,
|
||||||
|
animation: { open: "zoomIn", close: "zoomOut" },
|
||||||
|
closeOnEsc: false,
|
||||||
|
closeButton: true,
|
||||||
|
closeOnMouseleave: false,
|
||||||
|
closeOnClick: false,
|
||||||
|
draggable: false,
|
||||||
|
color: "red",
|
||||||
|
stack: true,
|
||||||
|
showCountdown: true,
|
||||||
|
reposition: true,
|
||||||
|
responsiveWidth: true,
|
||||||
|
responsiveHeight: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidSeatSelection(inInputsWithValue: I.InputsWithValue) {
|
||||||
|
jQuery("#modalCart-overlay").hide();
|
||||||
|
|
||||||
|
if (!state.selectedSeatsArr.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
UI.showHideBtnCartLoading("show");
|
||||||
|
|
||||||
|
jQuery("#modalCart i").hide();
|
||||||
|
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
|
||||||
|
|
||||||
|
const url = generateCheckoutUrl(inInputsWithValue);
|
||||||
|
|
||||||
|
// const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
||||||
|
// const url: string = `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue.user_context}&pid=${inputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
||||||
|
|
||||||
|
const message: I.Message = {
|
||||||
|
message: {
|
||||||
|
url: url,
|
||||||
|
},
|
||||||
|
from: "child",
|
||||||
|
event: "child_needCheckoutResponse",
|
||||||
|
date: Date.now()
|
||||||
|
};
|
||||||
|
Communication.sendMessage(message, "parent");
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateCheckoutUrl(inInputsWithValue: I.InputsWithValue): string | undefined {
|
||||||
|
if (!state.selectedSeatsArr.length)
|
||||||
|
return;
|
||||||
|
else {
|
||||||
|
const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
||||||
|
return `${inInputsWithValue["ticketPurchaseUrl"]}?user_context=${inInputsWithValue.user_context}&pid=${inInputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateSelectedSeatIndexes(): string {
|
||||||
|
return (state.selectedSeatsArr.map(function (arr) {
|
||||||
|
return arr.join(",");
|
||||||
|
})).join("|");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSeatmapBtnParent(): void {
|
||||||
|
console.log("child completely ready");
|
||||||
|
Communication.sendEventToParent("child_seatmap_ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
function messageHandler(inE: any) {
|
||||||
if (typeof (inE.data) !== 'string')
|
if (typeof (inE.data) !== 'string')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -94,6 +198,7 @@ function messagesHandler(inE: any) {
|
|||||||
|
|
||||||
|
|
||||||
new jBox("Tooltip", {
|
new jBox("Tooltip", {
|
||||||
|
attach: jQuery(".seatCharts-seat"),
|
||||||
onOpen: function (this: any) {
|
onOpen: function (this: any) {
|
||||||
showSeatTooltip(this);
|
showSeatTooltip(this);
|
||||||
},
|
},
|
||||||
@@ -108,15 +213,15 @@ function messagesHandler(inE: any) {
|
|||||||
|
|
||||||
if (!state.isValidSeatSelection) {
|
if (!state.isValidSeatSelection) {
|
||||||
showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
|
showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
|
||||||
showHideBtnCartLoading("hide");
|
UI.showHideBtnCartLoading("hide");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
removeCartItems();
|
removeCartItems();
|
||||||
generateCartItems();
|
generateCartItems();
|
||||||
const url = generateCheckoutUrl();
|
const url = generateCheckoutUrl(inputsWithValue);
|
||||||
setCheckoutBtn(url);
|
setCheckoutBtn(url);
|
||||||
showModalCart();
|
UI.showModalCart();
|
||||||
showHideBtnCartLoading("hide");
|
UI.showHideBtnCartLoading("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
state.cartChanged = false;
|
state.cartChanged = false;
|
||||||
@@ -183,7 +288,7 @@ function decodeAddTrims(textArr: string[], x: number, y: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyTrim(x: number, y: number, i: number, character: string) {
|
function applyTrim(x: number, y: number, i: number, character: string) {
|
||||||
if(!/[^a-zA-Z0-9äöüÄÖÜß$]/.test(character)) {
|
if (!/[^a-zA-Z0-9äöüÄÖÜß$]/.test(character)) {
|
||||||
const _x = (x - 1) + i;
|
const _x = (x - 1) + i;
|
||||||
const _y = y - 1;
|
const _y = y - 1;
|
||||||
console.log(`${character} -> ${_x} ${_y}`);
|
console.log(`${character} -> ${_x} ${_y}`);
|
||||||
@@ -233,10 +338,7 @@ function setCheckoutBtn(inUrl: string | undefined) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showModalCart() {
|
|
||||||
jQuery("#modalCart-overlay").fadeIn(300);
|
|
||||||
Communication.sendEventToParent("child_hide_dialog_titlebar");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVenuePricescalePropertyByPricescaleID(property: I.Pricescale2Properties, pricescaleID: string, inVenueXML: I.VenueXML) {
|
function getVenuePricescalePropertyByPricescaleID(property: I.Pricescale2Properties, pricescaleID: string, inVenueXML: I.VenueXML) {
|
||||||
const venuePricescaleArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
const venuePricescaleArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
||||||
@@ -294,7 +396,7 @@ function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj: I.JSCS
|
|||||||
calcOverallPrice(inVenueXML);
|
calcOverallPrice(inVenueXML);
|
||||||
setBtnCartText();
|
setBtnCartText();
|
||||||
|
|
||||||
const url = generateCheckoutUrl();
|
const url = generateCheckoutUrl(inputsWithValue);
|
||||||
console.log(url);
|
console.log(url);
|
||||||
setCheckoutBtn(url);
|
setCheckoutBtn(url);
|
||||||
|
|
||||||
@@ -370,27 +472,6 @@ function selectSeatsInCart() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showJBoxNotice(inContent: string, inAutoClose: number | boolean | undefined = 5000) {
|
|
||||||
new jBox('Notice', {
|
|
||||||
position: { x: 'center', y: 'top' },
|
|
||||||
offset: { x: 0, y: 320 },
|
|
||||||
content: inContent,
|
|
||||||
autoClose: inAutoClose,
|
|
||||||
animation: { open: "zoomIn", close: "zoomOut" },
|
|
||||||
closeOnEsc: false,
|
|
||||||
closeButton: true,
|
|
||||||
closeOnMouseleave: false,
|
|
||||||
closeOnClick: false,
|
|
||||||
draggable: false,
|
|
||||||
color: "red",
|
|
||||||
stack: true,
|
|
||||||
showCountdown: true,
|
|
||||||
reposition: true,
|
|
||||||
responsiveWidth: true,
|
|
||||||
responsiveHeight: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function generatePricescaleCSS(inVenueXML: I.VenueXML): string {
|
function generatePricescaleCSS(inVenueXML: I.VenueXML): string {
|
||||||
const venuePricescalesArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
const venuePricescalesArr: I.Pricescale2[] = inVenueXML.venue[0].pricescales[0].pricescale;
|
||||||
let cssArr: string[] = [];
|
let cssArr: string[] = [];
|
||||||
@@ -433,7 +514,7 @@ function initModalCart() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onresize = function() {
|
window.onresize = function () {
|
||||||
const innerHeight = window.innerHeight;
|
const innerHeight = window.innerHeight;
|
||||||
if (innerHeight < 576) {
|
if (innerHeight < 576) {
|
||||||
console.log("small");
|
console.log("small");
|
||||||
@@ -446,53 +527,7 @@ window.onresize = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', function () {
|
|
||||||
Utils.inject(config.urlJSCStaging, "js", "head");
|
|
||||||
Utils.inject(config.urlCSSJSCStaging, "css", "body");
|
|
||||||
Utils.inject(config.urlCSSChildStaging, "css", "body");
|
|
||||||
Utils.inject(config.urlCSSjQueryUI, "css", "body");
|
|
||||||
Communication.listenToMessages(messagesHandler);
|
|
||||||
Utils.waitForSeatmap(Communication.showBookingBtnParent);
|
|
||||||
|
|
||||||
Utils.waitForElement("#modalCart-overlay", initModalCart);
|
|
||||||
// Utils.waitForElement("#modalCart-overlay", () => jQuery("#modalCart-overlay").hide());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const btnCloseModal = jQuery("#btnCloseModal").get(0);
|
|
||||||
|
|
||||||
if (btnCloseModal) {
|
|
||||||
btnCloseModal.addEventListener("click", function () {
|
|
||||||
Communication.sendEventToParent("child_closeDialog");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const btnCart = jQuery("#modalCart .uabb-button").get(0);
|
|
||||||
if (btnCart) {
|
|
||||||
btnCart.addEventListener("click", function () {
|
|
||||||
if (!state.selectedSeatsArr.length)
|
|
||||||
showJBoxNotice(`Sie haben bislang keinen Platz ausgewählt.`);
|
|
||||||
else if (state.cartChanged)
|
|
||||||
isValidSeatSelection();
|
|
||||||
else if (!state.cartChanged && state.isValidSeatSelection)
|
|
||||||
showModalCart();
|
|
||||||
else if (!state.cartChanged && !state.isValidSeatSelection)
|
|
||||||
showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const dropdownSeatmap: HTMLElement | null = document.getElementById("dropdownSeatmap");
|
|
||||||
if (dropdownSeatmap) {
|
|
||||||
dropdownSeatmap.addEventListener("change", function (this: HTMLSelectElement) {
|
|
||||||
UI.controlLoftloader("show");
|
|
||||||
const value: string = this.value;
|
|
||||||
UI.destroyCurrentSeatmap("#containerSeatmapInner", panzoom);
|
|
||||||
Communication.needSeatmapXML(value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function dropdownLegendOnChange(inSelector: string) {
|
function dropdownLegendOnChange(inSelector: string) {
|
||||||
const dropdownLegend = jQuery(inSelector).get(0);
|
const dropdownLegend = jQuery(inSelector).get(0);
|
||||||
@@ -564,62 +599,6 @@ function getBuyerTypeCodeByBuyerTypeID(inVenueXML: I.VenueXML, inBuyerTypeID: st
|
|||||||
})?.code[0];
|
})?.code[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function isValidSeatSelection() {
|
|
||||||
jQuery("#modalCart-overlay").hide();
|
|
||||||
|
|
||||||
if (!state.selectedSeatsArr.length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
showHideBtnCartLoading("show");
|
|
||||||
|
|
||||||
jQuery("#modalCart i").hide();
|
|
||||||
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
|
|
||||||
|
|
||||||
const url = generateCheckoutUrl();
|
|
||||||
|
|
||||||
// const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
|
||||||
// const url: string = `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue.user_context}&pid=${inputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
|
||||||
|
|
||||||
const message: I.Message = {
|
|
||||||
message: {
|
|
||||||
url: url,
|
|
||||||
},
|
|
||||||
from: "child",
|
|
||||||
event: "child_needCheckoutResponse",
|
|
||||||
date: Date.now()
|
|
||||||
};
|
|
||||||
Communication.sendMessage(message, "parent");
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateCheckoutUrl(): string | undefined {
|
|
||||||
if (!state.selectedSeatsArr.length)
|
|
||||||
return;
|
|
||||||
else {
|
|
||||||
const selectedSeatIndexes: string = generateSelectedSeatIndexes();
|
|
||||||
return `${inputsWithValue["ticketPurchaseUrl"]}?user_context=${inputsWithValue.user_context}&pid=${inputsWithValue["pid"]}&selected_seat_indexes=${selectedSeatIndexes}&trxstate=148`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateSelectedSeatIndexes(): string {
|
|
||||||
return (state.selectedSeatsArr.map(function (arr) {
|
|
||||||
return arr.join(",");
|
|
||||||
})).join("|");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVenuePriceStructurePropertyByPricescaleID(inVenueXML: I.VenueXML, inID: string): I.Pricescale5 | undefined {
|
function getVenuePriceStructurePropertyByPricescaleID(inVenueXML: I.VenueXML, inID: string): I.Pricescale5 | undefined {
|
||||||
const venuePricescaleArr: I.Pricescale5[] = inVenueXML.price_structure[0].pricescale;
|
const venuePricescaleArr: I.Pricescale5[] = inVenueXML.price_structure[0].pricescale;
|
||||||
return venuePricescaleArr.find(obj => {
|
return venuePricescaleArr.find(obj => {
|
||||||
|
|||||||
1
client/src/types/types.d.ts
vendored
1
client/src/types/types.d.ts
vendored
@@ -90,6 +90,7 @@ export interface Config {
|
|||||||
childHasVenueXML: boolean;
|
childHasVenueXML: boolean;
|
||||||
urlCSSjQueryUI: string;
|
urlCSSjQueryUI: string;
|
||||||
maxSelectedSeats: number;
|
maxSelectedSeats: number;
|
||||||
|
state: I.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Message {
|
export interface Message {
|
||||||
|
|||||||
Reference in New Issue
Block a user