document.addEventListener('DOMContentLoaded', () => { const chatWindow = document.getElementById('chat-window'); const chatInput = document.getElementById('chat-input'); const sendBtn = document.getElementById('send-btn'); const stopBtn = document.getElementById('stop-btn'); const modeItems = document.querySelectorAll('.mode-item'); const currentModeBadge = document.getElementById('current-mode-badge'); const newChatBtn = document.getElementById('new-chat-btn'); const chatHistoryList = document.getElementById('chat-history'); // Settings elements const creativityRange = document.getElementById('creativity-range'); const creativityVal = document.getElementById('creativity-val'); const limitsToggle = document.getElementById('limits-toggle'); const modelSelect = document.getElementById('model-select'); const themeSwatches = document.querySelectorAll('.theme-swatch'); const saveSettingsBtn = document.getElementById('save-settings-btn'); // Share elements const shareModal = new bootstrap.Modal(document.getElementById('shareModal')); const shareUrlInput = document.getElementById('share-url-input'); const copyShareBtn = document.getElementById('copy-share-btn'); const viewSharedLink = document.getElementById('view-shared-link'); let currentMode = 'regular'; let currentChatId = null; let abortController = null; // --- Sidebar & Mode Switching --- modeItems.forEach(item => { item.addEventListener('click', () => { if (item.classList.contains('active')) return; modeItems.forEach(i => i.classList.remove('active')); item.classList.add('active'); currentMode = item.dataset.mode; currentModeBadge.textContent = item.querySelector('span').textContent; startNewChat(); }); }); function startNewChat() { currentChatId = null; chatWindow.innerHTML = "`
How can I help you in this mode?
${escapeHtml(block.code)}