Spaces:
Running
Running
Download index.html from Pep1900/chat-widget-pro: direct link, hf CLI and curl.
- Browser
- Download file 3.93 kB
-
https://huggingface.co/spaces/Pep1900/chat-widget-pro/resolve/main/index.html
- Command line
-
hf download hf://spaces/Pep1900/chat-widget-pro/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Pep1900/chat-widget-pro/resolve/main/index.html
3.93 kB
| <html lang="ru"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Виджет чата</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| </head> | |
| <body> | |
| <!-- Вставьте эту кнопку в нужное место на сайте --> | |
| <button | |
| onclick="launchChatWidget()" | |
| class="flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-gray-500 to-gray-600 text-white font-medium rounded-lg shadow-lg hover:shadow-xl hover:from-gray-600 hover:to-gray-700 transform hover:-translate-y-0.5 transition-all duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-opacity-50" | |
| > | |
| <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> | |
| <path fill-rule="evenodd" d="M18 5v8a2 2 0 01-2 2h-5l-5 4v-4H4a2 2 0 01-2-2V5a2 2 0 012-2h12a2 2 0 012 2zM7 8H5v2h2V8zm2 0h2v2H9V8zm6 0h-2v2h2V8z" clip-rule="evenodd" /> | |
| </svg> | |
| Chat | |
| </button> | |
| <script> | |
| let chatWindow = null; | |
| function launchChatWidget() { | |
| // ЗАМЕНИТЕ НА РЕАЛЬНЫЙ URL ВАШЕГО ВИДЖЕТА-ОБЕРТКИ | |
| const widgetUrl = 'widget.html'; | |
| // Проверяем существует ли окно и не закрыто ли оно | |
| if (chatWindow && !chatWindow.closed) { | |
| // Окно уже открыто - переводим фокус | |
| chatWindow.focus(); | |
| } else { | |
| // Проверяем мобильное устройство | |
| const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768; | |
| if (isMobile) { | |
| // На мобильных открываем в полном окне | |
| chatWindow = window.open( | |
| widgetUrl, | |
| 'ChatWidgetWindow', | |
| 'width=' + window.screen.availWidth + ',height=' + window.screen.availHeight + ',left=0,top=0,scrollbars=no,resizable=no,fullscreen=yes' | |
| ); | |
| } else { | |
| // Получаем размеры экрана для desktop | |
| const screenWidth = window.screen.availWidth; | |
| const screenHeight = window.screen.availHeight; | |
| // Параметры окна | |
| const windowWidth = 420; | |
| const windowHeight = Math.floor(screenHeight * 0.9); // 90% от высоты экрана | |
| const leftPosition = screenWidth - windowWidth - 20; // Прижимаем к правому краю | |
| const topPosition = Math.floor(screenHeight * 0.05); // Небольшой отступ сверху | |
| // Открываем новое окно | |
| chatWindow = window.open( | |
| widgetUrl, | |
| 'ChatWidgetWindow', | |
| `width=${windowWidth},height=${windowHeight},left=${leftPosition},top=${topPosition},scrollbars=no,resizable=yes` | |
| ); | |
| } | |
| // Обработчик на случай, если пользователь закроет окно вручную | |
| if (chatWindow) { | |
| chatWindow.onbeforeunload = function() { | |
| chatWindow = null; | |
| } | |
| } | |
| } | |
| } | |
| // Дополнительно: закрываем окно при закрытии страницы | |
| window.addEventListener('beforeunload', function() { | |
| if (chatWindow && !chatWindow.closed) { | |
| chatWindow.close(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |