;(function () { // Create iframe var iframe = document.createElement('iframe') iframe.id = 'iframe' iframe.src = 'https://widgets.supportbot.pro/8/chat' iframe.frameBorder = '0' iframe.style.zIndex = '9999' iframe.style.backgroundColor = '#fff' iframe.style.borderRadius = '5px' iframe.style.display = 'none' iframe.style.position = 'fixed' iframe.style.boxSizing = 'border-box' iframe.style.width = window.innerWidth < 640 ? '100%' : '448px'; iframe.style.height = window.innerWidth < 640 ? '100%' : '85vh'; iframe.style.bottom = window.innerWidth < 640 ? '0' : '80px'; iframe.style.right = window.innerWidth < 640 ? '0' : '16px'; // Create toggle button var toggleButton = document.createElement('img') toggleButton.className = 'toggle-button' toggleButton.src = 'https://api.supportbot.pro/storage/v1/object/public/public/3c5d3fc2-515e-42c0-812e-1a23d1f3210e/IMG_0030.PNG' toggleButton.alt = 'Toggle Button' toggleButton.style.position = 'fixed' toggleButton.style.width = '50px' toggleButton.style.zIndex = '9999' toggleButton.style.height = '50px' toggleButton.style.borderRadius = '50%' toggleButton.style.backgroundColor = '#fff' toggleButton.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)' toggleButton.style.float = 'right' toggleButton.style.marginTop = '10px' toggleButton.style.right = '10px' toggleButton.style.bottom = '10px' toggleButton.style.cursor = 'pointer' toggleButton.onclick = function () { toggleIframe() } // Append chat box and toggle button to app container document.body.appendChild(iframe) document.body.appendChild(toggleButton) // Define the toggleIframe function function toggleIframe() { var iframeContainer = document.getElementById('iframe') if (iframeContainer.style.display === 'none') { if (window.innerWidth < 640) { toggleButton.style.display = 'none' } iframeContainer.style.display = 'block' } else { toggleButton.style.display = 'block' iframeContainer.style.display = 'none' } } window.addEventListener('message', (event) => { var iframeContainer = document.getElementById('iframe') if (event.data == "openIframe" || event.data == "closeIframe") { toggleIframe() } }); })()