var iframe_loaded = 0; var referrer = document.location.href; var widgetButtons = document.getElementsByClassName('dialog_widget_button'); var widget = document.createElement('div'); widget.classList.add('dialogai-consultant-widget'); var loader = document.createElement('div'); loader.id = 'widget-loader'; loader.classList.add('dialogai-modal-loader'); var modal = document.createElement('div'); modal.id = 'widget-modal'; modal.classList.add('dialogai-widget-modal'); var overlay = document.createElement('div'); overlay.id = 'dialogai-overlay'; document.body.appendChild(overlay); var iframe = document.createElement('iframe'); //iframe.src = 'https://functions.pro-talk.ru/api/v1.0/chatgpt_widget_dialog_api?record_id=rec7UIESmHvBJpkJh&promt_id=2103&url='+referrer+'&lang=ru&strict=-&video=&store_user_email='; iframe.src = ''; iframe.style.overflow = 'hidden'; modal.appendChild(iframe); var closeButton = document.createElement('div'); closeButton.classList.add('dialogai-close-button'); closeButton.innerHTML = 'X'; document.body.appendChild(closeButton); widget.addEventListener('click', function() { var delay = 100; if (iframe_loaded == 0) { iframe.src = 'https://functions.pro-talk.ru/api/v1.0/chatgpt_widget_dialog_api?record_id=rec7UIESmHvBJpkJh&promt_id=2103&url='+referrer+'&lang=ru&strict=-&video=&store_user_email='; iframe_loaded = 1; delay = 3500; } loader.style.display='block'; document.getElementById('dialogai-overlay').style.display = 'block'; setTimeout(function() { loader.style.display='none'; //modal.style.display = 'block'; modal.classList.add('show'); closeButton.classList.add('dialogai-show'); }, delay); }); closeButton.addEventListener('click', function() { //modal.style.display = 'none'; modal.classList.remove('show'); document.getElementById('dialogai-overlay').style.display = 'none'; closeButton.classList.remove('dialogai-show'); modal.classList.remove('show'); }); if (widgetButtons.length > 0) { for (var i = 0; i < widgetButtons.length; i++) { widgetButtons[i].addEventListener('click', function() { var recordId = this.getAttribute('record_id'); var promt_id = this.getAttribute('promt_id'); iframe.src = 'https://functions.pro-talk.ru/api/v1.0/chatgpt_widget_dialog_api?record_id=' + recordId + '&promt_id='+promt_id+'&url='+referrer+'&lang=ru&strict=-&video=&store_user_email='; loader.style.display='block'; setTimeout(function() {document.getElementById('dialogai-overlay').style.display = 'block';loader.style.display='none';modal.style.display = 'block';modal.classList.add('show');closeButton.classList.add('dialogai-show');}, 5000); }); } } document.addEventListener('click', function(event) { var isClickInsideModal = modal.contains(event.target); var isClickOnWidget = widget.contains(event.target); if (!isClickInsideModal && !isClickOnWidget) { //modal.style.display = 'none'; modal.classList.remove('show'); document.getElementById('dialogai-overlay').style.display = 'none'; closeButton.classList.remove('dialogai-show'); modal.classList.remove('show'); } }); var styles = document.createElement('style'); styles.innerHTML = ` .dialogai-consultant-widget { position: fixed; bottom: 10rem; right: 2rem; width: 80px; height: 80px; background-color: #ffffff; cursor: pointer; background-image: url('https://v5.airtableusercontent.com/v3/u/28/28/1714219200000/HBOcfWjZVhANEMgEzPlJRw/R0dhsfPdqHGDjxqBdjjSyWi4Cej4JbKsbe63x_X6KKYsAyMH4PWEQmi8q7lpHNyeTEW2auyUb6V_tEWYuXBndcf1J2ozur53ktmXAJSaF5tir8RZHXgV5-eBBozhsvaASw_ucnBnUxHlFdHTdoleAhKR1K4oWkLVntOj4EGg1oHH5Mh0LmcJjm1LSGJMjdrg/JfhE7XIZ4U5_PZWZ7PI03o4VmMlKy0si3moee0AS38M?sid=nocache'); background-size: cover; border-radius: 50%; box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); z-index: 999; animation: pulse 2s infinite; border: solid #fff 5px; //transform: translate(-50%, -50%); } .dialogai-consultant-telegram-bot { position: fixed; bottom: calc(12rem + 50px); right: calc(2rem + 10px); width: 60px; height: 60px; background-color: #ffffff; cursor: pointer; background-image: url('/get_svg_file/Telegram.svg'); background-size: cover; border-radius: 50%; box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); z-index: 9998; animation: pulse 2s infinite; } .dialogai-consultant-whatsapp { position: fixed; bottom: calc(12rem + 100px); right: calc(2rem + 10px); width: 60px; height: 60px; background-color: #ffffff; cursor: pointer; background-image: url('/get_svg_file/WhatsApp.svg'); background-size: cover; border-radius: 50%; box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); z-index: 9997; animation: pulse 2s infinite; } @keyframes pulse { 0% { transform: scale(0.9); } 50% { transform: scale(1); } 100% { transform: scale(0.9); } } @keyframes rotateY { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(720deg); } } .dialogai-modal-loader { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; } .dialogai-modal-loader::after { content: ''; display: block; width: 200px; height: 200px; background-image: url(/get_svg_file/loading-wdget-ai.svg); background-size: cover; } .dialogai-widget-modal { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scaleY(0); width: 90%; height: 90%; max-width: 950px; max-height: 650px; z-index: 9999999999; opacity: 0; transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out; } .dialogai-widget-modal.show { opacity: 1; transform: translate(-50%, -50%) scaleY(1); } .dialogai-widget-modal iframe { width: 100%; height: 100%; //max-width: 400px; //max-height: 600px; //overflow: hidden; border: none; z-index: 99998; border-radius:20px; box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); overflow: auto; } #dialogai-overlay { display: none; position: fixed; z-index: 99997; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px); } .dialogai-close-button { top: 20px; right: 20px; width: 40px; height: 40px; font-size: 18px; padding-top: 0.5rem; position: fixed; font-wight:bold; background: #333; text-align: center; border-radius: 100%; z-index: 99999; color: #ffffff; cursor: pointer; display: none; box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.5); } .dialogai-close-button:hover { color: #ccc; } .dialogai-close-button.dialogai-show { display: block; } @media (max-width: 950px) { .dialogai-widget-modal { max-width: 350px; max-height: 450px; } .dialogai-widget-modal iframe { width: auto; } } `; document.head.appendChild(styles); //if (widgetButtons.length > 0) {} else {} document.body.appendChild(loader); document.body.appendChild(modal); setTimeout(function() { document.body.appendChild(widget); }, 6000); let idleTime = 0; let modalTimeout; function resetTimer() { clearTimeout(modalTimeout); idleTime = 0; startTimer(); } function startTimer() { modalTimeout = setTimeout(function() { if (modal.style.display != 'block') { loader.style.display='block'; document.getElementById('dialogai-overlay').style.display = 'block'; setTimeout(function() { loader.style.display='none'; //modal.style.display = 'block'; modal.classList.add('show'); document.getElementById('dialogai-overlay').style.display = 'block'; closeButton.classList.add('dialogai-show'); }, 500); } }, 200000000); } document.addEventListener('mousemove', resetTimer); document.addEventListener('click', resetTimer); document.addEventListener('keypress', resetTimer); document.addEventListener('touchstart', resetTimer); startTimer(); setInterval(function() { widget.style.animation = 'rotateY 2s linear'; setTimeout(function() { widget.style.animation = 'pulse 2s infinite'; }, 2000); }, 10000);