before state inputswithvalue
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import * as I from "../types/types";
|
||||
import { state } from "../seatmap";
|
||||
import { config } from "./config";
|
||||
import * as State from "./state";
|
||||
import * as Cart from "./cart";
|
||||
import * as UI from "./ui";
|
||||
|
||||
export function getSeats(inXML: any): I.JSCSeats {
|
||||
const pricescaleArr: I.SeatmapPricescale[] = inXML.seatmap[0].pricescale_config[0].pricescale;
|
||||
@@ -205,7 +208,7 @@ function enterSeatsInMatrix(inRows: I.LayoutRow2[], inArrMatrix: string[][], inP
|
||||
inArrMatrix[Y][X] = generateSeatStr(seatsKey, seatArr);
|
||||
|
||||
// save seatArr in state with seatID as key
|
||||
state.layoutRows[seatArr[0]] = seatArr;
|
||||
config.state.layoutRows[seatArr[0]] = seatArr;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -244,4 +247,116 @@ export function createArrMatrix(inNumrows: number, inNumcols: number, inInitial:
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
export function addTrims(inSeatmapXML: any) {
|
||||
const trimArr: I.Trim[] = inSeatmapXML.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>`
|
||||
}
|
||||
}
|
||||
|
||||
export function selectSeatsInCart(inSeatmap: any) {
|
||||
config.state.selectedSeatsArr.forEach(arr => {
|
||||
const seatID: string = arr[0];
|
||||
|
||||
if (inSeatmap.get(seatID))
|
||||
inSeatmap.status(seatID, "selected");
|
||||
});
|
||||
}
|
||||
|
||||
export function addSeatmap(inSelector: string, inMap: string[], inRowsNaming: string[], inSeats: I.JSCSeats, inLegend: I.JSCLegend, inSeatmap: any, inVenueXML: I.VenueXML): void {
|
||||
const containerSeatmap: any = (<any>window).jQuery(inSelector);
|
||||
|
||||
// console.log(inSeatmapInitMap);
|
||||
// console.log(inSeats);
|
||||
// console.log(inLegend);
|
||||
|
||||
inSeatmap = 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, inSeatmap))
|
||||
return "available";
|
||||
|
||||
State.addSeatToState(inVenueXML, selectedSeat);
|
||||
Cart.calcOverallPrice(inVenueXML);
|
||||
UI.setBtnCartText();
|
||||
|
||||
return "selected";
|
||||
}
|
||||
else if (this.status() === "selected") {
|
||||
const selectedSeat: I.JSCSelectedSeat = this.settings;
|
||||
|
||||
State.removeSeatFromState(selectedSeat);
|
||||
Cart.calcOverallPrice(inVenueXML);
|
||||
UI.setBtnCartText();
|
||||
console.log(config.state.selectedSeatsArr);
|
||||
|
||||
return "available";
|
||||
}
|
||||
else if (this.status() == 'unavailable') {
|
||||
return "unavailable";
|
||||
}
|
||||
else {
|
||||
return this.style();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user