-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStefdevassistantapp
More file actions
780 lines (673 loc) · 27.5 KB
/
Stefdevassistantapp
File metadata and controls
780 lines (673 loc) · 27.5 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dev Assistant App @</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(to bottom, #8f8e5e, #2c332c);
color: #cddc39;
text-shadow: 0.5px 0.5px 1px #7a5565;
padding: 20px;
}
textarea {
width: 100%;
height: 100px;
font-size: 16px;
padding: 10px;
border-radius: 8px;
border: none;
color: #ffffff;
text-shadow: 0.5px 0.5px 1px #7a5565;
background: linear-gradient(to bottom, #4b5747, #2c332c);
box-shadow: 1px 1px 4px 2px rgba(227, 251, 207, 0.90);
}
button {
padding: 10px 15px;
font-size: 16px;
margin: 8px;
border-radius: 8px;
border: none;
cursor: pointer;
color: #ffffff;
text-shadow: 0.5px 0.5px 1.3px #385843;
background: linear-gradient(to bottom,#252516, #000000);
box-shadow: 1px 1px 4px 2px rgba(152, 156, 133, 0.79);
}
#chatBox {
padding: 15px;
background: #2a2a2a;
border-radius: 10px;
white-space: pre-wrap;
text-shadow: 0.5px 0.5px 1px #7a5565;
box-shadow: 1px 1px 4px 2px rgba(227, 231, 207, 0.79);
max-height: 400px;
overflow-y: auto;
margin-bottom: 10px;
color: #ffffff;
}
.message {
margin-bottom: 10px;
}
.user {
color: #ffffff;
}
.assistant {
color: #ffffff;
}
#privateIndicator {
animation: blink 1s infinite;
color: #ffea00;
font-weight: bold;
font-size: 16px;
text-align: center;
margin-top: 10px;
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0.1; }
100% { opacity: 1; }
}
@keyframes fadeSlideOut {
0% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-30px); }
}
@keyframes fadeSlideIn {
0% { opacity: 0; transform: translateY(30px); }
100% { opacity: 1; transform: translateY(0); }
}
.fade-out {
animation: fadeSlideOut 0.5s forwards;
}
.fade-in {
animation: fadeSlideIn 0.5s forwards;
}
body.day-theme {
background-color: #fef8e7; /* Много светъл крем */
color: color: #ffffff;; /* Тъмен текст */
}
body.night-theme {
background-color: #0b0c1a; /* Почти черен */
color: color: #ffffff;; /* Златист текст */
}
body.sun-theme {
background-color: #ffffff; /* Абсолютно бяло */
color: #000000; /* Абсолютно черно */
font-weight: bold;
text-shadow:
0 0 4px #fff,
0 0 8px #ffd700,
1px 1px 0 #000;
}
#themeToggleBtn {
padding: 10px 16px;
background: #444;
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
cursor: pointer;
margin: 10px;
}
#themeToggleBtn:hover {
background: #666;
}
body {
transition: background-color 0.5s ease, color 0.5s ease;
/* Общ стил за всички бутони */
button {
padding: 10px 16px;
border: none;
border-radius: 8px;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s ease;
}
/* Дневен режим */
body.day-theme button {
background-color: #f0e6d2;
color: #222;
border: 2px solid #ccc;
}
/* Нощен режим */
body.night-theme button {
background-color: #222;
color: #ffd700;
border: 2px solid #444;
}
/* Слънчев режим */
body.sun-theme button {
background-color: #fff;
color: #000;
border: 2px solid #000;
font-weight: bold;
text-shadow: 0 0 2px #ffd700, 0 0 4px #fff;
}
body.sun-theme .speak-btn {
background-color: #fff;
color: #000;
border: 2px solid #000;
}
</style>
</head>
<body>
<h1 style="color: gold;">🚀 Dev Assistant App @ 💼 🕵️♂️ 🎙 🔊 🤖 🧑⚖️🛑 ⏳ 💬</h1>
<div style="display: flex; justify-content: center; align-items: flex-start; gap: 170px; margin-top: 30px; flex-wrap: wrap;">
<!-- 📝 ОПИСАНИЕ ОТЛЯВО НА ВИДЕОТО -->
<div style="flex: 1 1 420px; max-width: 480px; color: #ffffff;">
<h3>🔍 About Dev Assistant App</h3>
<p>This app is your personal AI assistant – voice-enabled and context-aware. Here's what the main buttons do:</p>
<ul>
<li><strong>🎙️ Speak Question</strong>: Activates your device microphone and transcribes your question in real-time.</li>
<li><strong>🤖 Get Answer</strong>: Sends your text or spoken question to GPT-4o and returns a smart reply.</li>
<li><strong>🔊 Speak Answer</strong>: Speaks out the assistant's last response aloud.</li>
<li><strong>🛑 Stop Voice</strong>: Instantly stops all ongoing speech playback.</li>
<li><strong>🔇 Silent Mode</strong>: Mutes all spoken output until toggled back.</li>
<li><strong>🧑⚖️ Private Mode</strong>: Temporarily disables saving/viewing chat and auto-clears history for privacy.</li>
<li><strong>🧹 Clear Chat</strong>: Clears the chat window and resets the assistant's context.</li>
<li><strong>💾 Save Chat History</strong>: Saves the entire conversation locally on your device as text.</li>
<li><strong>🗂 View Saved History</strong>: Displays your last saved conversation from local storage.</li>
<li><strong>☀️/🌙/⚡ Theme</strong>: Cycles between Day, Night, and Sunlight themes for better visibility.</li>
</ul>
<p style="margin-top: 20px; font-style: italic; color: #ffffff;">Ideal for multitaskers, professionals, or anyone who wants a powerful, voice-friendly assistant right in their browser.</p>
</div>
<!-- ВИДЕО ДЯСНО -->
<video id="visionVideo" autoplay muted playsinline style="margin-top: 80px;width: 100%; max-width: 600px; border-radius: 12px; box-shadow: 0 0 12px #ffd700;">
<source src="https://devcodeapp.site/wp-content/uploads/2025/05/20250519_1249_Digital-Visionary-Moment_simple_compose_01jvkz4s0hfa88adbp670wrnrp.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
<!-- 🔁 Бутон за повторно пускане под видеото -->
<div style="text-align: center;">
<button id="replayBtn" onclick="replayVideo()" style="display: none; margin-bottom: 60px; margin-left: 300px; padding: 8px 16px; background: #ffd700; color: #1e1e1e; border: none; border-radius: 8px; font-weight: bold; box-shadow: 0 0 8px #ffae00; cursor: pointer;">
▶️ Play Again
</button>
</div>
<div id="privateIndicator" style="display: none;">🕵️♂️ PRIVATE MODE ACTIVE</div>
<select id="roleSelector" onchange="updatePersona()">
<option value="default">🧠 Default Assistant</option>
<option value="hustle">💼 Side Hustle Coach😎</option>
<option value="therapist">🧘 Therapist</option>
<option value="medic">🧑⚕️ Medical Assistant</option>
<option value="teacher">📚 Tutor</option>
<option value="dev">💻 Developer Assistant</option>
</select>
<textarea id="prompt" placeholder="Type or speak your question..."></textarea><br>
<div id="chatBox"></div>
<button id="themeToggleBtn">☀️ Theme: Day</button>
<!-- 🌍 Избор на език (под бутона) -->
<div style="margin-top: 8px;">
<label for="voiceLang" style="font-weight: bold;">🌍 Voice Language:</label><br>
<select id="voiceLang" style="margin-top: 4px; padding: 6px 10px; border-radius: 6px;">
<option value="auto">🌐 Auto Detect</option>
<option value="bg-BG">🇧🇬 Bulgarian</option>
<option value="cs-CZ">🇨🇿 Czech</option>
<option value="da-DK">🇩🇰 Danish</option>
<option value="de-DE">🇩🇪 German</option>
<option value="el-GR">🇬🇷 Greek</option>
<option value="en-GB">🇬🇧 English (UK)</option>
<option value="en-US">🇺🇸 English (US)</option>
<option value="es-ES">🇪🇸 Spanish</option>
<option value="et-EE">🇪🇪 Estonian</option>
<option value="fi-FI">🇫🇮 Finnish</option>
<option value="fr-FR">🇫🇷 French</option>
<option value="ga-IE">🇮🇪 Irish</option>
<option value="hr-HR">🇭🇷 Croatian</option>
<option value="hu-HU">🇭🇺 Hungarian</option>
<option value="it-IT">🇮🇹 Italian</option>
<option value="lt-LT">🇱🇹 Lithuanian</option>
<option value="lv-LV">🇱🇻 Latvian</option>
<option value="mt-MT">🇲🇹 Maltese</option>
<option value="nl-NL">🇳🇱 Dutch</option>
<option value="pl-PL">🇵🇱 Polish</option>
<option value="pt-PT">🇵🇹 Portuguese</option>
<option value="ro-RO">🇷🇴 Romanian</option>
<option value="sk-SK">🇸🇰 Slovak</option>
<option value="sl-SI">🇸🇮 Slovenian</option>
<option value="sv-SE">🇸🇪 Swedish</option>
<option value="ru-RU">🇷🇺 Russian</option>
<option value="tr-TR">🇹🇷 Turkish</option>
<option value="ar-SA">🇸🇦 Arabic</option>
<option value="zh-CN">🇨🇳 Chinese (Mandarin)</option>
</select>
</div>
<!-- Показване на текущия език -->
<div id="currentLangDisplay" style="margin: 6px 0; font-weight: bold; color: #ffd700;">
🗣️ Language in use: English (US)
</div>
<button onclick="startNewTopic()">🆕 Start New Topic! 💥
Type your question above 🚀 Use the down buttons. </button>
<button id="themeToggleBtn">☀️ Theme: Day</button>
<button onclick="startListening()">🎙️ Speak Question</button>
<button onclick="sendPrompt()">🤖 Get Answer</button>
<button onclick="speakAnswer()">🔊 Speak Answer</button>
<button onclick="stopSpeaking()">🛑 Stop Voice</button>
<button id="silentBtn" onclick="toggleSilentMode()">🔇 Silent Mode: OFF</button>
<button id="privateBtn" onclick="togglePrivateMode()">🧑⚖️ Private Mode: OFF</button>
<button onclick="clearChat()">🧹 Clear Chat</button>
<button id="saveBtn" onclick="saveChat()">💾 Save Chat History</button>
<button id="viewBtn" onclick="viewHistory()">🗂 View Saved History</button>
<div id="autoClearBar" style="display: none; height: 8px; background: gold; border-radius: 5px; margin-top: 10px;"></div>
<button id="cancelClearBtn" onclick="cancelAutoClear()" style="display: none; margin-top: 5px;">🧯 Cancel Auto-Clear</button>
<!-- Add this inside the <body> of your assistant_test.html page -->
<button onclick="showUsageChart()">📈 View Usage Chart</button>
<canvas id="usageChart" style="max-width: 600px; margin: 30px auto; display: none;"></canvas>
<h3>🔐 Admin Login</h3>
<input id="username" type="text" placeholder="adminSTEF" style="padding: 5px;" />
<input id="password" type="password" placeholder="VetomEmka21$$$" style="padding: 5px;" />
<button onclick="loginToProxy()">🔑 Login</button>
<button onclick="showLogs()">📜 View Logs (last 100)</button>
<pre id="logsDisplay" style="display:none; background:#000; color:#0f0; padding:10px; max-height:300px; overflow:auto; font-size: 0.8rem;"></pre>
<h2>💥 🎯 📣 🖼 🎥 ✨🛑🕵️ 💾🧠📤 🔐 💼🧠🧑 🚀</h2>
<h2 style="color: gold;">© 2025. Made by Stefan Spasov. All Rights Reserved.🔥 🫡 👑</h2>
<script>
document.addEventListener("DOMContentLoaded", () => {
const video = document.getElementById("visionVideo");
const replayBtn = document.getElementById("replayBtn");
// Показваме бутона за повторно пускане, когато видеото приключи
video.addEventListener("ended", () => {
replayBtn.style.display = "inline-block";
});
// Скриваме бутона и пускаме видеото отначало при натискане
window.replayVideo = function () {
video.currentTime = 0;
video.play();
replayBtn.style.display = "none";
};
});
</script>
<script>
let speakingUtterance = null;
let silentMode = false;
let privateMode = false;
let systemMessage = "You are a helpful assistant.";
let conversation = [{ role: "system", content: systemMessage }];
let autoClearTimer = null;
const autoClearDuration = 15000;
function updatePersona() {
const role = document.getElementById('roleSelector').value;
switch (role) {
case 'hustle': systemMessage = "You are a brilliant Side Hustle Coach..."; break;
case 'therapist': systemMessage = "You are a calm, understanding therapist..."; break;
case 'medic': systemMessage = "You are a responsible medical assistant..."; break;
case 'teacher': systemMessage = "You are a patient and funny tutor..."; break;
case 'dev': systemMessage = "You are a highly experienced software developer..."; break;
default: systemMessage = "You are a helpful assistant.";
}
conversation = [{ role: "system", content: systemMessage }];
document.getElementById('chatBox').innerHTML = '';
}
function startListening() {
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
const selectedLang = document.getElementById('voiceLang').value;
recognition.lang = selectedLang === 'auto' ? 'en-US' : selectedLang;
recognition.start();
recognition.onresult = e => document.getElementById('prompt').value = e.results[0][0].transcript;
recognition.onerror = e => alert('Voice input error: ' + e.error);
}
function stopSpeaking() {
if (speechSynthesis.speaking) speechSynthesis.cancel();
}
function detectLanguage(text) {
const cyrillic = /[а-яА-ЯёЁ]/;
const chinese = /[\u4e00-\u9fff]/;
const arabic = /[\u0600-\u06FF]/;
const turkish = /[ğüşöçıİĞÜŞÖÇ]/i;
if (chinese.test(text)) return 'zh-CN';
if (arabic.test(text)) return 'ar-SA';
if (cyrillic.test(text)) return 'ru-RU'; // default for Cyrillic (can be bg-BG manually)
if (turkish.test(text)) return 'tr-TR';
return 'en-US'; // fallback
}
function detectLanguage(text) {
const cyrillic = /[а-яА-ЯёЁ]/;
const chinese = /[\u4e00-\u9fff]/;
const arabic = /[\u0600-\u06FF]/;
const turkish = /[ğüşöçıİĞÜŞÖÇ]/i;
if (chinese.test(text)) return { code: 'zh-CN', label: 'Chinese' };
if (arabic.test(text)) return { code: 'ar-SA', label: 'Arabic' };
if (cyrillic.test(text)) return { code: 'ru-RU', label: 'Russian/Bulgarian' };
if (turkish.test(text)) return { code: 'tr-TR', label: 'Turkish' };
return { code: 'en-US', label: 'English' };
}
function speakAnswer() {
if (silentMode) return;
const last = conversation.filter(m => m.role === 'assistant').pop();
if (!last) return;
const langSelect = document.getElementById('voiceLang').value;
let langCode = langSelect;
let langLabel = document.querySelector(`#voiceLang option[value="${langSelect}"]`)?.textContent || 'English';
if (langSelect === 'auto') {
const detected = detectLanguage(last.content);
langCode = detected.code;
langLabel = Auto: ${detected.label};
}
// Покажи езика
document.getElementById('currentLangDisplay').textContent = 🗣️ Language in use: ${langLabel};
// Говори
const utterance = new SpeechSynthesisUtterance(last.content);
utterance.lang = langCode;
speechSynthesis.speak(utterance);
}
function toggleSilentMode() {
silentMode = !silentMode;
document.getElementById('silentBtn').textContent = silentMode ? '🔈 Silent Mode: ON' : '🔇 Silent Mode: OFF';
}
function togglePrivateMode() {
privateMode = !privateMode;
document.getElementById('privateBtn').textContent = privateMode ? '🕵️ Private Mode: ON' : '🧑⚖️ Private Mode: OFF';
document.getElementById('privateIndicator').style.display = privateMode ? 'block' : 'none';
document.getElementById('saveBtn').style.display = privateMode ? 'none' : 'inline-block';
document.getElementById('viewBtn').style.display = privateMode ? 'none' : 'inline-block';
if (privateMode) clearChat();
}
let conversation = [{ role: "system", content: "You are a helpful assistant." }];
function sendPrompt() {
const userInput = document.getElementById('prompt').value.trim();
if (!userInput) return;
document.getElementById('prompt').value = '';
const chatBox = document.getElementById('chatBox');
conversation.push({ role: 'user', content: userInput });
chatBox.innerHTML += `<div class='message user'>🟡 You: ${userInput}</div>`;
console.log("🧠 Sending prompt:", conversation);
fetch('https://proxy-shield-ai.onrender.com/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: conversation, model: 'gpt-4' })
})
.then(res => res.json())
.then(data => {
const reply = data.choices[0].message.content;
console.log("🟢 Assistant replied:", reply);
conversation.push({ role: 'assistant', content: reply });
chatBox.innerHTML += `<div class='message assistant'>🔵 Assistant: ${reply}</div>`;
chatBox.scrollTop = chatBox.scrollHeight;
})
.catch(err => {
console.error("❌ API error:", err);
chatBox.innerHTML += `<div class='message assistant'>⚠️ Error: ${err.message}</div>`;
});
}
function clearChat() {
conversation = [{ role: "system", content: systemMessage }];
document.getElementById('chatBox').innerHTML = '';
document.getElementById('prompt').value = '';
}
function saveChat() {
const saved = conversation.map(entry => ${entry.role.toUpperCase()}:\n${entry.content}).join('\n\n');
const blob = new Blob([saved], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'chat_history.txt';
a.click();
URL.revokeObjectURL(url);
localStorage.setItem('dev_assistant_history', saved);
}
function viewHistory() {
const history = localStorage.getItem('dev_assistant_history') || "📭 No saved history found.";
alert(history);
}
function startAutoClearTimer() {
const bar = document.getElementById('autoClearBar');
const cancelBtn = document.getElementById('cancelClearBtn');
bar.style.display = 'block';
cancelBtn.style.display = 'inline-block';
bar.style.width = '100%';
let width = 100;
const interval = 100;
const step = (interval / autoClearDuration) * 100;
autoClearTimer = setInterval(() => {
width -= step;
if (width <= 0) {
clearInterval(autoClearTimer);
autoClearTimer = null;
bar.style.display = 'none';
cancelBtn.style.display = 'none';
clearChat();
} else {
bar.style.width = width + '%';
}
}, interval);
}
function cancelAutoClear() {
clearInterval(autoClearTimer);
autoClearTimer = null;
document.getElementById('autoClearBar').style.display = 'none';
document.getElementById('cancelClearBtn').style.display = 'none';
}
function startNewTopic() {
if (confirm("Start a new topic? Your current conversation will be cleared.")) {
conversation = [{ role: "system", content: systemMessage }];
document.getElementById('chatBox').innerHTML = '';
document.getElementById('prompt').value = '';
console.log("🧠 New topic started");
}
}
function startNewTopic() {
if (confirm("Start a new topic? Your current conversation will be cleared.")) {
const chatBox = document.getElementById('chatBox');
// Стартира изчезване
chatBox.classList.add('fade-out');
setTimeout(() => {
// След изчезване – нулира
conversation = [{ role: "system", content: systemMessage }];
chatBox.innerHTML = '<div style="color:gold;">💬 New topic started.💻✨</div>';
document.getElementById('prompt').value = '';
// Приложи анимация за поява
chatBox.classList.remove('fade-out');
chatBox.classList.add('fade-in');
// След края на анимацията – махни класа
setTimeout(() => chatBox.classList.remove('fade-in'), 500);
}, 500);
}
}
</script>
<script>
let currentTheme = 0; // 0 = day, 1 = night, 2 = sunlight
function updateTheme() {
const body = document.body;
const button = document.getElementById('themeToggleBtn');
body.classList.remove('day-theme', 'night-theme', 'sun-theme');
if (currentTheme === 0) {
body.classList.add('day-theme');
button.textContent = "☀️ Current Theme: Day";
} else if (currentTheme === 1) {
body.classList.add('night-theme');
button.textContent = "🌙 Current Theme: Night";
} else {
body.classList.add('sun-theme');
button.textContent = "⚡ Current Theme: Sunlight";
}
}
document.getElementById('themeToggleBtn').addEventListener('click', () => {
currentTheme = (currentTheme + 1) % 3;
updateTheme();
});
// стартира със "day" по подразбиране
updateTheme();
function updateTheme() {
const body = document.body;
const button = document.getElementById('themeToggleBtn');
const label = document.getElementById('currentThemeLabel');
body.classList.remove('day-theme', 'night-theme', 'sun-theme');
if (currentTheme === 0) {
body.classList.add('day-theme');
body.setAttribute('data-theme', 'day');
button.textContent = "☀️ Current Theme: Day";
label.textContent = "Theme: Day";
} else if (currentTheme === 1) {
body.classList.add('night-theme');
body.setAttribute('data-theme', 'night');
button.textContent = "🌙 Current Theme: Night";
label.textContent = "Theme: Night";
} else {
body.classList.add('sun-theme');
body.setAttribute('data-theme', 'sun');
button.textContent = "⚡ Current Theme: Sunlight";
label.textContent = "Theme: Sunlight";
}
}
</script>
<style>
#welcomeOverlay {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(0,0,0,0.85);
color: gold;
font-size: 24px;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
z-index: 99999;
text-align: center;
padding: 20px;
animation: fadeIn 0.8s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: scale(0.8); }
to { opacity: 1; transform: scale(1); }
}
</style>
<!-- 🌟 Welcome Overlay с видео и аватар -->
<div id="welcomeOverlay" style="
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.9);
color: #ffd700;
font-size: 1.4em;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 9999;
text-align: center;
font-family: 'Segoe UI', sans-serif;
padding: 20px;
">
<!-- 🎥 Видео фон или секция -->
<video autoplay muted loop playsinline style="width: 100%; max-width: 600px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 0 12px #ffd700;">
<source src="https://devcodeapp.site/wp-content/uploads/2025/05/20250519_1240_Future-AI-Vision_simple_compose_01jvkymf94f7hacry6d2et21kz.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
<!-- 🧠 Текст -->
👋 Welcome to 🔵 <span style="color:#fff;">Stefan’s Private AI Assistant</span>!<br>
🚀 <span style="color:#fff;">Powered by GPT-4o, voice-enabled, and built for smart humans.</span><br>
<small style="color: #aaa; font-size: 1.3rem;">Click anywhere, open Dev Assistant App @ 🕵️♂️ </small>
<!-- 🎥 Видео фон или секция -->
<video autoplay muted loop playsinline style="width: 100%; max-width: 600px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 0 12px #ffd700;">
<source src="https://devcodeapp.site/wp-content/uploads/2025/05/20250519_1249_Digital-Visionary-Moment_simple_compose_01jvkz4s0me8cs3yvaqjx7tcc1.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const overlay = document.getElementById("welcomeOverlay");
// 🗣️ Гласово съобщение
const utter = new SpeechSynthesisUtterance("Welcome to Stefan's Private AI Assistant.");
utter.lang = 'en-US';
utter.pitch = 1.1;
utter.rate = 1;
speechSynthesis.speak(utter);
// ⏳ Скриване след 6 секунди или при клик
setTimeout(() => {
overlay.style.display = "none";
}, 7000);
overlay.addEventListener("click", () => {
overlay.style.display = "none";
});
});
</script>
<script>
function detectLanguage(text) {
const cyrillic = /[а-яА-ЯёЁ]/;
const chinese = /[\u4e00-\u9fff]/;
const arabic = /[\u0600-\u06FF]/;
const turkish = /[ğüşöçıİĞÜŞÖÇ]/i;
if (chinese.test(text)) return { code: 'zh-CN', label: 'Chinese' };
if (arabic.test(text)) return { code: 'ar-SA', label: 'Arabic' };
if (cyrillic.test(text)) return { code: 'ru-RU', label: 'Russian/Bulgarian' };
if (turkish.test(text)) return { code: 'tr-TR', label: 'Turkish' };
return { code: 'en-US', label: 'English' };
}
function speakAnswer() {
if (silentMode) return;
const last = conversation.filter(m => m.role === 'assistant').pop();
if (!last) {
alert("⚠️ No assistant message available to speak.");
return;
}
const langSelect = document.getElementById('voiceLang').value;
let langCode = langSelect;
let langLabel = document.querySelector(#voiceLang option[value="${langSelect}"])?.textContent || 'English';
if (langSelect === 'auto') {
const detected = detectLanguage(last.content);
langCode = detected.code;
langLabel = Auto: ${detected.label};
}
document.getElementById('currentLangDisplay').textContent = 🗣️ Language in use: ${langLabel};
const utterance = new SpeechSynthesisUtterance(last.content);
utterance.lang = langCode;
utterance.onerror = (e) => {
console.error("Speech error:", e.error);
alert("❌ Voice playback failed: " + e.error);
};
speechSynthesis.speak(utterance);
}
// Debug log
function sendPrompt() {
const userInput = document.getElementById('prompt').value.trim();
if (!userInput) return;
document.getElementById('prompt').value = '';
const chatBox = document.getElementById('chatBox');
conversation.push({ role: 'user', content: userInput });
chatBox.innerHTML += <div class='message user'>🟡 You: ${userInput}</div>;
console.log("🧠 Sending prompt:", conversation);
fetch('https://proxy-shield-ai.onrender.com/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: conversation, model: 'gpt-4' })
})
.then(res => res.json())
.then(data => {
const reply = data.choices[0].message.content;
console.log("🟢 Assistant replied:", reply);
conversation.push({ role: 'assistant', content: reply });
chatBox.innerHTML += <div class='message assistant'>🔵 Assistant: ${reply}</div>;
chatBox.scrollTop = chatBox.scrollHeight;
})
.catch(err => {
console.error("❌ API error:", err);
chatBox.innerHTML += <div class='message assistant'>⚠️ Error: ${err.message}</div>;
});
}
</script>
<script>
function startListening() {
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
const selectedLang = document.getElementById('voiceLang').value;
recognition.lang = selectedLang === 'auto' ? 'en-US' : selectedLang;
recognition.interimResults = false;
recognition.onstart = () => console.log("🎤 Listening in:", recognition.lang);
recognition.start();
recognition.onresult = e => {
const resultText = e.results[0][0].transcript;
console.log("🗣️ Heard:", resultText);
document.getElementById('prompt').value = resultText;
};
recognition.onerror = e => {
console.error('Voice input error:', e.error);
alert('⚠️ Speech recognition error: ' + e.error);
};
recognition.onend = () => console.log("🛑 Recognition ended.");
}
</script>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</body>
</html>