revised communication
This commit is contained in:
@@ -12,14 +12,6 @@ export function sendMessage(inData: I.Message, inTo: string): void {
|
||||
child.contentWindow.postMessage(JSON.stringify(inData), "*");
|
||||
else
|
||||
console.log(`Element with ID ${inTo} does not exist`);
|
||||
|
||||
// if (child === null) {
|
||||
// console.log(`Element with ID ${inTo} does not exist`);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (child.contentWindow !== null)
|
||||
// child.contentWindow.postMessage(JSON.stringify(inData), "*")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +21,7 @@ export function listenToMessages(inHandler: CallableFunction): void {
|
||||
});
|
||||
}
|
||||
|
||||
export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: string, inDate: number = Date.now()) {
|
||||
export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: string, inDate: number = Date.now()): void {
|
||||
xml.getXMLPromise(inUrl).then((result: unknown): void => {
|
||||
const message: I.Message = {
|
||||
date: inDate,
|
||||
@@ -38,12 +30,13 @@ export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: st
|
||||
event: inEvent
|
||||
}
|
||||
sendMessage(message, inTo);
|
||||
}).catch(function (err) {
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
export function sendEventToChild(inEvent: string) {
|
||||
export function sendEventToChild(inEvent: string): void {
|
||||
const message: I.Message = {
|
||||
message: null,
|
||||
from: "parent",
|
||||
@@ -53,7 +46,7 @@ export function sendEventToChild(inEvent: string) {
|
||||
sendMessage(message, "iframeSeatmap");
|
||||
}
|
||||
|
||||
export function sendEventToParent(inEvent: string) {
|
||||
export function sendEventToParent(inEvent: string): void {
|
||||
const message: I.Message = {
|
||||
message: null,
|
||||
from: "child",
|
||||
@@ -63,7 +56,7 @@ export function sendEventToParent(inEvent: string) {
|
||||
sendMessage(message, "parent");
|
||||
}
|
||||
|
||||
export function needSeatmapXML(inID: string) {
|
||||
export function needSeatmapXML(inID: string): void {
|
||||
const message: I.Message = {
|
||||
message: inID,
|
||||
from: "child",
|
||||
@@ -73,14 +66,14 @@ export function needSeatmapXML(inID: string) {
|
||||
sendMessage(message, "parent");
|
||||
}
|
||||
|
||||
export function cancelCheckout(inUrl: string) {
|
||||
export function cancelCheckout(inUrl: string): void {
|
||||
// use fetch instead of axios because of 302 redirect
|
||||
// see https://github.com/axios/axios/issues/932
|
||||
fetch(inUrl, {
|
||||
redirect: "manual"
|
||||
}).then(() => {
|
||||
console.log(`${inUrl} canceled`);
|
||||
}).catch(function (error) {
|
||||
})
|
||||
.then(() => console.log(`${inUrl} canceled`))
|
||||
.catch(function (error) {
|
||||
console.log("error");
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user