window.addEventListener('load', (function () {
var directIcon = ``;
var faceIcon = ``;
var xIcon = ``
// Function to add CSS to the head
function addStyles(css) {
var style = document.createElement("style");
style.type = "text/css";
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);
}
// Function to toggle the display of the iframe
function toggleIframe() {
document.getElementById("wingmateWidgetIframeContainer").onload = () => {};
var iframeContainer = document.getElementById(
"wingmateWidgetIframeContainer"
);
var isDisplayed = iframeContainer.style.display === "flex";
iframeContainer.style.display = isDisplayed ? "none" : "flex";
// remove buttonsContainer
var buttonsContainer = document.getElementById(
"wingmateWidgetButtonsContainer"
);
if (buttonsContainer) {
buttonsContainer.style.display = "none";
}
const floatingIcon = document.getElementById(
"wingmateWidgetFloatingIcon"
);
const xIconButton = document.getElementById("wingmateXIcon");
xIconButton.style.display = isDisplayed ? "none" : "inline-flex";
floatingIcon.innerHTML = isDisplayed
? `${directIcon}${faceIcon}`
: `${faceIcon}Close`;
}
// CSS styles
var css = `
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');
#wingmateWidgetFloatingIcon *:not(svg *),
#wingmateWidgetButtonsContainer *:not(svg *),
#wingmateWidgetFloatingIcon,
#wingmateWidgetButtonsContainer {
all: unset;
font-size: 16px;
margin: 0;
padding: 0;
box-sizing: border-box;
}
#wingmateWidgetFloatingIcon {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #FFFFFF;
color: #000000;
gap: 8px;
display: inline-flex;
justify-content: center;
align-items: center;
padding: 11px 25px;
box-shadow: 0px 10px 50px 0px #0000001A;
border-radius: 17px;
cursor: pointer;
z-index: 2000000;
border-width: 0px;
font-family: 'Nunito', sans-serif;
font-weight: 800;
transition: background-color 0.2s, color 0.2s;
}
#wingmateWidgetFloatingIcon:hover {
background-color: #4F90D2;
color: white;
}
#wingmateWidgetButtonsContainer {
position: fixed;
z-index: 2000000;
bottom: 94px;
right: 23px;
font-family: 'Nunito', sans-serif;
}
#wingmateWidgetButtonsContainer button {
display: flex;
background-color: #FFFFFF;
color: #000000;
justify-content: center;
align-items: center;
padding: 11px 25px;
width: 100%;
box-shadow: 0px 10px 50px 0px #0000001A;
border-radius: 17px;
cursor: pointer;
border-width: 0px;
font-family: 'Nunito', sans-serif;
font-weight: 600;
transition: background-color 0.2s, color 0.2s;
}
#wingmateWidgetButtonsContainer button:hover {
background-color: #4F90D2;
color: white;
}
#wingmateWidgetButtonsContainer button:not(:last-child) {
margin-bottom: 10px;
}
@media (min-width: 768px) {
#wingmateWidgetIframeContainer {
position: fixed;
bottom: 94px;
right: 0px;
background-color: rgba(0,0,0,0.2);
display: none;
z-index: 2000000;
max-width: 98%;
width: 402px;
max-height: 80%;
height: 744px;
border-radius: 10px;
margin-right: 1vw;
}
#wingmateWidgetIframeContainer {
display: none;
}
}
@media (max-width: 768px) {
#wingmateWidgetFloatingIcon *:not(svg *),
#wingmateWidgetButtonsContainer *:not(svg *),
#wingmateWidgetFloatingIcon,
#wingmateWidgetButtonsContainer {
font-size: 10px;
}
#wingmateWidgetFloatingIcon svg {
height: 20px;
}
#wingmateWidgetFloatingIcon {
padding: 5px 10px;
border-radius: 8px;
}
#wingmateWidgetButtonsContainer {
bottom: 70px;
}
#wingmateWidgetButtonsContainer button {
padding: 5px 10px;
border-radius: 8px;
}
#wingmateWidgetIframeContainer {
position: fixed;
bottom: 0px;
right: 0px;
background-color: rgba(0,0,0,0.2);
display: none;
z-index: 2000000;
max-width: 100%;
width: 100%;
max-height: 100%;
height: 100%;
}
#wingmateXIcon *:not(svg *),
#wingmateXIcon {
all: unset;
font-size: 16px;
margin: 0;
padding: 0;
box-sizing: border-box;
}
#wingmateXIcon {
position: fixed;
top: 20px;
right: 20px;
background-color: transparent;
color: #000000;
gap: 8px;
display: inline-flex;
justify-content: center;
align-items: center;
border-radius: 17px;
cursor: pointer;
z-index: 2000001;
border-width: 0px;
font-family: 'Nunito', sans-serif;
font-weight: 800;
}
#wingmateXIcon:hover {
border: 1px #000 solid;
padding: 0.2rem;
background-color: transparent;
color: white;
top: 16px;
right: 16px;
border-radius: 8px;
}
}
`;
// Inject CSS
addStyles(css);
//create head
var maximumScale = document.createElement("meta");
maximumScale.setAttribute("name", "viewport");
maximumScale.setAttribute("content", "width=device-width, initial-scale=1, maximum-scale=1");
document.head.appendChild(maximumScale);
// Create close icon
var closeIcon = document.createElement("button");
closeIcon.id = "wingmateXIcon";
closeIcon.type = "button";
closeIcon.innerHTML = xIcon;
closeIcon.onclick = toggleIframe;
closeIcon.style.display = "none";
document.body.appendChild(closeIcon);
// Create and append the floating icon
var floatingIcon = document.createElement("button");
floatingIcon.id = "wingmateWidgetFloatingIcon";
floatingIcon.type = "button";
floatingIcon.innerHTML = `${directIcon}${faceIcon}Your WingMate`;
floatingIcon.onclick = toggleIframe;
document.body.appendChild(floatingIcon);
// Create and append the iframe container
var iframeContainer = document.createElement("div");
iframeContainer.id = "";
iframeContainer.innerHTML = ``;
document.body.appendChild(iframeContainer);
document.getElementById("wingmateWidgetIframeContainer").onload = function () {
// insert the buttons
var buttonContents = ["Check flight status","Book a new flight"];
var buttonsContainer = document.createElement("div");
buttonsContainer.id = "wingmateWidgetButtonsContainer";
buttonContents.forEach((content) => {
var button = document.createElement("button");
button.innerHTML = content;
button.onclick = () => {
var iframeContainer = document.getElementById(
"wingmateWidgetIframeContainer"
);
iframeContainer.contentWindow.postMessage(
content,
"https://www.wingmates.ai"
);
toggleIframe();
};
buttonsContainer.appendChild(button);
});
var moreButton = document.createElement("button");
moreButton.innerHTML = "More";
moreButton.onclick = toggleIframe;
buttonsContainer.appendChild(moreButton);
document.body.appendChild(buttonsContainer);
}
}));