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

65
client/dist/inject.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -20,6 +20,7 @@
"@types/xml2js": "^0.4.8", "@types/xml2js": "^0.4.8",
"browserify": "^17.0.0", "browserify": "^17.0.0",
"browserify-css": "^0.15.0", "browserify-css": "^0.15.0",
"envify": "^4.1.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"jquery-ui": "^1.12.1", "jquery-ui": "^1.12.1",
"tsify": "^5.0.2", "tsify": "^5.0.2",
@@ -815,6 +816,19 @@
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true "dev": true
}, },
"node_modules/envify": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/envify/-/envify-4.1.0.tgz",
"integrity": "sha512-IKRVVoAYr4pIx4yIWNsz9mOsboxlNXiu7TNBnem/K/uTHdkyzXWDzHCK7UTolqBbgaBz0tQHsD3YNls0uIIjiw==",
"dev": true,
"dependencies": {
"esprima": "^4.0.0",
"through": "~2.3.4"
},
"bin": {
"envify": "bin/envify"
}
},
"node_modules/error-ex": { "node_modules/error-ex": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -869,6 +883,19 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true,
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/events": { "node_modules/events": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
@@ -3185,6 +3212,16 @@
} }
} }
}, },
"envify": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/envify/-/envify-4.1.0.tgz",
"integrity": "sha512-IKRVVoAYr4pIx4yIWNsz9mOsboxlNXiu7TNBnem/K/uTHdkyzXWDzHCK7UTolqBbgaBz0tQHsD3YNls0uIIjiw==",
"dev": true,
"requires": {
"esprima": "^4.0.0",
"through": "~2.3.4"
}
},
"error-ex": { "error-ex": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@@ -3227,6 +3264,12 @@
"is-symbol": "^1.0.2" "is-symbol": "^1.0.2"
} }
}, },
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
},
"events": { "events": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",

View File

@@ -5,8 +5,10 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"browserifyf": "func() { browserify --debug -p [ tsify ] $1 > $2; }; func", "browserifyf": "func() { browserify --debug -p [ tsify ] $1 > $2; }; func",
"watchifyf": "func() { watchify --debug --verbose -p [ tsify ] $1 -o $2; }; func", "watchifyfdev": "func() { watchify -t [ envify --NODE_ENV development ] --debug --verbose -p [ tsify ] $1 -o $2; }; func",
"watchifyfcss": "func() { watchify -g browserify-css --debug --verbose -p [ tsify ] $1 -o $2; }; func" "watchifyfprod": "func() { watchify -t [ envify --NODE_ENV production ] --debug --verbose -p [ tsify ] $1 -o $2; }; func",
"watchifyfcssdev": "func() { watchify -t [ envify --NODE_ENV development ] -g browserify-css --debug --verbose -p [ tsify ] $1 -o $2; }; func",
"watchifyfcssprod": "func() { watchify -t [ envify --NODE_ENV production ] -g browserify-css --debug --verbose -p [ tsify ] $1 -o $2; }; func"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
@@ -18,6 +20,7 @@
"@types/xml2js": "^0.4.8", "@types/xml2js": "^0.4.8",
"browserify": "^17.0.0", "browserify": "^17.0.0",
"browserify-css": "^0.15.0", "browserify-css": "^0.15.0",
"envify": "^4.1.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"jquery-ui": "^1.12.1", "jquery-ui": "^1.12.1",
"tsify": "^5.0.2", "tsify": "^5.0.2",

View File

@@ -16,14 +16,14 @@ window.addEventListener('load', () => {
const content: string = new XMLSerializer().serializeToString(document); const content: string = new XMLSerializer().serializeToString(document);
inputsWithValue = { ...inputsWithValue, ...Parser.getInputs(content) }; inputsWithValue = { ...inputsWithValue, ...Parser.getInputs(content) };
console.log(inputsWithValue); Utils.consoleLog(inputsWithValue);
console.log(`trxstate: ${inputsWithValue["trxstate"]}`); Utils.consoleLog(`trxstate: ${inputsWithValue["trxstate"]}`);
// "posturl" in function showMap() only available if "pvmapse" PVO code is true. // "posturl" in function showMap() only available if "pvmapse" PVO code is true.
// "pvmapse" false disables seatmap // "pvmapse" false disables seatmap
const posturlAvail: boolean = /posturl:"(.+?)"/.test(content); const posturlAvail: boolean = /posturl:"(.+?)"/.test(content);
console.log(`posturl available: ${posturlAvail}`); Utils.consoleLog(`posturl available: ${posturlAvail}`);
// Only inject on page with trxstate 20 and if seatmap is enabled with PVO code "pvmapse" // Only inject on page with trxstate 20 and if seatmap is enabled with PVO code "pvmapse"
if (inputsWithValue["trxstate"] !== "20" || posturlAvail === false) if (inputsWithValue["trxstate"] !== "20" || posturlAvail === false)
@@ -49,7 +49,7 @@ window.addEventListener('load', () => {
// https://api.jqueryui.com/dialog/ // https://api.jqueryui.com/dialog/
UI.createDialog(); UI.createDialog();
console.log(inputsWithValue); Utils.consoleLog(inputsWithValue);
}); });
function messageHandler(e: any) { function messageHandler(e: any) {
@@ -58,8 +58,8 @@ function messageHandler(e: any) {
const data: I.Message = JSON.parse(e.data); const data: I.Message = JSON.parse(e.data);
console.log(`parent: received from ${data.from}`); Utils.consoleLog(`parent: received from ${data.from}`);
console.log(data); Utils.consoleLog(data);
switch (data.event) { switch (data.event) {
case "child_init_needInputsWithValue": { case "child_init_needInputsWithValue": {
@@ -75,6 +75,7 @@ function messageHandler(e: any) {
break; break;
} }
case "child_seatmap_ready": { case "child_seatmap_ready": {
Utils.consoleLog("child completely ready");
jQuery("#containerBookingBtn").show(); jQuery("#containerBookingBtn").show();
break; break;
} }

View File

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

View File

@@ -41,9 +41,8 @@ export function initSendVenueXML(inE: any) {
jQuery("#dropdownSeatmap").val(id); jQuery("#dropdownSeatmap").val(id);
Communication.needSeatmapXML(id); Communication.needSeatmapXML(id);
console.log(css); Utils.consoleLog(css);
console.log(seatmapListing); Utils.consoleLog(seatmapListing);
} }
export function initSendInputsWithValue(inE: any) { export function initSendInputsWithValue(inE: any) {
@@ -78,7 +77,7 @@ export function sendCheckoutResponse(inE: any) {
const data: I.Message = JSON.parse(inE.data); const data: I.Message = JSON.parse(inE.data);
config.state.isValidSeatSelection = data.message.isValidSeatSelection; config.state.isValidSeatSelection = data.message.isValidSeatSelection;
console.log(data.message); Utils.consoleLog(data.message);
if (!config.state.isValidSeatSelection) { if (!config.state.isValidSeatSelection) {
jBoxHelper.showJBoxNotice(`Auswahl nicht möglich: Bitte lassen Sie keinen einzelnen Platz frei.`); 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 * as UI from "./ui";
import { config } from "./config"; import { config } from "./config";
import * as Cart from "./cart"; import * as Cart from "./cart";
import Utils from './utils'
// rework try/catch ? // rework try/catch ?
export function sendMessage(inData: I.Message, inTo: string): void { 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) if (child !== null && child.contentWindow !== null)
child.contentWindow.postMessage(JSON.stringify(inData), "*"); 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, { fetch(inUrl, {
redirect: "manual" redirect: "manual"
}) })
.then(() => console.log(`${inUrl} canceled`)) .then(() => Utils.consoleLog(`${inUrl} canceled`))
.catch(function (error) { .catch((error) => Utils.consoleLog(error));
console.log("error");
console.log(error);
});
} }
export function isValidSeatSelection(): void { export function isValidSeatSelection(): void {
@@ -121,7 +117,5 @@ function getXMLPromise(inUrl: string): Promise<unknown> {
} }
}); });
}) })
.catch((error) => { .catch((error) => Utils.consoleLog(error));
console.log(error);
});
} }

View File

@@ -3,6 +3,7 @@ import * as I from "../types/types";
export const config: I.Config = { export const config: I.Config = {
debug: true, debug: true,
branch: "staging", branch: "staging",
version: "0.0.1",
urlSeatmapStaging: "https://staging.tickets.zinomedia.de", urlSeatmapStaging: "https://staging.tickets.zinomedia.de",
urlSeatmapMaster: "https://tickets.zinomedia.de", urlSeatmapMaster: "https://tickets.zinomedia.de",
urlCSSChildMaster: "https://tickets.zinomedia.de/dist/styleChild.css", 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 State from "./state";
import * as Cart from "./cart"; import * as Cart from "./cart";
import * as CartButtons from "./cartButtons"; import * as CartButtons from "./cartButtons";
import Utils from './utils'
export function getSeats(): I.JSCSeats { export function getSeats(): I.JSCSeats {
const seatmapXML: any = config.state.seatmapXML; 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 { export function addSeatmap(inSelector: string, inMap: string[], inRowsNaming: string[], inSeats: I.JSCSeats, inLegend: I.JSCLegend): void {
const containerSeatmap: any = (<any>window).jQuery(inSelector); const containerSeatmap: any = (<any>window).jQuery(inSelector);
// console.log(inSeatmapInitMap);
// console.log(inSeats);
// console.log(inLegend);
config.state.seatmap = containerSeatmap.seatCharts({ config.state.seatmap = containerSeatmap.seatCharts({
naming: { naming: {
top: false, top: false,
@@ -213,7 +210,8 @@ function clickedSeat(inSeatmap: any) {
function clickAvailableSeat(inSeatmap: any) { function clickAvailableSeat(inSeatmap: any) {
const selectedSeat: I.JSCSelectedSeat = inSeatmap.settings; const selectedSeat: I.JSCSelectedSeat = inSeatmap.settings;
console.log(selectedSeat);
Utils.consoleLog(selectedSeat);
if (State.maximumSelectedSeatsReached(selectedSeat)) if (State.maximumSelectedSeatsReached(selectedSeat))
return "available"; return "available";

View File

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

View File

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

View File

@@ -97,3 +97,8 @@ export function adjustUIToLoading(): void {
jQuery("#modalCart i").hide(); jQuery("#modalCart i").hide();
jQuery("#modalCart .uabb-button-text").addClass("dot-pulse"); 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

@@ -9,11 +9,11 @@ export default class Utils {
const element: boolean | HTMLElement = inSwitch === "selector" ? jQuery(<string>inSelector).get(0) : Utils.getSeatmapElement(); const element: boolean | HTMLElement = inSwitch === "selector" ? jQuery(<string>inSelector).get(0) : Utils.getSeatmapElement();
if (element) { if (element) {
console.log("ready"); Utils.consoleLog("ready");
inCallback(); inCallback();
} }
else { else {
console.log(`Repeating for ${inSwitch}`); Utils.consoleLog(`Repeating for ${inSwitch}`);
setTimeout(() => { setTimeout(() => {
if (inTimeoutInMs && Date.now() - startTimeInMs > inTimeoutInMs) if (inTimeoutInMs && Date.now() - startTimeInMs > inTimeoutInMs)
return; return;
@@ -93,4 +93,9 @@ export default class Utils {
static getDayName(inDate: Date, inLocale: string): string { static getDayName(inDate: Date, inLocale: string): string {
return inDate.toLocaleDateString(inLocale, { weekday: 'long' }); return inDate.toLocaleDateString(inLocale, { weekday: 'long' });
} }
static consoleLog(inMessage: any) {
if (process.env["NODE_ENV"] === "development")
console.log(inMessage);
}
} }

View File

@@ -8,6 +8,7 @@ require("jbox/dist/jBox.all.css");
import * as Cart from "./modules/cart"; import * as Cart from "./modules/cart";
import * as BookingBtn from "./modules/bookingButton"; import * as BookingBtn from "./modules/bookingButton";
import * as Child from './modules/child'; import * as Child from './modules/child';
import * as UI from "./modules/ui";
window.addEventListener('load', () => { window.addEventListener('load', () => {
// Inject JSC (jQuery Seat Charts) // Inject JSC (jQuery Seat Charts)
@@ -31,6 +32,8 @@ window.addEventListener('load', () => {
Events.addModalCart(); Events.addModalCart();
Events.addDropdownSeatmap(); Events.addDropdownSeatmap();
// Change version configured in config
UI.appendVersion();
}); });
// Hide header when height of window is smaller than ... // Hide header when height of window is smaller than ...
@@ -40,7 +43,6 @@ window.onresize = function () {
const innerHeight = window.innerHeight; const innerHeight = window.innerHeight;
if (innerHeight < 576) { if (innerHeight < 576) {
console.log("small");
jQuery("#containerEventInfoRow").hide(); jQuery("#containerEventInfoRow").hide();
panzoom?.reset(); panzoom?.reset();
} }
@@ -56,8 +58,8 @@ function messageHandler(inE: any) {
const data: I.Message = JSON.parse(inE.data); const data: I.Message = JSON.parse(inE.data);
console.log(`child: received from ${data.from}`); Utils.consoleLog(`child: received from ${data.from}`);
console.log(data); Utils.consoleLog(data);
switch (data.event) { switch (data.event) {
case "parent_init_venue": { case "parent_init_venue": {

View File

@@ -84,6 +84,7 @@ export interface InputsWithValue {
export interface Config { export interface Config {
debug: boolean; debug: boolean;
branch: string; branch: string;
version: string;
urlSeatmapStaging: string; urlSeatmapStaging: string;
urlSeatmapMaster: string; urlSeatmapMaster: string;
urlCSSChildStaging: string; urlCSSChildStaging: string;