Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var scope = this;
- // Get the URL of the page where we load the iFrame
- scope.websiteSourceURL = encodeURIComponent(window.parent.location);
- // Create an HTML div
- var div = document.createElement("div");
- div.innerHTML = '<iframe id="elementID" src="<BUBBLEAPPURL>' width="225px" height="58px" frameBorder="0" scrolling="no" style="position:fixed;bottom:2%;left:2%;z-index:999999999999999;"></iframe>';
- scope.document.body.appendChild(div);
- window.addEventListener('message', (event) => {
- console.log("artnftmint widget: postMessage called");
- if (event.origin != '<ORGINURL>') { return; }
- console.log("artnftmint Widget: postMessage's origin validated, OK.");
- if (event.data.WorkflowAPICall) {
- var workflowCall = JSON.parse(event.data.WorkflowAPICall);
- let _data71linesBookACall = {
- 'email': workflowCall.body.email,
- "date": workflowCall.body.date
- }
- fetch('<APIWORKFLOWCALLBACKURL>', {
- method: "POST",
- body: JSON.stringify(BODYOFCALL),
- headers: {"Content-type": "application/json; charset=UTF-8",
- "Authorization": workflowCall.token}
- })
- .then(response => {
- if (response.ok) {
- response.json().then(function (json) {
- var iframe = document.getElementById("ELEMENTID");
- var iframeWindow = (iframe.contentWindow || iframe.contentDocument);
- iframeWindow.postMessage(
- {"newAppointmentCreated": json.response.appointmentUniqeId }, "https://figmaimportui.bubbleapps.io");
- console.log("artnftmint Widget: postMessage called on iframeWindow");
- });
- }}).catch(error => console.log("artnftmint Error"))}
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement