outsourced inject and seatmap to modules

This commit is contained in:
zino
2021-05-18 19:57:04 +02:00
parent 48c5efbd57
commit d15476161c
5 changed files with 194 additions and 151 deletions

View File

@@ -1,21 +1,13 @@
import jQuery = require("jquery");
import * as XMLHelper from "./modules/xmlhelper";
import * as Communication from "./modules/communication";
import * as I from "./types/types";
import * as UI from "./modules/ui";
import * as JSC from "./modules/jsc";
import { config } from "./modules/config";
import Utils from "./modules/utils";
import * as Events from "./modules/events";
require("jbox/dist/jBox.all.css");
import * as Cart from "./modules/cart";
import * as Trims from "./modules/trims";
import * as Legend from "./modules/legend";
import * as BookingBtn from "./modules/bookingButton";
import * as Panzoom from "./modules/panzoom";
import * as CartButtons from "./modules/cartButtons";
import * as jBoxHelper from "./modules/jBoxHelper";
import * as Parser from './modules/parser';
import * as Child from './modules/child';
window.addEventListener('load', () => {
// Inject JSC (jQuery Seat Charts)
@@ -68,90 +60,26 @@ function messageHandler(inE: any) {
console.log(data);
switch (data.event) {
case "parent_init_venue": {
UI.controlLoftloader("show");
Communication.sendEventToParent("child_init_needInputsWithValue");
Child.initVenue();
break;
}
case "parent_init_sendVenueXML": {
config.state.inVenueXML = data.message.map_response;
const venueXML = config.state.inVenueXML!;
// Generate pricescale css classes
const css = UI.generatePricescaleCSS();
Utils.inject(css, "cssCustom", "body");
// Fill event info
const eventInfo = Parser.getEventInfo();
UI.setEventInfo(eventInfo);
// Fill select dropdown
const seatmapListing: I.Seatmap[] = venueXML.seatmap_config[0].seatmap;
UI.setOptionSelect(seatmapListing, "dropdownSeatmap");
// Display first seatmapXML
const id: string = seatmapListing[0].id[0];
jQuery("#dropdownSeatmap").val(id);
Communication.needSeatmapXML(id);
console.log(css);
console.log(seatmapListing);
Child.initSendVenueXML(inE);
break;
}
case "parent_init_sendInputsWithValue": {
config.state.inputsWithValue = data.message;
UI.changeVenueImage();
Communication.sendEventToParent("child_init_needVenueXML");
Child.initSendInputsWithValue(inE);
break;
}
case "parent_sendSeatmapXML": {
config.state.seatmapXML = data.message.map_response;
const map: string[] = JSC.generateMap();
const rowsNaming: string[] = JSC.getRowsNaming();
const seats: I.JSCSeats = JSC.getSeats();
const legend: I.JSCLegend = JSC.generateLegend("#JSCLegendInner");
JSC.addSeatmap("#containerSeatmapInner", map, rowsNaming, seats, legend);
JSC.setUnavailableSeats();
JSC.selectSeatsInCart();
Legend.convertLegendToDropdown("dropdownLegend");
Events.dropdownLegendOnChange("#dropdownLegend");
Trims.addTrims();
XMLHelper.processSMAP();
config.state.panzoom = Panzoom.addPanzoom("#containerSeatmapInner", ".panzoomZoomIn", ".panzoomZoomOut", "#panzoomResetZoom");
UI.controlLoftloader("hide");
jBoxHelper.createSeatTooltips();
Child.sendSeatmapXML(inE);
break;
}
case "parent_sendCheckoutResponse": {
config.state.isValidSeatSelection = data.message.isValidSeatSelection;
console.log(data.message);
if (!config.state.isValidSeatSelection) {
jBoxHelper.showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);
CartButtons.showHideBtnCartLoading("hide");
}
else {
Cart.removeCartItems();
Cart.generateCartItems();
const url = Cart.generateCheckoutUrl();
Events.addRedirectCheckout(url);
UI.fadeInCartModal();
CartButtons.showHideBtnCartLoading("hide");
}
config.state.cartChanged = false;
case "parent_sendCheckoutResponse": {
Child.sendCheckoutResponse(inE);
break;
}
default:
break;
}