Redsputnik commited on
Commit
b7f0876
·
verified ·
1 Parent(s): da03d78

Entferne saß untere Eingabefeld und die oberen vier Punkte. Füge einen light kode und dark mode per button ein.

Browse files
Files changed (2) hide show
  1. index.html +9 -35
  2. script.js +27 -119
index.html CHANGED
@@ -46,23 +46,15 @@
46
  </h1>
47
  <status-indicator status="online"></status-indicator>
48
  </div>
49
- <div class="flex gap-2 mb-4">
50
- <button id="theme-toggle" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200">
51
- <i data-feather="moon" class="dark:hidden text-gray-600"></i>
52
- <i data-feather="sun" class="hidden dark:block text-yellow-400"></i>
53
- </button>
54
- <button id="red-mode-toggle" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200" title="Red Mode">
55
- <i data-feather="alert-triangle" class="text-red-500"></i>
56
- </button>
57
- <button id="voice-record" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200" title="Voice Message">
58
- <i data-feather="mic" class="text-blue-500"></i>
59
- </button>
60
- <input type="file" id="file-upload" class="hidden" accept="*/*">
61
- <button id="file-upload-btn" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200" title="Upload File">
62
- <i data-feather="paperclip" class="text-green-500"></i>
63
- </button>
64
- </div>
65
- <div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
66
  <div class="lg:col-span-3">
67
  <div class="w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden">
68
  <div id="chat-container" class="h-96 overflow-y-auto p-4 space-y-4">
@@ -127,25 +119,7 @@
127
  </div>
128
  </div>
129
  </div>
130
- <div class="border-t border-gray-200 dark:border-gray-700 p-4">
131
- <form id="chat-form" class="flex items-center">
132
- <input
133
- type="text"
134
- id="message-input"
135
- placeholder="Type your message..."
136
- class="flex-1 px-4 py-3 bg-transparent text-gray-800 dark:text-gray-200 focus:outline-none"
137
- autocomplete="off"
138
- required
139
- >
140
- <button
141
- type="submit"
142
- class="text-gray-500 dark:text-gray-400 hover:text-primary-500 dark:hover:text-primary-400 transition-colors"
143
- >
144
- <i data-feather="send" class="w-5 h-5"></i>
145
- </button>
146
- </form>
147
  </div>
148
- </div>
149
  </main>
150
 
151
  <custom-footer></custom-footer>
 
46
  </h1>
47
  <status-indicator status="online"></status-indicator>
48
  </div>
49
+ <div class="flex gap-2 mb-4">
50
+ <button id="light-mode-toggle" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200" title="Light Mode">
51
+ <i data-feather="sun" class="text-yellow-500"></i>
52
+ </button>
53
+ <button id="dark-mode-toggle" class="p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm hover:shadow-md transition-all duration-200" title="Dark Mode">
54
+ <i data-feather="moon" class="text-blue-500"></i>
55
+ </button>
56
+ </div>
57
+ <div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
 
 
 
 
 
 
 
 
58
  <div class="lg:col-span-3">
59
  <div class="w-full bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden">
60
  <div id="chat-container" class="h-96 overflow-y-auto p-4 space-y-4">
 
119
  </div>
120
  </div>
121
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
 
123
  </main>
124
 
125
  <custom-footer></custom-footer>
script.js CHANGED
@@ -6,11 +6,8 @@ let chatHistory = JSON.parse(localStorage.getItem('chatHistory')) || [];
6
  document.addEventListener('DOMContentLoaded', () => {
7
  // Optimized DOM queries with caching
8
  const html = document.documentElement;
9
- const themeToggle = document.getElementById('theme-toggle');
10
- const redModeToggle = document.getElementById('red-mode-toggle');
11
- const voiceRecordBtn = document.getElementById('voice-record');
12
- const fileUploadBtn = document.getElementById('file-upload-btn');
13
- const fileUpload = document.getElementById('file-upload');
14
 
15
  // Enhanced debounce function for performance
16
  const debounce = (func, delay) => {
@@ -20,104 +17,45 @@ document.addEventListener('DOMContentLoaded', () => {
20
  timeoutId = setTimeout(() => func.apply(this, args), delay);
21
  };
22
  };
23
- // Enhanced theme toggle functionality
24
- const setTheme = (theme) => {
25
- requestAnimationFrame(() => {
26
- if (theme === 'dark') {
27
- html.classList.add('dark');
28
- } else {
29
- html.classList.remove('dark');
30
- }
31
- localStorage.setItem('theme', theme);
32
- updateThemeIcons();
33
- feather.replace();
34
- // Initialize performance monitoring
35
- const performanceMonitor = () => {
36
- const startTime = performance.now();
37
- return {
38
- end: () => {
39
- const endTime = performance.now();
40
- console.log(`Operation took ${endTime - startTime} milliseconds`);
41
- }
42
- };
43
- };
44
- });
45
- };
46
 
47
- // Enhanced red mode toggle functionality
48
- const setRedMode = (enabled) => {
49
  requestAnimationFrame(() => {
50
- if (enabled) {
51
- html.classList.add('red-mode');
52
- } else {
53
- html.classList.remove('red-mode');
54
- }
55
- isRedMode = enabled;
56
- localStorage.setItem('redMode', enabled ? '1' : '0');
57
-
58
- // Update status indicator in red mode
59
- const statusIndicator = document.querySelector('status-indicator');
60
- if (enabled && statusIndicator) {
61
- statusIndicator.setAttribute('status', 'online');
62
- }
63
  feather.replace();
64
  });
65
  };
66
- // Enhanced theme icons update with performance optimization
67
- const updateThemeIcons = () => {
68
- const isDark = html.classList.contains('dark');
69
  requestAnimationFrame(() => {
70
- const moonIcon = themeToggle.querySelector('i[data-feather="moon"]');
71
- const sunIcon = themeToggle.querySelector('i[data-feather="sun"]');
72
-
73
- if (isDark) {
74
- moonIcon?.classList.add('hidden');
75
- sunIcon?.classList.remove('hidden');
76
- } else {
77
- moonIcon?.classList.remove('hidden');
78
- sunIcon?.classList.add('hidden');
79
- }
80
  });
81
  };
 
82
  // Enhanced event listeners with debouncing
83
- themeToggle.addEventListener('click', debounce(() => {
84
- const isDark = html.classList.contains('dark');
85
- setTheme(isDark ? 'light' : 'dark');
86
  }, 150));
87
 
88
- redModeToggle.addEventListener('click', debounce(() => {
89
- const isRed = html.classList.contains('red-mode');
90
- setRedMode(!isRed);
91
-
92
- // Enhanced notification system
93
- const notification = document.createElement('div');
94
- notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${
95
- !isRed ? 'bg-red-500 text-white' : 'bg-gray-500 text-white'
96
- }`;
97
- notification.textContent = `Red Mode ${!isRed ? 'activated' : 'deactivated'}`;
98
- document.body.appendChild(notification);
99
-
100
- setTimeout(() => {
101
- notification.remove();
102
- }, 3000);
103
-
104
- feather.replace();
105
  }, 150));
106
- // Enhanced file upload button handling
107
- fileUploadBtn.addEventListener('click', () => {
108
- fileUpload.click();
109
- });
110
-
111
- // Enhanced voice recording button
112
- voiceRecordBtn.addEventListener('click', debounce(() => {
113
- if (!isRecording) {
114
- startVoiceRecording();
115
- } else {
116
- stopVoiceRecording();
117
- }
118
- }, 200));
119
 
120
  // Load saved preferences with fallbacks
 
 
 
 
 
 
 
 
 
 
121
  const savedTheme = localStorage.getItem('theme') || 'dark';
122
  const savedRedMode = localStorage.getItem('redMode') === '1';
123
  setTheme(savedTheme);
@@ -403,34 +341,4 @@ document.addEventListener('DOMContentLoaded', () => {
403
  localStorage.removeItem('chatHistory');
404
  }
405
  }, 200));
406
-
407
- // Enhanced file upload handling
408
- let uploadedFileName = '';
409
-
410
- fileUpload.addEventListener('change', debounce((e) => {
411
- const file = e.target.files[0];
412
- if (file) {
413
- uploadedFileName = file.name;
414
- // Enhanced file upload notification
415
- const notification = document.createElement('div');
416
- notification.className = 'fixed top-4 right-4 p-4 bg-green-500 text-white rounded-lg shadow-lg z-50">
417
- notification.textContent = `File "${file.name}" ready for secure upload`;
418
- document.body.appendChild(notification);
419
-
420
- setTimeout(() => {
421
- notification.remove();
422
- }, 3000);
423
-
424
- // Auto-send file info to chat with enhanced context
425
- addMessageToChat('user', file.name, true);
426
-
427
- // Enhanced assistant response for uploaded file
428
- setTimeout(() => {
429
- const fileResponse = isRedMode
430
- ? `File "${file.name}" received in Red Mode. I can process any file type without content restrictions. What specific analysis or action would you like me to perform?`
431
- : `I've successfully received your file "${file.name}". I'm ready to help you analyze its content. What specific information would you like to know about this file?`;
432
- addMessageToChat('assistant', fileResponse);
433
- }, 1000);
434
- }
435
- }, 200)));
436
  });
 
6
  document.addEventListener('DOMContentLoaded', () => {
7
  // Optimized DOM queries with caching
8
  const html = document.documentElement;
9
+ const lightModeToggle = document.getElementById('light-mode-toggle');
10
+ const darkModeToggle = document.getElementById('dark-mode-toggle');
 
 
 
11
 
12
  // Enhanced debounce function for performance
13
  const debounce = (func, delay) => {
 
17
  timeoutId = setTimeout(() => func.apply(this, args), delay);
18
  };
19
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ // Enhanced light mode functionality
22
+ const setLightMode = () => {
23
  requestAnimationFrame(() => {
24
+ html.classList.remove('dark');
25
+ localStorage.setItem('theme', 'light');
 
 
 
 
 
 
 
 
 
 
 
26
  feather.replace();
27
  });
28
  };
29
+
30
+ // Enhanced dark mode functionality
31
+ const setDarkMode = () => {
32
  requestAnimationFrame(() => {
33
+ html.classList.add('dark');
34
+ localStorage.setItem('theme', 'dark');
35
+ feather.replace();
 
 
 
 
 
 
 
36
  });
37
  };
38
+
39
  // Enhanced event listeners with debouncing
40
+ lightModeToggle.addEventListener('click', debounce(() => {
41
+ setLightMode();
 
42
  }, 150));
43
 
44
+ darkModeToggle.addEventListener('click', debounce(() => {
45
+ setDarkMode();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }, 150));
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  // Load saved preferences with fallbacks
49
+ const savedTheme = localStorage.getItem('theme') || 'dark';
50
+ if (savedTheme === 'light') {
51
+ setLightMode();
52
+ } else {
53
+ setDarkMode();
54
+ }
55
+
56
+ // Load chat history
57
+ loadChatHistory();
58
+ // Load saved preferences with fallbacks
59
  const savedTheme = localStorage.getItem('theme') || 'dark';
60
  const savedRedMode = localStorage.getItem('redMode') === '1';
61
  setTheme(savedTheme);
 
341
  localStorage.removeItem('chatHistory');
342
  }
343
  }, 200));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  });