replaced console.log, installed envify, added appendVersion

This commit is contained in:
zino
2021-05-23 12:17:45 +02:00
parent 9580b81d22
commit 6d40613e64
16 changed files with 167 additions and 102 deletions

View File

@@ -7,7 +7,6 @@ export function injectBookingBtn(): void {
}
export function showSeatmapBtnParent(): void {
console.log("child completely ready");
Communication.sendEventToParent("child_seatmap_ready");
}

View File

@@ -41,9 +41,8 @@ export function initSendVenueXML(inE: any) {
jQuery("#dropdownSeatmap").val(id);
Communication.needSeatmapXML(id);
console.log(css);
console.log(seatmapListing);
Utils.consoleLog(css);
Utils.consoleLog(seatmapListing);
}
export function initSendInputsWithValue(inE: any) {
@@ -78,7 +77,7 @@ export function sendCheckoutResponse(inE: any) {
const data: I.Message = JSON.parse(inE.data);
config.state.isValidSeatSelection = data.message.isValidSeatSelection;
console.log(data.message);
Utils.consoleLog(data.message);
if (!config.state.isValidSeatSelection) {
jBoxHelper.showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`);

View File

@@ -4,6 +4,7 @@ const xml2jsParser = require('xml2js').parseString;
import * as UI from "./ui";
import { config } from "./config";
import * as Cart from "./cart";
import Utils from './utils'
// rework try/catch ?
export function sendMessage(inData: I.Message, inTo: string): void {
@@ -14,8 +15,6 @@ export function sendMessage(inData: I.Message, inTo: string): void {
if (child !== null && child.contentWindow !== null)
child.contentWindow.postMessage(JSON.stringify(inData), "*");
else
console.log(`Element with ID ${inTo} does not exist`);
}
}
@@ -76,11 +75,8 @@ export function cancelCheckout(inUrl: string): void {
fetch(inUrl, {
redirect: "manual"
})
.then(() => console.log(`${inUrl} canceled`))
.catch(function (error) {
console.log("error");
console.log(error);
});
.then(() => Utils.consoleLog(`${inUrl} canceled`))
.catch((error) => Utils.consoleLog(error));
}
export function isValidSeatSelection(): void {
@@ -121,7 +117,5 @@ function getXMLPromise(inUrl: string): Promise<unknown> {
}
});
})
.catch((error) => {
console.log(error);
});
.catch((error) => Utils.consoleLog(error));
}

View File

@@ -3,6 +3,7 @@ import * as I from "../types/types";
export const config: I.Config = {
debug: true,
branch: "staging",
version: "0.0.1",
urlSeatmapStaging: "https://staging.tickets.zinomedia.de",
urlSeatmapMaster: "https://tickets.zinomedia.de",
urlCSSChildMaster: "https://tickets.zinomedia.de/dist/styleChild.css",

View File

@@ -3,6 +3,7 @@ import { config } from "./config";
import * as State from "./state";
import * as Cart from "./cart";
import * as CartButtons from "./cartButtons";
import Utils from './utils'
export function getSeats(): I.JSCSeats {
const seatmapXML: any = config.state.seatmapXML;
@@ -124,10 +125,6 @@ export function selectSeatsInCart(): void {
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,
@@ -213,7 +210,8 @@ function clickedSeat(inSeatmap: any) {
function clickAvailableSeat(inSeatmap: any) {
const selectedSeat: I.JSCSelectedSeat = inSeatmap.settings;
console.log(selectedSeat);
Utils.consoleLog(selectedSeat);
if (State.maximumSelectedSeatsReached(selectedSeat))
return "available";

View File

@@ -2,6 +2,7 @@ import { config } from "./config";
import axios from 'axios';
import * as Communication from "./communication";
import * as I from "../types/types";
import Utils from './utils'
export function needCheckoutResponse(inE: any, inInputsWithValue: I.InputsWithValue) {
const data: I.Message = JSON.parse(inE.data);
@@ -17,7 +18,7 @@ export function needCheckoutResponse(inE: any, inInputsWithValue: I.InputsWithVa
const parsedHTML: Node[] = jQuery.parseHTML(content);
const orderkey: orderkey = jQuery(parsedHTML).find("#orderkey").val();
console.log(`orderkey: ${orderkey}`);
Utils.consoleLog(`orderkey: ${orderkey}`);
if (orderkey) {
isValidSeatSelection = true;
@@ -38,8 +39,8 @@ export function needCheckoutResponse(inE: any, inInputsWithValue: I.InputsWithVa
Communication.sendMessage(message, "iframeSeatmap");
})
.catch(function (error) {
console.log("error in child_needCheckoutResponse");
console.log(error);
Utils.consoleLog("error in child_needCheckoutResponse");
Utils.consoleLog(error);
});
}

View File

@@ -44,10 +44,8 @@ function decodeNormalTrim(element: string): string {
function applyTrim(inCharacter: string, inTrimPos: I.TrimPos): void {
const regex: RegExp = /[^a-zA-Z0-9äöüÄÖÜß$]/;
if (!regex.test(inCharacter)) {
console.log(`${inCharacter} -> ${inTrimPos.xJSC} ${inTrimPos.yJSC}`);
if (!regex.test(inCharacter))
jQuery(".seatCharts-row")[inTrimPos.yJSC].children[inTrimPos.xJSC].innerHTML = `<span class="trimChar">${inCharacter}</span>`
}
}
function getJSCTrimPos(inX: number, inY: number, index: number): I.TrimPos {

View File

@@ -96,4 +96,9 @@ export function adjustUIToLoading(): void {
CartButtons.showHideBtnCartLoading("show");
jQuery("#modalCart i").hide();
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse");
}
export function appendVersion(): void {
jQuery("#bottomHTMLVersion")[0].innerText = config.version;
jQuery("#bottomHTMLBranch")[0].innerText = `(${config.branch})`;
}

View File

@@ -7,13 +7,13 @@ export default class Utils {
(function loopSearch(): void {
const element: boolean | HTMLElement = inSwitch === "selector" ? jQuery(<string>inSelector).get(0) : Utils.getSeatmapElement();
if (element) {
console.log("ready");
Utils.consoleLog("ready");
inCallback();
}
}
else {
console.log(`Repeating for ${inSwitch}`);
Utils.consoleLog(`Repeating for ${inSwitch}`);
setTimeout(() => {
if (inTimeoutInMs && Date.now() - startTimeInMs > inTimeoutInMs)
return;
@@ -67,7 +67,7 @@ export default class Utils {
script.type = 'text/css';
script.innerHTML = inContent;
break;
case "script":
script = document.createElement('script');
script.type = 'text/javascript';
@@ -76,11 +76,11 @@ export default class Utils {
default:
script = undefined;
break;
break;
}
if (script)
Utils.appendScript(script, inLoc);
Utils.appendScript(script, inLoc);
}
static appendScript(inScript: I.TypeInjectScript, inLoc: string): void {
@@ -92,5 +92,10 @@ export default class Utils {
static getDayName(inDate: Date, inLocale: string): string {
return inDate.toLocaleDateString(inLocale, { weekday: 'long' });
}
}
static consoleLog(inMessage: any) {
if (process.env["NODE_ENV"] === "development")
console.log(inMessage);
}
}