File size: 2,016 Bytes
f0ef107
 
 
 
 
 
 
 
 
 
 
 
 
de3f199
f0ef107
 
 
de3f199
 
 
 
 
 
 
 
 
 
 
f0ef107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42e191f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// app.js - Main application initialization

import { ChatComponent } from './components/chat-component.js';
import { FileUploadComponent } from './components/file-upload-component.js';
import { SettingsComponent } from './components/settings-component.js';
import { LanguageComponent } from './components/language-component.js';
import { ConsentComponent } from './components/consent-component.js';
import { ProfileComponent } from './components/profile-component.js';
import { CommentComponent } from './components/comment-component.js';
import { FeedbackComponent } from './components/feedback-component.js';
import { TranslationService } from './services/translation-service.js';
import { CarbonTracker } from './components/carbon-tracker-component.js';
import { ToolbarComponent } from './components/toolbar-component.js';
import { StateManager } from './services/state-manager.js';

// Initialize the application when DOM is ready
document.addEventListener('DOMContentLoaded', () => {
  // In dev mode, skip the welcome modal and seed dummy profile data
  if (document.getElementById('welcomePopup').style.display === 'none') {
    StateManager.setConsent(true);
    StateManager.updateProfile({
      ageGroup: '25-34',
      gender: 'M',
      roles: ['researcher'],
      participantId: 'dev-user'
    });
  }

  // Initialize all components
  ChatComponent.init();
  FileUploadComponent.init();
  SettingsComponent.init();
  LanguageComponent.init();
  ConsentComponent.init();
  ProfileComponent.init();
  CommentComponent.init();
  FeedbackComponent.init();
  CarbonTracker.init();
  ToolbarComponent.init();

  // Make FeedbackComponent globally accessible for chat component
  window.FeedbackComponent = FeedbackComponent;

  // Apply initial translations
  TranslationService.applyTranslation();

  // Open the details element by default on desktop only
  if (window.innerWidth >= 460) {
    const details = document.querySelector('details');
    if (details) details.setAttribute('open', '');
  }
});