before splitting in modules
This commit is contained in:
@@ -28,45 +28,49 @@ window.addEventListener('load', function () {
|
||||
}, "parent");
|
||||
});
|
||||
|
||||
Utils.inject(config.urlSeatChartsStaging, "js", "head");
|
||||
Utils.inject(config.urlCSSSeatChartsStaging, "css", "body");
|
||||
Utils.inject(config.urlCSSSeatmapStaging, "css", "body");
|
||||
Utils.inject(config.urlJSCStaging, "js", "head");
|
||||
Utils.inject(config.urlCSSJSCStaging, "css", "body");
|
||||
Utils.inject(config.urlCSSChildStaging, "css", "body");
|
||||
communication.listenToMessages(messagesHandler);
|
||||
// Utils.waitForSeatmap(addSeatmap);
|
||||
Utils.waitForSeatmap(showBookingBtnParent);
|
||||
|
||||
const dropdownSeatmap: HTMLElement | null = document.getElementById("dropdownSeatmap");
|
||||
if (dropdownSeatmap) {
|
||||
dropdownSeatmap.addEventListener("change", function (this: HTMLSelectElement) {
|
||||
controlLoftloader("show");
|
||||
const value: string = this.value;
|
||||
const message: I.Message = {
|
||||
message: value,
|
||||
from: "child",
|
||||
event: "child_needSeatmapXML",
|
||||
date: Date.now()
|
||||
};
|
||||
communication.sendMessage(message, "parent");
|
||||
destroyCurrentSeatmap();
|
||||
communication.needSeatmapXML(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// const containerSeatmap: HTMLElement | null = document.getElementById("containerSeatmap");
|
||||
// if (containerSeatmap) {
|
||||
|
||||
// const panzoom = Panzoom(containerSeatmap, {
|
||||
// maxScale: 5
|
||||
// });
|
||||
|
||||
// const btnZoomIn: HTMLElement | null = document.getElementById("panmzoomZoomIn");
|
||||
// if (btnZoomIn)
|
||||
// btnZoomIn.addEventListener('click', panzoom.zoomIn)
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
function destroyCurrentSeatmap(): void {
|
||||
jQuery("#containerSeatmapInner").remove();
|
||||
jQuery("#htmlSeatmapInner .fl-html").removeAttr("style");
|
||||
jQuery("#htmlSeatmapInner .fl-html").append('<div id="containerSeatmapInner"></div>');
|
||||
}
|
||||
|
||||
function controlLoftloader(inSwitch: string) {
|
||||
if (inSwitch === "show")
|
||||
jQuery("body").removeClass("loaded loftloader-loaded");
|
||||
else if (inSwitch === "hide")
|
||||
jQuery("body").addClass("loaded loftloader-loaded");
|
||||
}
|
||||
|
||||
function showBookingBtnParent(): void {
|
||||
console.log("child completely ready");
|
||||
const message: I.Message = {
|
||||
message: null,
|
||||
from: "child",
|
||||
event: "child_seatmap_ready",
|
||||
date: Date.now()
|
||||
};
|
||||
communication.sendMessage(message, "parent");
|
||||
}
|
||||
|
||||
|
||||
function addSeatmap(inSelector: string, inSeatmapInitMap: string[], inSeatmapInitRows: number[], inSeats: I.JSCSeats): void {
|
||||
|
||||
const containerSeatmap: any = (<any>window).jQuery(inSelector);
|
||||
@@ -166,6 +170,7 @@ function messagesHandler(inE: any) {
|
||||
break;
|
||||
}
|
||||
case "parent_init_venue": {
|
||||
controlLoftloader("show");
|
||||
communication.sendEventToParent("child_init_needInputsWithValue");
|
||||
break;
|
||||
}
|
||||
@@ -178,8 +183,14 @@ function messagesHandler(inE: any) {
|
||||
|
||||
// fill select dropdown
|
||||
const seatmapListing: I.Seatmap[] = xml.getSeatmapListing(XML);
|
||||
console.log(seatmapListing);
|
||||
ui.setOptionSelect(seatmapListing, "dropdownSeatmap");
|
||||
|
||||
// display first seatmapXML
|
||||
const id: string = seatmapListing[0].id[0];
|
||||
jQuery("#dropdownSeatmap").val(id);
|
||||
communication.needSeatmapXML(id);
|
||||
|
||||
break;
|
||||
}
|
||||
case "parent_init_sendInputsWithValue": {
|
||||
@@ -191,11 +202,13 @@ function messagesHandler(inE: any) {
|
||||
const XML: any = data.message.map_response;
|
||||
const seatmapInitMap: string[] = generateMap(XML);
|
||||
const seatmapInitRows: number[] = getRows(XML);
|
||||
const seatmapInitSeats: I.JSCSeats = getSeats(XML);
|
||||
const seatmapInitSeats: I.JSCSeats = getSeats(XML);
|
||||
console.log(seatmapInitSeats);
|
||||
|
||||
addSeatmap("#containerSeatmapInner", seatmapInitMap, seatmapInitRows, seatmapInitSeats);
|
||||
addPanzoom("#containerSeatmapInner", "#panzoomZoomIn", "#panzoomZoomOut", "#panzoomResetZoom");
|
||||
addPanzoom("#containerSeatmapInner", ".panzoomZoomIn", ".panzoomZoomOut", "#panzoomResetZoom");
|
||||
|
||||
controlLoftloader("hide");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -209,7 +222,7 @@ function getSeats(inXML: any): I.JSCSeats {
|
||||
const pricescaleArr: I.SeatmapPricescale[] = inXML.seatmap[0].pricescale_config[0].pricescale;
|
||||
let object: any = {};
|
||||
|
||||
for (let key in pricescaleArr) {
|
||||
for (let key in pricescaleArr) {
|
||||
const seatsObj: I.JSCSeats2 = {
|
||||
"classes": "foobar",
|
||||
"seatsObj": pricescaleArr[key]
|
||||
@@ -259,19 +272,7 @@ function getRows(inXML: any): number[] {
|
||||
const layout: I.SeatmapLayout = inXML.seatmap[0].layouts[0].layout[0];
|
||||
const height: number = parseInt(layout.height[0]);
|
||||
|
||||
return Array.from({ length: height }, (_, i: number) => i + 1)
|
||||
|
||||
// const rows: I.LayoutRow2[] = XML.seatmap[0].layouts[0].layout[0].rows[0].row;
|
||||
// console.log(rows);
|
||||
// let seatmapInitRows: number[] = [];
|
||||
|
||||
// rows.forEach(element => {
|
||||
// const row: I.LayoutRow2 = element;
|
||||
// const Y: number = parseInt(row.y_cell_coord[0]);
|
||||
// seatmapInitRows.push(Y);
|
||||
// });
|
||||
|
||||
// return seatmapInitRows;
|
||||
return Array.from({ length: height }, (_, i: number) => i + 1);
|
||||
}
|
||||
|
||||
function generateMap(inXML: any): string[] {
|
||||
@@ -332,9 +333,9 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
|
||||
}
|
||||
|
||||
function getSeatsKey(inSeatID: string, inPricescaleArr: I.SeatmapPricescale[]): string | undefined {
|
||||
for (let key in inPricescaleArr) {
|
||||
for (let key in inPricescaleArr) {
|
||||
if (inPricescaleArr[key].mask[0].includes(inSeatID))
|
||||
return String.fromCharCode(97 + parseInt(key)).toLocaleUpperCase();
|
||||
return String.fromCharCode(97 + parseInt(key)).toLocaleUpperCase();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user