AnesKAM commited on
Commit
42ea841
·
verified ·
1 Parent(s): 5b19d71

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +38 -7
index.html CHANGED
@@ -298,7 +298,7 @@
298
  </div>
299
  <button class="btn-danger" onclick="clearAllChats()" id="i18n-del-btn">🗑 Delete</button>
300
  </div>
301
- <button class="btn-save" onclick="closeSettings()" id="i18n-save-btn">💾 Save</button>
302
  </div>
303
  </div>
304
 
@@ -591,13 +591,44 @@ async function sendMessage(){
591
  scrollToBottom();
592
  }
593
 
594
- if (fullBotResponse.includes('<div style="text-align:center;')) {
595
- botContentDiv.innerHTML = fullBotResponse;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  } else {
597
- botContentDiv.innerHTML = marked.parse(fullBotResponse);
598
- renderKaTeX(botContentDiv);
 
 
 
 
 
599
  }
600
-
 
601
  chat.history.push({ user: text, bot: fullBotResponse, uiFiles: uiFiles });
602
  saveChats();
603
  appendMemBadge(chat.history.length, chat.history.length);
@@ -665,4 +696,4 @@ document.getElementById('lang-select').value = currentLang;
665
  applyI18n();
666
  </script>
667
  </body>
668
- </html>
 
298
  </div>
299
  <button class="btn-danger" onclick="clearAllChats()" id="i18n-del-btn">🗑 Delete</button>
300
  </div>
301
+ <button class="btn-save" onclick="closeSettings()" id="i18n-save-btn">💾 Close</button>
302
  </div>
303
  </div>
304
 
 
591
  scrollToBottom();
592
  }
593
 
594
+ // --- التعديل الأساسي: معالجة JSON للصور ---
595
+ // إزالة مؤشر الكتابة قبل التقديم النهائي
596
+ const cursor = botContentDiv.querySelector('.gemini-cursor');
597
+ if (cursor) cursor.remove();
598
+
599
+ // محاولة تحليل الرد على أنه JSON (لحالة توليد الصور)
600
+ let parsedResponse = null;
601
+ try {
602
+ parsedResponse = JSON.parse(fullBotResponse);
603
+ } catch (e) {
604
+ // ليس JSON، نتعامل معه كنص عادي
605
+ }
606
+
607
+ if (parsedResponse && (parsedResponse.image || parsedResponse.url)) {
608
+ // عرض الصورة المولدة
609
+ let imgHtml = '';
610
+ if (parsedResponse.image) {
611
+ // الصورة بصيغة base64
612
+ imgHtml = `<img src="data:image/png;base64,${parsedResponse.image}" alt="Generated Image" style="max-width:100%; border-radius:18px; box-shadow:0 8px 25px rgba(0,0,0,0.1);"/>`;
613
+ } else if (parsedResponse.url) {
614
+ // رابط مباشر للصورة
615
+ imgHtml = `<img src="${parsedResponse.url}" alt="Generated Image" style="max-width:100%; border-radius:18px; box-shadow:0 8px 25px rgba(0,0,0,0.1);"/>`;
616
+ }
617
+ botContentDiv.innerHTML = `<div style="text-align:center;">${imgHtml}</div>`;
618
+ } else if (parsedResponse && parsedResponse.error) {
619
+ // عرض رسالة خطأ من الخادم
620
+ botContentDiv.innerHTML = `<span style="color:var(--danger)">⚠️ ${parsedResponse.error}</span>`;
621
  } else {
622
+ // التعامل مع الردود النصية العادية (Markdown أو HTML)
623
+ if (fullBotResponse.includes('<div style="text-align:center;')) {
624
+ botContentDiv.innerHTML = fullBotResponse;
625
+ } else {
626
+ botContentDiv.innerHTML = marked.parse(fullBotResponse);
627
+ renderKaTeX(botContentDiv);
628
+ }
629
  }
630
+ // --- نهاية التعديل ---
631
+
632
  chat.history.push({ user: text, bot: fullBotResponse, uiFiles: uiFiles });
633
  saveChats();
634
  appendMemBadge(chat.history.length, chat.history.length);
 
696
  applyI18n();
697
  </script>
698
  </body>
699
+ </html>