From 126b9be7eae0baff315ba0ffb2a88ac5b9048868 Mon Sep 17 00:00:00 2001 From: zino Date: Thu, 6 May 2021 17:57:51 +0200 Subject: [PATCH] intorduced smap --- client/src/inject.ts | 29 +++++++++++++------ client/src/modules/ui.ts | 13 ++++----- client/src/modules/xmlhelper.ts | 2 +- client/src/seatmap.ts | 49 ++++++++++++++++++++++++++------- client/src/types/types.d.ts | 1 + 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/client/src/inject.ts b/client/src/inject.ts index 62ac291..7a81756 100644 --- a/client/src/inject.ts +++ b/client/src/inject.ts @@ -137,17 +137,30 @@ window.addEventListener('load', function () { inputsWithValue = { ...inputsWithValue, ...Parser.getAdditionalInputs(content) }; inputsWithValue = { ...inputsWithValue, ...Parser.getVenueImage() }; - const importantNote = Parser.getImportantNote(); - if (importantNote) - inputsWithValue = { ...inputsWithValue, ...importantNote }; + // const importantNote = Parser.getImportantNote(); + // if (importantNote) + // inputsWithValue = { ...inputsWithValue, ...importantNote }; + + inputsWithValue = { ...inputsWithValue, ...Parser.getImportantNote() }; + inputsWithValue["smap"] = getSMAP(); + UI.injectBookingBtn(); UI.createDialog(); console.log(inputsWithValue); +}); - // remove on production - jQuery("#foobarParent").on("click", () => { - Communication.sendEventToChild("parent_init_venue"); - }); -}); \ No newline at end of file +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; +} \ No newline at end of file diff --git a/client/src/modules/ui.ts b/client/src/modules/ui.ts index 03ba313..72b86a3 100644 --- a/client/src/modules/ui.ts +++ b/client/src/modules/ui.ts @@ -57,15 +57,12 @@ export function injectBookingBtn(): void { "width": "100%" }); jQuery("#flash_seat_map_box_id").append(` +
+
-
-
+ + Saalplanbuchung +
`); diff --git a/client/src/modules/xmlhelper.ts b/client/src/modules/xmlhelper.ts index 4c9ecad..e767914 100644 --- a/client/src/modules/xmlhelper.ts +++ b/client/src/modules/xmlhelper.ts @@ -35,7 +35,7 @@ export function getEventInfo(inVenueXML: I.VenueXML): I.EventInfo { const eventObj: I.Event = inVenueXML.event[0]; const event = inVenueXML.event[0]; const venue_config = inVenueXML.venue_config[0]; - const dateObj: Date = new Date(parseInt(event.year[0]), parseInt(event.month[0])-1, parseInt(event.hour[0]), parseInt(event.minute[0])); + const dateObj: Date = new Date(parseInt(event.year[0]), parseInt(event.month[0])-1, parseInt(event.day[0]), parseInt(event.hour[0]), parseInt(event.minute[0])); const start: string[] = [ dateObj.toLocaleString(["de-DE"], { weekday: "long", day: "2-digit", month: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit", timeZoneName: "short" }) ]; const weekday = [ Utils.getDayName(dateObj, "de-DE") ]; const seats_available = sectionArr.map(item => parseInt(item.available[0])).reduce((prev, curr) => prev + curr); diff --git a/client/src/seatmap.ts b/client/src/seatmap.ts index 0b8fcd1..d04d6a2 100644 --- a/client/src/seatmap.ts +++ b/client/src/seatmap.ts @@ -87,14 +87,13 @@ function messagesHandler(inE: any) { addTrims(); + processSMAP(); + panzoom = UI.addPanzoom("#containerSeatmapInner", ".panzoomZoomIn", ".panzoomZoomOut", "#panzoomResetZoom"); UI.controlLoftloader("hide"); new jBox("Tooltip", { - attach: jQuery(".seatCharts-seat"), - // title: "title", - // content: "foooobar", onOpen: function (this: any) { showSeatTooltip(this); }, @@ -130,6 +129,16 @@ function messagesHandler(inE: any) { } } +function processSMAP() { + if (!inputsWithValue.smap) + return; + + const smapArr = inputsWithValue.smap.split("").map(Number); + + if (!smapArr[0]) + jQuery("#eventInfoCapacity").hide(); +} + function addTrims() { const trimArr: I.Trim[] = seatmapXML.seatmap[0].trims[0].trim; trimArr.forEach(arr => { @@ -146,22 +155,42 @@ function addTrims() { function decodeAddTrims(textArr: string[], x: number, y: number) { let i = 0; + const specialChar = new Map([ + ["Ž", "Ä"], + ["™", "Ö"], + ["š", "Ü"], + ["„", "ä"], + ["”", "ö"], + ["", "ü"], + ["á", "ß"] + ]); textArr.forEach(element => { - const charCode = element.replace(/^\&\#/, "0"); - const character = String.fromCharCode(parseInt(charCode, 16)); + let character; - if(!/[^a-zA-Z0-9äöüÄÖÜß$]/.test(character)) { - const _x = (x - 1) + i; - const _y = y - 1; - console.log(`${character} -> ${_x} ${_y}`); - jQuery(".seatCharts-row")[_y].children[_x].innerHTML = `${character}` + if (specialChar.has(element)) + character = specialChar.get(element); + else { + const charCode = element.replace(/^\&\#/, "0"); + character = String.fromCharCode(parseInt(charCode, 16)); } + + if (character) + applyTrim(x, y, i, character); i++; }); } +function applyTrim(x: number, y: number, i: number, character: string) { + if(!/[^a-zA-Z0-9äöüÄÖÜß$]/.test(character)) { + const _x = (x - 1) + i; + const _y = y - 1; + console.log(`${character} -> ${_x} ${_y}`); + jQuery(".seatCharts-row")[_y].children[_x].innerHTML = `${character}` + } +} + function showSeatTooltip(jBox: any): void { const seatID: string = jBox.source[0].id; diff --git a/client/src/types/types.d.ts b/client/src/types/types.d.ts index d9e7bdc..7af08d2 100644 --- a/client/src/types/types.d.ts +++ b/client/src/types/types.d.ts @@ -71,6 +71,7 @@ export interface InputsWithValue { venueImageHeight: number; venueImageWidth: number; ticketPurchaseUrl: string; + smap: string | undefined; } export interface Config {