revised parser
This commit is contained in:
@@ -88,15 +88,7 @@ export function generateLegend(inNode: string): I.JSCLegend {
|
||||
}
|
||||
}
|
||||
|
||||
function createLegendItems(pricescaleArr: I.SeatmapPricescale[], venuePricescaleArr: I.Pricescale2[]): string[][] {
|
||||
return pricescaleArr.map((arr, index: number) => {
|
||||
const id: string = arr.id[0];
|
||||
const seatsKey: string = String.fromCharCode(97 + index).toLocaleUpperCase();
|
||||
const desc: string | undefined = venuePricescaleArr.find(obj => obj.id[0] === id)?.desc[0];
|
||||
const description: string = `${desc} €${pricescaleArr[index].ref_price[0]}`;
|
||||
return [seatsKey, "available", description];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function setUnavailableSeats(): void {
|
||||
const seatmapXML: any = config.state.seatmapXML;
|
||||
@@ -109,6 +101,80 @@ export function setUnavailableSeats(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSeatsKey(inSeatID: string, inPricescaleArr: I.SeatmapPricescale[]): string | undefined {
|
||||
for (let key in inPricescaleArr) {
|
||||
if (inPricescaleArr[key].mask[0].includes(inSeatID))
|
||||
return String.fromCharCode(97 + parseInt(key)).toLocaleUpperCase();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function splitSeatStr(inSeatStr: string): string[] {
|
||||
return inSeatStr.split(",").map((item) => item.trim());
|
||||
}
|
||||
|
||||
export function createArrMatrix(inNumrows: number, inNumcols: number, inCharacter: string): string[][] {
|
||||
// let matrixArr: string[][] = [];
|
||||
|
||||
// for (let i: number = 0; i < inNumrows; ++i) {
|
||||
// let columns: string[] = [];
|
||||
|
||||
// for (let j: number = 0; j < inNumcols; ++j)
|
||||
// columns[j] = inCharacter;
|
||||
|
||||
// matrixArr[i] = columns;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// return matrixArr;
|
||||
|
||||
return Array(inNumrows).fill(null).map(() => Array(inNumcols).fill(inCharacter));
|
||||
}
|
||||
|
||||
export function selectSeatsInCart(): void {
|
||||
const seatmap: any = config.state.seatmap;
|
||||
config.state.selectedSeatsArr.forEach(arr => {
|
||||
const seatID: string = arr[0];
|
||||
|
||||
if (seatmap.get(seatID))
|
||||
seatmap.status(seatID, "selected");
|
||||
});
|
||||
}
|
||||
|
||||
export function addSeatmap(inSelector: string, inMap: string[], inRowsNaming: string[], inSeats: I.JSCSeats, inLegend: I.JSCLegend): void {
|
||||
const containerSeatmap: any = (<any>window).jQuery(inSelector);
|
||||
|
||||
// console.log(inSeatmapInitMap);
|
||||
// console.log(inSeats);
|
||||
// console.log(inLegend);
|
||||
|
||||
config.state.seatmap = containerSeatmap.seatCharts({
|
||||
naming: {
|
||||
top: false,
|
||||
left: false,
|
||||
rows: inRowsNaming,
|
||||
},
|
||||
map: inMap,
|
||||
seats: inSeats,
|
||||
legend: inLegend,
|
||||
click: function () {
|
||||
return clickedSeat(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createLegendItems(pricescaleArr: I.SeatmapPricescale[], venuePricescaleArr: I.Pricescale2[]): string[][] {
|
||||
return pricescaleArr.map((arr, index: number) => {
|
||||
const id: string = arr.id[0];
|
||||
const seatsKey: string = String.fromCharCode(97 + index).toLocaleUpperCase();
|
||||
const desc: string | undefined = venuePricescaleArr.find(obj => obj.id[0] === id)?.desc[0];
|
||||
const description: string = `${desc} €${pricescaleArr[index].ref_price[0]}`;
|
||||
return [seatsKey, "available", description];
|
||||
});
|
||||
}
|
||||
|
||||
function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inPricescaleArr: I.SeatmapPricescale[], inAvailabilityArr: I.JSCAvailability): string[][] {
|
||||
const availableArr: string[] = inAvailabilityArr.available_selectable_mask[0].split(",");
|
||||
const unavailableArr: string[] = inAvailabilityArr.unavailable_unselectable_mask[0].split(",");
|
||||
@@ -142,7 +208,7 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
|
||||
|
||||
if (seatsKey)
|
||||
inArrMatrix[Y][X] = `${seatsKey}[${seatArr[0]}, ]`;
|
||||
|
||||
|
||||
|
||||
// save seatArr in state with seatID as key
|
||||
config.state.layoutRows[seatArr[0]] = seatArr;
|
||||
@@ -152,153 +218,40 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
|
||||
return inArrMatrix;
|
||||
}
|
||||
|
||||
export function getSeatsKey(inSeatID: string, inPricescaleArr: I.SeatmapPricescale[]): string | undefined {
|
||||
// for (let key in inPricescaleArr) {
|
||||
// if (inPricescaleArr[key].mask[0].includes(inSeatID))
|
||||
// return String.fromCharCode(97 + parseInt(key)).toLocaleUpperCase();
|
||||
// }
|
||||
|
||||
return inPricescaleArr.map((arr, index) => {
|
||||
if (arr.mask[0].includes(inSeatID))
|
||||
return String.fromCharCode(97 + index).toLocaleUpperCase();
|
||||
else
|
||||
return undefined;
|
||||
})[0];
|
||||
}
|
||||
|
||||
export function splitSeatStr(inSeatStr: string): string[] {
|
||||
return inSeatStr.split(",").map((item) => item.trim());
|
||||
}
|
||||
|
||||
export function createArrMatrix(inNumrows: number, inNumcols: number, inCharacter: string): string[][] {
|
||||
// let matrixArr: string[][] = [];
|
||||
|
||||
// for (let i: number = 0; i < inNumrows; ++i) {
|
||||
// let columns: string[] = [];
|
||||
|
||||
// for (let j: number = 0; j < inNumcols; ++j)
|
||||
// columns[j] = inCharacter;
|
||||
|
||||
// matrixArr[i] = columns;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// return matrixArr;
|
||||
|
||||
return Array(inNumrows).fill(null).map(() => Array(inNumcols).fill(inCharacter));
|
||||
}
|
||||
|
||||
export function addTrims() {
|
||||
const seatmapXML = config.state.seatmapXML;
|
||||
const trimArr: I.Trim[] = seatmapXML.seatmap[0].trims[0].trim;
|
||||
trimArr.forEach(arr => {
|
||||
const [xTrim, yTrim] = arr.coord[0].split(",").map(Number);
|
||||
const textArr: string[] = arr.text[0].split(";").filter(Boolean);
|
||||
const x = xTrim / 20;
|
||||
const y = Math.round(yTrim / 21.25);
|
||||
|
||||
console.log(`xTrim: ${xTrim} yTrim: ${yTrim} -> x: ${x} y: ${y}`);
|
||||
|
||||
decodeAddTrims(textArr, x, y);
|
||||
});
|
||||
}
|
||||
|
||||
function decodeAddTrims(textArr: string[], x: number, y: number) {
|
||||
let i = 0;
|
||||
const specialChar = new Map([
|
||||
["Ž", "Ä"],
|
||||
["™", "Ö"],
|
||||
["š", "Ü"],
|
||||
["„", "ä"],
|
||||
["”", "ö"],
|
||||
["", "ü"],
|
||||
["á", "ß"]
|
||||
]);
|
||||
|
||||
textArr.forEach(element => {
|
||||
let 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 = `<span class="trimChar">${character}</span>`
|
||||
function clickedSeat(inSeatmap: any) {
|
||||
if (inSeatmap.status() == 'available') {
|
||||
return clickAvailableSeat(inSeatmap);
|
||||
}
|
||||
else if (inSeatmap.status() === "selected") {
|
||||
return clickedSelectedSeat(inSeatmap);
|
||||
}
|
||||
else if (inSeatmap.status() == 'unavailable') {
|
||||
return "unavailable";
|
||||
}
|
||||
else {
|
||||
return inSeatmap.style();
|
||||
}
|
||||
}
|
||||
|
||||
export function selectSeatsInCart() {
|
||||
const seatmapXML = config.state.seatmapXML;
|
||||
config.state.selectedSeatsArr.forEach(arr => {
|
||||
const seatID: string = arr[0];
|
||||
function clickAvailableSeat(inSeatmap: any) {
|
||||
const selectedSeat: I.JSCSelectedSeat = inSeatmap.settings;
|
||||
console.log(selectedSeat);
|
||||
|
||||
if (seatmapXML.get(seatID))
|
||||
seatmapXML.status(seatID, "selected");
|
||||
});
|
||||
if (State.maximumSelectedSeatsReached(selectedSeat))
|
||||
return "available";
|
||||
|
||||
State.addSeatToState(selectedSeat);
|
||||
Cart.calcOverallPrice();
|
||||
UI.setBtnCartText();
|
||||
|
||||
return "selected";
|
||||
}
|
||||
|
||||
export function addSeatmap(inSelector: string, inMap: string[], inRowsNaming: string[], inSeats: I.JSCSeats, inLegend: I.JSCLegend): void {
|
||||
const containerSeatmap: any = (<any>window).jQuery(inSelector);
|
||||
function clickedSelectedSeat(inSeatmap: any) {
|
||||
const selectedSeat: I.JSCSelectedSeat = inSeatmap.settings;
|
||||
State.removeSeatFromState(selectedSeat);
|
||||
Cart.calcOverallPrice();
|
||||
UI.setBtnCartText();
|
||||
|
||||
// console.log(inSeatmapInitMap);
|
||||
// console.log(inSeats);
|
||||
// console.log(inLegend);
|
||||
|
||||
config.state.seatmap = containerSeatmap.seatCharts({
|
||||
naming: {
|
||||
top: false,
|
||||
left: false,
|
||||
rows: inRowsNaming,
|
||||
},
|
||||
map: inMap,
|
||||
seats: inSeats,
|
||||
legend: inLegend,
|
||||
click: function () {
|
||||
if (this.status() == 'available') {
|
||||
const selectedSeat: I.JSCSelectedSeat = this.settings;
|
||||
|
||||
console.log(selectedSeat);
|
||||
|
||||
if (State.maximumSelectedSeatsReached(selectedSeat))
|
||||
return "available";
|
||||
|
||||
State.addSeatToState(selectedSeat);
|
||||
Cart.calcOverallPrice();
|
||||
UI.setBtnCartText();
|
||||
|
||||
return "selected";
|
||||
}
|
||||
else if (this.status() === "selected") {
|
||||
const selectedSeat: I.JSCSelectedSeat = this.settings;
|
||||
|
||||
State.removeSeatFromState(selectedSeat);
|
||||
Cart.calcOverallPrice();
|
||||
UI.setBtnCartText();
|
||||
console.log(config.state.selectedSeatsArr);
|
||||
|
||||
return "available";
|
||||
}
|
||||
else if (this.status() == 'unavailable') {
|
||||
return "unavailable";
|
||||
}
|
||||
else {
|
||||
return this.style();
|
||||
}
|
||||
}
|
||||
});
|
||||
return "available";
|
||||
}
|
||||
@@ -2,12 +2,12 @@ import * as I from "../types/types";
|
||||
var jQuery = require("jquery");
|
||||
|
||||
export function getVenueLocation(): string {
|
||||
let span: string[] = [];
|
||||
let spanArr: string[] = [];
|
||||
jQuery(".venue span").each(function (this: any) {
|
||||
span.push(jQuery(this).text());
|
||||
spanArr.push(jQuery(this).text());
|
||||
});
|
||||
|
||||
return span.join(", ");
|
||||
return spanArr.join(", ");
|
||||
}
|
||||
|
||||
export function getInputs(inContent: string): I.Inputs {
|
||||
@@ -17,6 +17,7 @@ export function getInputs(inContent: string): I.Inputs {
|
||||
jQuery(parsedHTML).find('input').each(function (this: any) {
|
||||
const name: string = this.name;
|
||||
const value: string = this.value;
|
||||
|
||||
if (value !== '')
|
||||
inputs[name] = value;
|
||||
});
|
||||
@@ -25,13 +26,13 @@ export function getInputs(inContent: string): I.Inputs {
|
||||
}
|
||||
|
||||
// todo: check with different venues
|
||||
export function getImportantNote(): { importantNote: string, importantNoteEncoded: string } | undefined {
|
||||
export function getImportantNote(): I.ImportantNote | undefined {
|
||||
if (jQuery(".important_note").length) {
|
||||
const importantNote: string | null = jQuery(".important_note")[0].textContent;
|
||||
|
||||
if (importantNote?.trim().length) {
|
||||
const importantNoteEncoded: string = encodeURIComponent(importantNote);
|
||||
return {
|
||||
return <I.ImportantNote> {
|
||||
"importantNote": importantNote,
|
||||
"importantNoteEncoded": importantNoteEncoded
|
||||
}
|
||||
@@ -41,7 +42,7 @@ export function getImportantNote(): { importantNote: string, importantNoteEncode
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getAdditionalInputs(inContent: string): { [key: string]: string } {
|
||||
export function getAdditionalInputs(inContent: string): I.Inputs {
|
||||
const event = inContent.match(/event:"(.+?)"/)![1];
|
||||
const holdcode = inContent.match(/holdcode:"(.+?)"/)![1];
|
||||
const posturlRaw = inContent.match(/posturl:"(.+?)"/)![1];
|
||||
@@ -50,7 +51,7 @@ export function getAdditionalInputs(inContent: string): { [key: string]: string
|
||||
const venueLocation = getVenueLocation();
|
||||
const ticketPurchaseUrl = `${posturlRawDecoded.split("?")[0].split('/').slice(0,-1).join('/')}/TicketPurchase`;
|
||||
|
||||
return {
|
||||
return <I.Inputs> {
|
||||
"event": event,
|
||||
"holdcode": holdcode,
|
||||
"posturlRaw": posturlRaw,
|
||||
@@ -61,11 +62,11 @@ export function getAdditionalInputs(inContent: string): { [key: string]: string
|
||||
}
|
||||
}
|
||||
|
||||
export function getVenueImage(): { venueImageSrc: string, venueImageHeight: number, venueImageWidth: number } | undefined {
|
||||
export function getVenueImage(): I.VenueImage | undefined {
|
||||
const img: HTMLImageElement = jQuery("#static_venue_map img").get(0);
|
||||
|
||||
if (img) {
|
||||
return {
|
||||
return <I.VenueImage> {
|
||||
venueImageSrc: img.src,
|
||||
venueImageHeight: img.height,
|
||||
venueImageWidth: img.width
|
||||
@@ -76,15 +77,12 @@ export function getVenueImage(): { venueImageSrc: string, venueImageHeight: numb
|
||||
}
|
||||
|
||||
export function getSMAP(): string | undefined {
|
||||
if (jQuery("#seating_map_url").length === 0)
|
||||
if (!jQuery("#seating_map_url").length)
|
||||
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;
|
||||
|
||||
return found ? found[1] : undefined;
|
||||
}
|
||||
55
client/src/modules/trims.ts
Normal file
55
client/src/modules/trims.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { config } from "./config";
|
||||
import * as I from "../types/types";
|
||||
|
||||
export function addTrims() {
|
||||
const seatmapXML = config.state.seatmapXML;
|
||||
const trimArr: I.Trim[] = seatmapXML.seatmap[0].trims[0].trim;
|
||||
trimArr.forEach(arr => {
|
||||
const [xTrim, yTrim] = arr.coord[0].split(",").map(Number);
|
||||
const textArr: string[] = arr.text[0].split(";").filter(Boolean);
|
||||
const x = xTrim / 20;
|
||||
const y = Math.round(yTrim / 21.25);
|
||||
|
||||
console.log(`xTrim: ${xTrim} yTrim: ${yTrim} -> x: ${x} y: ${y}`);
|
||||
|
||||
decodeAddTrims(textArr, x, y);
|
||||
});
|
||||
}
|
||||
|
||||
function decodeAddTrims(textArr: string[], x: number, y: number) {
|
||||
let i = 0;
|
||||
const specialChar = new Map([
|
||||
["Ž", "Ä"],
|
||||
["™", "Ö"],
|
||||
["š", "Ü"],
|
||||
["„", "ä"],
|
||||
["”", "ö"],
|
||||
["", "ü"],
|
||||
["á", "ß"]
|
||||
]);
|
||||
|
||||
textArr.forEach(element => {
|
||||
let 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 = `<span class="trimChar">${character}</span>`
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ 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";
|
||||
|
||||
// let inputsWithValue: I.InputsWithValue;
|
||||
// let seatmap: any;
|
||||
@@ -120,7 +121,7 @@ function messageHandler(inE: any) {
|
||||
JSC.selectSeatsInCart();
|
||||
UI.convertLegendToDropdown("dropdownLegend");
|
||||
Events.dropdownLegendOnChange("#dropdownLegend");
|
||||
JSC.addTrims();
|
||||
Trims.addTrims();
|
||||
XMLHelper.processSMAP();
|
||||
config.state.panzoom = UI.addPanzoom("#containerSeatmapInner", ".panzoomZoomIn", ".panzoomZoomOut", "#panzoomResetZoom");
|
||||
UI.controlLoftloader("hide");
|
||||
|
||||
11
client/src/types/types.d.ts
vendored
11
client/src/types/types.d.ts
vendored
@@ -406,5 +406,16 @@ export interface JSCSelectedSeat {
|
||||
$node: Node;
|
||||
}
|
||||
|
||||
export interface VenueImage {
|
||||
venueImageSrc: string;
|
||||
venueImageHeight: number;
|
||||
venueImageWidth: number;
|
||||
}
|
||||
|
||||
export interface ImportantNote {
|
||||
importantNote: string;
|
||||
importantNoteEncoded: string;
|
||||
}
|
||||
|
||||
export type TypeBuyerType = (string | undefined)[][] | undefined;
|
||||
export type TypeBuyerTypeArr = (string | undefined)[];
|
||||
Reference in New Issue
Block a user