diff --git a/client/package-lock.json b/client/package-lock.json index 5b92124..630fded 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "client", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/client/src/modules/child.ts b/client/src/modules/child.ts index bbe0cd9..9e43b64 100644 --- a/client/src/modules/child.ts +++ b/client/src/modules/child.ts @@ -37,7 +37,9 @@ export function initSendVenueXML(inE: any) { UI.setOptionSelect(seatmapListing, "dropdownSeatmap"); // Display first seatmapXML - const id: string = seatmapListing[0].id[0]; + // If smap[1] is given by user, display specific seatmap on load + const id: string = XMLHelper.getFirstSeatmapIDToLoad(); + jQuery("#dropdownSeatmap").val(id); Communication.needSeatmapXML(id); @@ -67,7 +69,7 @@ export function sendSeatmapXML(inE: any) { Legend.convertLegendToDropdown("dropdownLegend"); Events.dropdownLegendOnChange("#dropdownLegend"); Trims.addTrims(); - XMLHelper.processSMAP(); + XMLHelper.showHideVenueCapacity(); config.state.panzoom = Panzoom.addPanzoom("#containerSeatmapInner", ".panzoomZoomIn", ".panzoomZoomOut", "#panzoomResetZoom"); Cart.setImportantNote(); UI.controlLoftloader("hide"); diff --git a/client/src/modules/parser.ts b/client/src/modules/parser.ts index a4038e1..fdbb6da 100644 --- a/client/src/modules/parser.ts +++ b/client/src/modules/parser.ts @@ -83,7 +83,10 @@ export function getSMAP(): string | undefined { return undefined; const str: string = jQuery("#seating_map_url a").attr("onclick"); - const re = /openNewWindow\(\'(\d+)\'/; + + //const re = /openNewWindow\(\'(\d+)\'/; + const re = /openNewWindow\(\'(.+?)\'/; + const found: RegExpMatchArray | null = str.match(re); return found ? found[1] : undefined; diff --git a/client/src/modules/xmlhelper.ts b/client/src/modules/xmlhelper.ts index 2922133..aa24ee5 100644 --- a/client/src/modules/xmlhelper.ts +++ b/client/src/modules/xmlhelper.ts @@ -1,19 +1,43 @@ - import * as I from "../types/types"; import { config } from "./config"; -export function processSMAP(): void { +export function showHideVenueCapacity(): void { const inputsWithValue = config.state.inputsWithValue!; if (!inputsWithValue.smap) return; - const smapArr: number[] = inputsWithValue.smap.split("").map(Number); + // TODO: We are sure that there are always only two elements [number, string], so we can declare it as a tuple? + const smapArr = inputsWithValue.smap.split(";"); + // Form: + // 0: = "0" -> Show venue capacity 1=yes 0=no + // 1: = "SC02" -> Show specific seat plan when loading for the first time - if (!smapArr[0]) + // Convert first SMAP element to Number and hide or show venue capacity data + if (!Number(smapArr[0])) jQuery("#eventInfoCapacity").hide(); } +export function getFirstSeatmapIDToLoad() { + const inputsWithValue = config.state.inputsWithValue!; + const venueXML = config.state.inVenueXML!; + const seatmapListing: I.Seatmap[] = venueXML.seatmap_config[0].seatmap; + const firstSeatmapID: string = seatmapListing[0].id[0]; + + // If SMAP field is missing, return ID of first seatmap + if (!inputsWithValue.smap) + return firstSeatmapID; + + // If seatmap code is given in SMAP, return corresponding seatmap ID, otherwise return ID of first seatmap + const smapArr = inputsWithValue.smap.split(";"); // Form described above + if (!smapArr[1]) + return firstSeatmapID; + + const seatmapID: string | undefined = seatmapListing.find(arr => smapArr[1] === arr.code[0])?.id[0]; + + return seatmapID ? seatmapID : firstSeatmapID; +} + export function getSectionDescBySectionID(inSectionID: string): string | undefined { const venueXML: I.VenueXML = config.state.inVenueXML!; const sectionArr: I.Section[] = venueXML.master_config[0].section_config[0].section; diff --git a/libs/jQuery-Seat-Charts b/libs/jQuery-Seat-Charts new file mode 160000 index 0000000..f43f2a1 --- /dev/null +++ b/libs/jQuery-Seat-Charts @@ -0,0 +1 @@ +Subproject commit f43f2a1884c95c3f4fa08ea67d4bc2ccf70aa26b