Spaces:
Running
Running
| // Основной скрипт приложения | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Инициализация компонентов | |
| // Обработчик для кнопки AI помощника | |
| const aiSendBtn = document.querySelector('#ai-send-btn'); | |
| const aiInput = document.querySelector('#ai-input'); | |
| if (aiSendBtn && aiInput) { | |
| aiSendBtn.addEventListener('click', sendAIQuestion); | |
| aiInput.addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') sendAIQuestion(); | |
| }); | |
| } | |
| function sendAIQuestion() { | |
| const question = aiInput.value.trim(); | |
| if (question) { | |
| console.log('Отправка вопроса:', question); | |
| // Здесь будет логика отправки запроса к API | |
| aiInput.value = ''; | |
| } | |
| } | |
| // Инициализация табов мест | |
| const initPlaceTabs = () => { | |
| const tabs = document.querySelectorAll('.place-tab'); | |
| const contents = document.querySelectorAll('.place-content'); | |
| tabs.forEach(tab => { | |
| tab.addEventListener('click', () => { | |
| // Удаляем активные классы у всех табов | |
| tabs.forEach(t => t.classList.remove('active')); | |
| contents.forEach(c => c.classList.add('hidden')); | |
| // Добавляем активный класс текущему табу | |
| tab.classList.add('active'); | |
| // Показываем соответствующий контент | |
| const target = tab.getAttribute('data-target'); | |
| document.querySelector(target).classList.remove('hidden'); | |
| }); | |
| }); | |
| }; | |
| initPlaceTabs(); | |
| // Инициализация модальных окон | |
| window.openModal = (modalId) => { | |
| document.getElementById(modalId).classList.remove('hidden'); | |
| document.body.classList.add('overflow-hidden'); | |
| }; | |
| window.closeModal = (modalId) => { | |
| document.getElementById(modalId).classList.add('hidden'); | |
| document.body.classList.remove('overflow-hidden'); | |
| }; | |
| // Закрытие модального окна при клике вне его | |
| document.querySelectorAll('.modal').forEach(modal => { | |
| modal.addEventListener('click', (e) => { | |
| if (e.target === modal) { | |
| closeModal(modal.id); | |
| } | |
| }); | |
| }); | |
| }); | |
| // Темная/светлая тема | |
| function toggleDarkMode() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', html.classList.contains('dark')); | |
| } | |
| // Проверяем сохраненную тему при загрузке | |
| document.addEventListener('DOMContentLoaded', () => { | |
| if (localStorage.getItem('darkMode') === 'false') { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| }); |