Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const sections = {
+ home: document.getElementById('home'),
+ languageSelect: document.getElementById('language-select'),
+ chatInterface: document.getElementById('chat-interface'),
+ onboarding: document.getElementById('onboarding')
+ };
+
+ let selectedLanguage = '';
+ let captionsEnabled = true;
+ let isRecording = false;
+
+ function showSection(sectionId) {
+ Object.values(sections).forEach(section => {
+ section.classList.add('hidden');
+ });
+ sections[sectionId].classList.remove('hidden');
+ }
+
+ window.startPractice = () => {
+ if (!localStorage.getItem('userProfile')) {
+ showSection('onboarding');
+ } else {
+ showSection('languageSelect');
+ }
+ };
+
+ document.querySelectorAll('.lang-btn').forEach(btn => {
+ btn.addEventListener('click', () => {
+ selectedLanguage = btn.dataset.lang;
+ showSection('chatInterface');
+ });
+ });
+
+ document.getElementById('toggleCaption').addEventListener('click', () => {
+ captionsEnabled = !captionsEnabled;
+ // Toggle captions logic here
+ });
+
+ document.getElementById('startRecording').addEventListener('click', () => {
+ if (!isRecording) {
+ isRecording = true;
+ document.getElementById('startRecording').classList.add('hidden');
+ document.getElementById('stopRecording').classList.remove('hidden');
+ // Start recording logic here
+ }
+ });
+
+ document.getElementById('stopRecording').addEventListener('click', () => {
+ if (isRecording) {
+ isRecording = false;
+ document.getElementById('stopRecording').classList.add('hidden');
+ document.getElementById('startRecording').classList.remove('hidden');
+ // Stop recording logic here
+ }
+ });
+
+ document.getElementById('userForm').addEventListener('submit', (e) => {
+ e.preventDefault();
+ const formData = new FormData(e.target);
+ localStorage.setItem('userProfile', JSON.stringify(Object.fromEntries(formData)));
+ showSection('languageSelect');
+ });
+ });