abohamood commited on
Commit
a2ad7cc
·
verified ·
1 Parent(s): ec699be

استبدل ايقونة متابة و شرح و ابداع و اتجاهات بأدوات التعامل مع الملفات وتحليلها بعد ارفاقها

Browse files
Files changed (1) hide show
  1. components/chat-widget.js +87 -24
components/chat-widget.js CHANGED
@@ -6,7 +6,37 @@ class AloloChatWidget extends HTMLElement {
6
  {
7
  role: 'assistant',
8
  content: 'مرحباً! أنا مساعد العلو الذكي. كيف يمكنني مساعدتك اليوم؟ أستطيع الإجابة على أسئلتك حول المنصات التعليمية، الدورات، الدعم الفني، والمزيد. يمكنك أيضاً رفع ملف نصي أو PDF لتحليله.',
9
- time: new Date().toLocaleTimeString('ar-SA', { hour: '2-digit', minute: '2-digit' })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
  ];
12
  this.quickQuestions = [
@@ -990,24 +1020,24 @@ handleQuickQuestion(question) {
990
 
991
  <div class="chat-footer">
992
  <div class="quick-actions">
993
- <button class="quick-action" data-question="اكتب مقالاً عن التعليم الإلكتروني">
994
- <i class="feather-icon" data-icon="edit"></i>
995
- كتابة
996
  </button>
997
- <button class="quick-action" data-question="اشرح مفهوم الذكاء الاصطناعي">
998
- <i class="feather-icon" data-icon="book-open"></i>
999
- شرح
1000
  </button>
1001
- <button class="quick-action" data-question="أنشئ قصة تعليمية قصيرة">
1002
- <i class="feather-icon" data-icon="feather"></i>
1003
- إبداع
1004
  </button>
1005
- <button class="quick-action" data-question="ما هي أحدث اتجاهات التعليم؟">
1006
- <i class="feather-icon" data-icon="trending-up"></i>
1007
- اتجاهات
1008
  </button>
1009
  </div>
1010
- <div class="chat-input-container">
1011
  <input type="text" class="chat-input" id="messageInput" placeholder="اكتب سؤالك هنا... (اضغط Enter لإرسال)" autocomplete="off">
1012
  <button class="send-button" id="sendMessage" title="إرسال">
1013
  <i class="feather-icon" data-icon="send"></i>
@@ -1020,8 +1050,8 @@ handleQuickQuestion(question) {
1020
  </div>
1021
  </div>
1022
  <div class="chat-footer-note">
1023
- <svg class="feather feather-cpu" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2" ry="2"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="1" x2="9" y2="4"/><line x1="15" y1="1" x2="15" y2="4"/><line x1="9" y1="20" x2="9" y2="23"/><line x1="15" y1="20" x2="15" y2="23"/><line x1="20" y1="9" x2="23" y2="9"/><line x1="20" y1="14" x2="23" y2="14"/><line x1="1" y1="9" x2="4" y2="9"/><line x1="1" y1="14" x2="4" y2="14"/></svg>
1024
- <span>يمكنك رفع ملف نصي أو PDF لتحليله</span>
1025
  </div>
1026
  </div>
1027
  </div>
@@ -1034,17 +1064,50 @@ handleQuickQuestion(question) {
1034
  this.shadowRoot.getElementById('messageInput').addEventListener('keypress', (e) => {
1035
  if (e.key === 'Enter') this.sendMessage();
1036
  });
 
 
 
 
 
1037
 
1038
- // Attach quick action buttons
1039
- this.shadowRoot.querySelectorAll('.quick-action').forEach(btn => {
1040
- btn.addEventListener('click', () => {
1041
- const question = btn.getAttribute('data-question');
1042
- if (question) {
1043
- this.handleQuickQuestion(question);
 
 
 
 
 
 
 
 
1044
  }
1045
  });
1046
- });
1047
- // Render initial messages
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1048
  this.renderMessages();
1049
  // Initialize icons
1050
  this.initializeIcons();
 
6
  {
7
  role: 'assistant',
8
  content: 'مرحباً! أنا مساعد العلو الذكي. كيف يمكنني مساعدتك اليوم؟ أستطيع الإجابة على أسئلتك حول المنصات التعليمية، الدورات، الدعم الفني، والمزيد. يمكنك أيضاً رفع ملف نصي أو PDF لتحليله.',
9
+ time: new Date().toLocaleTimeString('ar-SA', { hour: '2-digit', minute: '2-digit'
10
+ // Original quick-questions buttons (if any remain) still work
11
+ this.shadowRoot.querySelectorAll('.quick-action[data-question]').forEach(btn => {
12
+ btn.addEventListener('click', () => {
13
+ const question = btn.getAttribute('data-question');
14
+ if (question) this.handleQuickQuestion(question);
15
+ });
16
+ });
17
+ }
18
+
19
+ processFileAction(action) {
20
+ if (!this.attachedFile) {
21
+ this.addMessage('assistant', 'لم يتم رفع أي ملف. يرجى استخدام زر "رفع ملف" أولاً.');
22
+ return;
23
+ }
24
+
25
+ const actionMessages = {
26
+ 'summarize': `أريد تلخيص الملف المرفق "${this.attachedFile.name}".`,
27
+ 'analyze': `أريد تحليل محتوى الملف المرفق "${this.attachedFile.name}" بشكل مفصل.`,
28
+ 'convert': `أريد تحويل الملف المرفق "${this.attachedFile.name}" إلى صيغة أخرى أو تحسينه.`
29
+ };
30
+
31
+ const message = actionMessages[action] || `معالجة الملف ${this.attachedFile.name}`;
32
+ this.addMessage('user', message);
33
+ this.showTyping();
34
+
35
+ setTimeout(() => {
36
+ this.generateAIResponse(message);
37
+ }, 1200);
38
+ }
39
+ )
40
  }
41
  ];
42
  this.quickQuestions = [
 
1020
 
1021
  <div class="chat-footer">
1022
  <div class="quick-actions">
1023
+ <button class="quick-action" id="attachFileQuick" title="رفع ملف">
1024
+ <i class="feather-icon" data-icon="paperclip"></i>
1025
+ رفع ملف
1026
  </button>
1027
+ <button class="quick-action" id="summarizeFile" title="تلخيص الملف">
1028
+ <i class="feather-icon" data-icon="file-text"></i>
1029
+ تلخيص
1030
  </button>
1031
+ <button class="quick-action" id="analyzeFile" title="تحليل الملف">
1032
+ <i class="feather-icon" data-icon="search"></i>
1033
+ تحليل
1034
  </button>
1035
+ <button class="quick-action" id="convertFile" title="تحويل الملف">
1036
+ <i class="feather-icon" data-icon="refresh-cw"></i>
1037
+ تحويل
1038
  </button>
1039
  </div>
1040
+ <div class="chat-input-container">
1041
  <input type="text" class="chat-input" id="messageInput" placeholder="اكتب سؤالك هنا... (اضغط Enter لإرسال)" autocomplete="off">
1042
  <button class="send-button" id="sendMessage" title="إرسال">
1043
  <i class="feather-icon" data-icon="send"></i>
 
1050
  </div>
1051
  </div>
1052
  <div class="chat-footer-note">
1053
+ <svg class="feather feather-file-text" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
1054
+ <span>ارفع ملفاً لتحليله باستخدام الأدوات أعلاه</span>
1055
  </div>
1056
  </div>
1057
  </div>
 
1064
  this.shadowRoot.getElementById('messageInput').addEventListener('keypress', (e) => {
1065
  if (e.key === 'Enter') this.sendMessage();
1066
  });
1067
+ // Attach quick action buttons for file operations
1068
+ const attachFileQuickBtn = this.shadowRoot.getElementById('attachFileQuick');
1069
+ const summarizeFileBtn = this.shadowRoot.getElementById('summarizeFile');
1070
+ const analyzeFileBtn = this.shadowRoot.getElementById('analyzeFile');
1071
+ const convertFileBtn = this.shadowRoot.getElementById('convertFile');
1072
 
1073
+ if (attachFileQuickBtn) {
1074
+ attachFileQuickBtn.addEventListener('click', () => {
1075
+ // Trigger file input click
1076
+ const attachBtn = this.shadowRoot.getElementById('attachFileBtn');
1077
+ if (attachBtn) attachBtn.click();
1078
+ });
1079
+ }
1080
+
1081
+ if (summarizeFileBtn) {
1082
+ summarizeFileBtn.addEventListener('click', () => {
1083
+ if (this.attachedFile) {
1084
+ this.processFileAction('summarize');
1085
+ } else {
1086
+ this.addMessage('assistant', 'يرجى رفع ملف أولاً للنقر على زر "رفع ملف" أعلاه.');
1087
  }
1088
  });
1089
+ }
1090
+
1091
+ if (analyzeFileBtn) {
1092
+ analyzeFileBtn.addEventListener('click', () => {
1093
+ if (this.attachedFile) {
1094
+ this.processFileAction('analyze');
1095
+ } else {
1096
+ this.addMessage('assistant', 'يرجى رفع ملف أولاً للنقر على زر "رفع ملف" أعلاه.');
1097
+ }
1098
+ });
1099
+ }
1100
+
1101
+ if (convertFileBtn) {
1102
+ convertFileBtn.addEventListener('click', () => {
1103
+ if (this.attachedFile) {
1104
+ this.processFileAction('convert');
1105
+ } else {
1106
+ this.addMessage('assistant', 'يرجى رفع ملف أولاً للنقر على زر "رفع ملف" أعلاه.');
1107
+ }
1108
+ });
1109
+ }
1110
+ // Render initial messages
1111
  this.renderMessages();
1112
  // Initialize icons
1113
  this.initializeIcons();