al00sakkaf commited on
Commit
c3f9420
·
verified ·
1 Parent(s): 069779f

قم بتطوير التطبيق واضف التحسينات واجعل اسم التطبيق "المساعد الذكي" واضف اسفل الشاشة النص التالي "تصميم المهندس احمد السقاف"

Browse files
Files changed (1) hide show
  1. index.html +246 -51
index.html CHANGED
@@ -4,8 +4,8 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>GeminiPersona - الدردشة الذكية</title>
8
- <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
9
  <script src="https://cdn.tailwindcss.com"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
  <script src="https://unpkg.com/feather-icons"></script>
@@ -57,7 +57,14 @@
57
  transform: translateY(-2px);
58
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.15);
59
  }
60
- .markdown-content h1, .markdown-content h2, .markdown-content h3 {
 
 
 
 
 
 
 
61
  margin-top: 1rem;
62
  margin-bottom: 0.5rem;
63
  font-weight: bold;
@@ -79,23 +86,38 @@
79
  overflow-x: auto;
80
  margin: 1rem 0;
81
  }
82
- .page-container {
 
 
 
 
 
 
 
 
 
 
 
 
83
  display: none;
 
 
84
  }
85
  .active-page {
86
  display: block;
 
87
  }
88
- </style>
89
  </head>
90
- <body class="bg-gray-50 min-h-screen">
91
- <!-- Navigation -->
92
  <nav class="bg-white shadow-lg border-b">
93
- <div class="max-w-7xl mx-auto px-4">
94
- <div class="flex justify-between items-center h-16">
95
- <div class="flex items-center space-x-4 space-x-reverse">
96
  <i data-feather="message-circle" class="text-primary w-8 h-8"></i>
97
- <h1 class="text-xl font-bold text-gray-800">GeminiPersona</h1>
98
- </div>
99
  <div class="flex items-center space-x-4 space-x-reverse">
100
  <button onclick="showPage('settings')" class="text-gray-600 hover:text-primary transition-colors">
101
  <i data-feather="settings"></i>
@@ -121,9 +143,9 @@
121
  <div class="max-w-4xl mx-auto py-8 px-4">
122
  <!-- Welcome Section -->
123
  <div class="text-center mb-12">
124
- <h2 class="text-3xl font-bold text-gray-800 mb-4">مرحباً بك في GeminiPersona</h2>
125
- <p class="text-gray-600 text-lg">تطبيق الدردشة الذكي الذي يتقمص الشخصيات باستخدام نماذج Gemini المتقدمة</p>
126
- </div>
127
  <!-- Quick Actions -->
128
  <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-12">
129
  <button onclick="showPage('chat')" class="bg-white p-6 rounded-xl shadow-md border border-gray-200 hover:shadow-lg transition-shadow group">
@@ -165,9 +187,9 @@
165
  <div class="flex items-start space-x-4 space-x-reverse">
166
  <i data-feather="zap" class="w-6 h-6 text-green-500 mt-1"></i>
167
  <div>
168
- <h4 class="font-semibold text-gray-800 mb-2">نماذج Gemini المتقدمة</h4>
169
- <p class="text-gray-600">استخدم أحدث نماذج الذكاء الاصطناعي من Google</p>
170
- </div>
171
  </div>
172
  <div class="flex items-start space-x-4 space-x-reverse">
173
  <i data-feather="user" class="w-6 h-6 text-blue-500 mt-1"></i>
@@ -611,16 +633,19 @@
611
  }
612
  };
613
  }
614
-
615
  // Page navigation
616
  function showPage(pageName) {
617
- // Hide all pages
618
  document.querySelectorAll('.page-container').forEach(page => {
619
  page.classList.remove('active-page');
 
620
  });
621
 
622
- // Show the selected page
623
- document.getElementById(pageName).classList.add('active-page');
 
 
 
624
 
625
  // Update page-specific content
626
  if (pageName === 'characters') {
@@ -640,16 +665,31 @@
640
 
641
  feather.replace();
642
  }
643
-
644
- // Initialize app
645
  document.addEventListener('DOMContentLoaded', function() {
646
  initDB();
647
  feather.replace();
648
  loadStatistics();
649
  showPage('home');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  });
651
-
652
- // Load statistics
653
  function loadStatistics() {
654
  const dbRequest = indexedDB.open("GeminiPersonaDB", 1);
655
 
@@ -900,14 +940,13 @@
900
  const url = URL.createObjectURL(dataBlob);
901
  const link = document.createElement('a');
902
  link.href = url;
903
- link.download = `gemini-persona-characters-${new Date().toISOString().split('T')[0]}.json`;
904
  document.body.appendChild(link);
905
  link.click();
906
  document.body.removeChild(link);
907
  URL.revokeObjectURL(url);
908
  }
909
-
910
- // Handle form submission
911
  document.getElementById('characterForm').addEventListener('submit', function(e) {
912
  e.preventDefault();
913
 
@@ -981,7 +1020,6 @@
981
  document.getElementById('messageInput').disabled = false;
982
  document.getElementById('sendButton').disabled = false;
983
  }
984
-
985
  async function sendMessage() {
986
  const messageInput = document.getElementById('messageInput');
987
  const message = messageInput.value.trim();
@@ -998,6 +1036,13 @@
998
  addMessageToChat('user', message);
999
  messageInput.value = '';
1000
 
 
 
 
 
 
 
 
1001
  // Get character info
1002
  const request = indexedDB.open("GeminiPersonaDB", 1);
1003
  request.onsuccess = function(event) {
@@ -1008,15 +1053,46 @@
1008
 
1009
  getRequest.onsuccess = function() {
1010
  const character = getRequest.result;
1011
- // Simulate AI response (replace with actual API call)
 
 
 
1012
  setTimeout(() => {
1013
- addMessageToChat('ai', `هذه استجابة محاكاة من ${character.name}: ${message}`, character);
1014
- }, 1000);
 
1015
  };
1016
  };
1017
  }
1018
 
1019
- function addMessageToChat(sender, content, character = null) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1020
  const messagesContainer = document.getElementById('messagesContainer');
1021
  const messageDiv = document.createElement('div');
1022
  messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`;
@@ -1041,13 +1117,47 @@
1041
  messagesContainer.appendChild(messageDiv);
1042
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
1043
  }
1044
-
1045
  function saveConversation() {
1046
- // Implementation for saving conversation
1047
- alert('تم حفظ المحادثة');
1048
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1049
 
1050
- function clearChat() {
 
 
 
 
 
 
 
 
 
 
 
 
 
1051
  document.getElementById('messagesContainer').innerHTML = `
1052
  <div class="text-center text-gray-500 py-8">
1053
  <i data-feather="message-circle" class="w-12 h-12 mx-auto mb-4"></i>
@@ -1056,13 +1166,38 @@
1056
  `;
1057
  feather.replace();
1058
  }
1059
-
1060
  function exportChat() {
1061
- // Implementation for exporting chat
1062
- alert('تم تصدير المحادثة');
1063
- }
 
 
 
 
 
 
 
 
 
1064
 
1065
- // Voice chat functionality
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1066
  function loadVoiceCharacterSelect() {
1067
  const select = document.getElementById('voiceCharacterSelect');
1068
  const request = indexedDB.open("GeminiPersonaDB", 1);
@@ -1230,7 +1365,6 @@
1230
  };
1231
  };
1232
  }
1233
-
1234
  function exportAllConversations() {
1235
  const request = indexedDB.open("GeminiPersonaDB", 1);
1236
 
@@ -1247,7 +1381,7 @@
1247
  const url = URL.createObjectURL(dataBlob);
1248
  const link = document.createElement('a');
1249
  link.href = url;
1250
- link.download = `gemini-persona-conversations-${new Date().toISOString().split('T')[0]}.json`;
1251
  document.body.appendChild(link);
1252
  link.click();
1253
  document.body.removeChild(link);
@@ -1255,8 +1389,7 @@
1255
  };
1256
  };
1257
  }
1258
-
1259
- // Settings functionality
1260
  function loadSettings() {
1261
  const request = indexedDB.open("GeminiPersonaDB", 1);
1262
 
@@ -1337,7 +1470,6 @@
1337
  };
1338
  };
1339
  }
1340
-
1341
  function exportAllData() {
1342
  const request = indexedDB.open("GeminiPersonaDB", 1);
1343
 
@@ -1366,7 +1498,7 @@
1366
  const url = URL.createObjectURL(dataBlob);
1367
  const link = document.createElement('a');
1368
  link.href = url;
1369
- link.download = `gemini-persona-backup-${new Date().toISOString().split('T')[0]}.json`;
1370
  document.body.appendChild(link);
1371
  link.click();
1372
  document.body.removeChild(link);
@@ -1375,7 +1507,63 @@
1375
  };
1376
  }
1377
 
1378
- // Add event listeners for search and sort in characters page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1379
  document.addEventListener('DOMContentLoaded', function() {
1380
  document.getElementById('searchInput')?.addEventListener('input', function() {
1381
  currentPage = 1;
@@ -1395,5 +1583,12 @@
1395
  });
1396
  });
1397
  </script>
 
 
 
 
 
 
 
1398
  </body>
1399
  </html>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>المساعد الذكي - الدردشة الذكية</title>
8
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
9
  <script src="https://cdn.tailwindcss.com"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
  <script src="https://unpkg.com/feather-icons"></script>
 
57
  transform: translateY(-2px);
58
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.15);
59
  }
60
+ .fade-in {
61
+ animation: fadeIn 0.3s ease-in-out;
62
+ }
63
+ @keyframes fadeIn {
64
+ from { opacity: 0; transform: translateY(10px); }
65
+ to { opacity: 1; transform: translateY(0); }
66
+ }
67
+ .markdown-content h1, .markdown-content h2, .markdown-content h3 {
68
  margin-top: 1rem;
69
  margin-bottom: 0.5rem;
70
  font-weight: bold;
 
86
  overflow-x: auto;
87
  margin: 1rem 0;
88
  }
89
+ .loading-spinner {
90
+ border: 3px solid #f3f3f3;
91
+ border-top: 3px solid #6366f1;
92
+ border-radius: 50%;
93
+ width: 20px;
94
+ height: 20px;
95
+ animation: spin 1s linear infinite;
96
+ }
97
+ @keyframes spin {
98
+ 0% { transform: rotate(0deg); }
99
+ 100% { transform: rotate(360deg); }
100
+ }
101
+ .page-container {
102
  display: none;
103
+ opacity: 0;
104
+ transition: opacity 0.3s ease-in-out;
105
  }
106
  .active-page {
107
  display: block;
108
+ opacity: 1;
109
  }
110
+ </style>
111
  </head>
112
+ <body class="bg-gray-50 min-h-screen flex flex-col">
113
+ <!-- Navigation -->
114
  <nav class="bg-white shadow-lg border-b">
115
+ <div class="max-w-7xl mx-auto px-4">
116
+ <div class="flex justify-between items-center h-16">
117
+ <div class="flex items-center space-x-4 space-x-reverse">
118
  <i data-feather="message-circle" class="text-primary w-8 h-8"></i>
119
+ <h1 class="text-xl font-bold text-gray-800">المساعد الذكي</h1>
120
+ </div>
121
  <div class="flex items-center space-x-4 space-x-reverse">
122
  <button onclick="showPage('settings')" class="text-gray-600 hover:text-primary transition-colors">
123
  <i data-feather="settings"></i>
 
143
  <div class="max-w-4xl mx-auto py-8 px-4">
144
  <!-- Welcome Section -->
145
  <div class="text-center mb-12">
146
+ <h2 class="text-3xl font-bold text-gray-800 mb-4">مرحباً بك في المساعد الذكي</h2>
147
+ <p class="text-gray-600 text-lg">تطبيق الدردشة الذكي الذي يتقمص الشخصيات باستخدام نماذج الذكاء الاصطناعي المتقدمة</p>
148
+ </div>
149
  <!-- Quick Actions -->
150
  <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-12">
151
  <button onclick="showPage('chat')" class="bg-white p-6 rounded-xl shadow-md border border-gray-200 hover:shadow-lg transition-shadow group">
 
187
  <div class="flex items-start space-x-4 space-x-reverse">
188
  <i data-feather="zap" class="w-6 h-6 text-green-500 mt-1"></i>
189
  <div>
190
+ <h4 class="font-semibold text-gray-800 mb-2">نماذج الذكاء الاصطناعي المتقدمة</h4>
191
+ <p class="text-gray-600">استخدم أحدث نماذج الذكاء الاصطناعي المتقدمة</p>
192
+ </div>
193
  </div>
194
  <div class="flex items-start space-x-4 space-x-reverse">
195
  <i data-feather="user" class="w-6 h-6 text-blue-500 mt-1"></i>
 
633
  }
634
  };
635
  }
 
636
  // Page navigation
637
  function showPage(pageName) {
638
+ // Hide all pages with fade out
639
  document.querySelectorAll('.page-container').forEach(page => {
640
  page.classList.remove('active-page');
641
+ page.style.opacity = '0';
642
  });
643
 
644
+ // Show the selected page with fade in
645
+ setTimeout(() => {
646
+ document.getElementById(pageName).classList.add('active-page');
647
+ document.getElementById(pageName).style.opacity = '1';
648
+ }, 100);
649
 
650
  // Update page-specific content
651
  if (pageName === 'characters') {
 
665
 
666
  feather.replace();
667
  }
668
+ // Initialize app
 
669
  document.addEventListener('DOMContentLoaded', function() {
670
  initDB();
671
  feather.replace();
672
  loadStatistics();
673
  showPage('home');
674
+
675
+ // Add smooth scroll behavior
676
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
677
+ anchor.addEventListener('click', function (e) {
678
+ e.preventDefault();
679
+ const target = document.querySelector(this.getAttribute('href'));
680
+ if (target) {
681
+ target.scrollIntoView({ behavior: 'smooth' });
682
+ }
683
+ });
684
+ });
685
+
686
+ // Add loading animation
687
+ document.querySelectorAll('.page-container').forEach(page => {
688
+ page.style.opacity = '0';
689
+ page.style.transition = 'opacity 0.3s ease-in-out';
690
+ });
691
  });
692
+ // Load statistics
 
693
  function loadStatistics() {
694
  const dbRequest = indexedDB.open("GeminiPersonaDB", 1);
695
 
 
940
  const url = URL.createObjectURL(dataBlob);
941
  const link = document.createElement('a');
942
  link.href = url;
943
+ link.download = `smart-assistant-characters-${new Date().toISOString().split('T')[0]}.json`;
944
  document.body.appendChild(link);
945
  link.click();
946
  document.body.removeChild(link);
947
  URL.revokeObjectURL(url);
948
  }
949
+ // Handle form submission
 
950
  document.getElementById('characterForm').addEventListener('submit', function(e) {
951
  e.preventDefault();
952
 
 
1020
  document.getElementById('messageInput').disabled = false;
1021
  document.getElementById('sendButton').disabled = false;
1022
  }
 
1023
  async function sendMessage() {
1024
  const messageInput = document.getElementById('messageInput');
1025
  const message = messageInput.value.trim();
 
1036
  addMessageToChat('user', message);
1037
  messageInput.value = '';
1038
 
1039
+ // Show loading indicator
1040
+ const loadingDiv = document.createElement('div');
1041
+ loadingDiv.className = 'flex justify-start';
1042
+ loadingDiv.innerHTML = '<div class="chat-bubble-ai px-4 py-2"><div class="loading-spinner"></div></div>';
1043
+ document.getElementById('messagesContainer').appendChild(loadingDiv);
1044
+ document.getElementById('messagesContainer').scrollTop = document.getElementById('messagesContainer').scrollHeight;
1045
+
1046
  // Get character info
1047
  const request = indexedDB.open("GeminiPersonaDB", 1);
1048
  request.onsuccess = function(event) {
 
1053
 
1054
  getRequest.onsuccess = function() {
1055
  const character = getRequest.result;
1056
+ // Remove loading indicator
1057
+ loadingDiv.remove();
1058
+
1059
+ // Simulate AI response with better formatting
1060
  setTimeout(() => {
1061
+ const response = generateSmartResponse(message, character);
1062
+ addMessageToChat('ai', response, character);
1063
+ }, 1500);
1064
  };
1065
  };
1066
  }
1067
 
1068
+ function generateSmartResponse(message, character) {
1069
+ const responses = {
1070
+ doctor: [
1071
+ "بناءً على ما ذكرت، أنصحك باستشارة الطبيب المختص للحصول على تشخيص دقيق.",
1072
+ "هذه الأعراض قد تتطلب فحصاً طبياً شاملاً. هل يمكنك توضيح المزيد؟",
1073
+ "من المهم مراقبة هذه الأعراض وتسجيلها لمساعدة الطبيب في التشخيص."
1074
+ ],
1075
+ teacher: [
1076
+ "هذا سؤال ممتاز! دعنا نحلل المفهوم خطوة بخطوة.",
1077
+ "يمكنني شرح هذا الموضوع بطريقة أبسط. هل تريد التركيز على جانب معين؟",
1078
+ "هذه نقطة مهمة جداً في الفهم. سأوضحها لك بمثال عملي."
1079
+ ],
1080
+ friend: [
1081
+ "أفهم ما تمر به تماماً. هل تريد أن تتحدث عن الأمر أكثر؟",
1082
+ "أنا هنا للاستماع. شاركني ما يجول في خاطرك.",
1083
+ "هذا موقف صعب حقاً. كيف تشعر حيال ذلك؟"
1084
+ ],
1085
+ default: [
1086
+ "هذا مثير للاهتمام! أخبرني المزيد عن هذا الموضوع.",
1087
+ "أفهم وجهة نظرك. هل هناك جانب آخر ترغب في مناقشته؟",
1088
+ "سؤال جيد! دعنا نفكر في هذا معاً."
1089
+ ]
1090
+ };
1091
+
1092
+ const roleResponses = responses[character.role?.toLowerCase()] || responses.default;
1093
+ return roleResponses[Math.floor(Math.random() * roleResponses.length)];
1094
+ }
1095
+ function addMessageToChat(sender, content, character = null) {
1096
  const messagesContainer = document.getElementById('messagesContainer');
1097
  const messageDiv = document.createElement('div');
1098
  messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`;
 
1117
  messagesContainer.appendChild(messageDiv);
1118
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
1119
  }
 
1120
  function saveConversation() {
1121
+ const messages = document.querySelectorAll('#messagesContainer .flex');
1122
+ if (messages.length === 0) {
1123
+ alert('لا توجد رسائل لحفظها');
1124
+ return;
1125
+ }
1126
+
1127
+ const characterSelect = document.getElementById('characterSelect');
1128
+ const characterId = characterSelect.value;
1129
+ const characterName = characterSelect.options[characterSelect.selectedIndex].text;
1130
+
1131
+ const conversationData = {
1132
+ title: `محادثة مع ${characterName}`,
1133
+ characterId: parseInt(characterId),
1134
+ characterName: characterName,
1135
+ messages: Array.from(messages).map(msg => {
1136
+ const isUser = msg.classList.contains('justify-end');
1137
+ const content = msg.querySelector('.markdown-content')?.innerHTML || msg.querySelector('div:not(.font-semibold)')?.textContent || '';
1138
+ return {
1139
+ sender: isUser ? 'user' : 'ai',
1140
+ content: content,
1141
+ timestamp: new Date().toISOString()
1142
+ };
1143
+ }),
1144
+ createdAt: new Date().toISOString()
1145
+ };
1146
 
1147
+ const request = indexedDB.open("GeminiPersonaDB", 1);
1148
+
1149
+ request.onsuccess = function(event) {
1150
+ const db = event.target.result;
1151
+ const transaction = db.transaction(['conversations'], 'readwrite');
1152
+ const store = transaction.objectStore('conversations');
1153
+ store.add(conversationData);
1154
+
1155
+ transaction.oncomplete = function() {
1156
+ alert('تم حفظ المحادثة بنجاح');
1157
+ };
1158
+ };
1159
+ }
1160
+ function clearChat() {
1161
  document.getElementById('messagesContainer').innerHTML = `
1162
  <div class="text-center text-gray-500 py-8">
1163
  <i data-feather="message-circle" class="w-12 h-12 mx-auto mb-4"></i>
 
1166
  `;
1167
  feather.replace();
1168
  }
 
1169
  function exportChat() {
1170
+ const messages = document.querySelectorAll('#messagesContainer .flex');
1171
+ if (messages.length === 0) {
1172
+ alert('لا توجد رسائل لتصديرها');
1173
+ return;
1174
+ }
1175
+
1176
+ const characterSelect = document.getElementById('characterSelect');
1177
+ const characterName = characterSelect.options[characterSelect.selectedIndex].text;
1178
+
1179
+ let chatContent = `محادثة مع ${characterName}\n`;
1180
+ chatContent += `التاريخ: ${new Date().toLocaleString('ar-SA')}\n`;
1181
+ chatContent += '=' .repeat(50) + '\n\n';
1182
 
1183
+ messages.forEach(msg => {
1184
+ const isUser = msg.classList.contains('justify-end');
1185
+ const sender = isUser ? 'أنت' : characterName;
1186
+ const content = msg.querySelector('.markdown-content')?.textContent || msg.querySelector('div:not(.font-semibold)')?.textContent || '';
1187
+ chatContent += `${sender}: ${content}\n\n`;
1188
+ });
1189
+
1190
+ const dataBlob = new Blob([chatContent], {type: 'text/plain'});
1191
+ const url = URL.createObjectURL(dataBlob);
1192
+ const link = document.createElement('a');
1193
+ link.href = url;
1194
+ link.download = `chat-${characterName}-${new Date().toISOString().split('T')[0]}.txt`;
1195
+ document.body.appendChild(link);
1196
+ link.click();
1197
+ document.body.removeChild(link);
1198
+ URL.revokeObjectURL(url);
1199
+ }
1200
+ // Voice chat functionality
1201
  function loadVoiceCharacterSelect() {
1202
  const select = document.getElementById('voiceCharacterSelect');
1203
  const request = indexedDB.open("GeminiPersonaDB", 1);
 
1365
  };
1366
  };
1367
  }
 
1368
  function exportAllConversations() {
1369
  const request = indexedDB.open("GeminiPersonaDB", 1);
1370
 
 
1381
  const url = URL.createObjectURL(dataBlob);
1382
  const link = document.createElement('a');
1383
  link.href = url;
1384
+ link.download = `smart-assistant-conversations-${new Date().toISOString().split('T')[0]}.json`;
1385
  document.body.appendChild(link);
1386
  link.click();
1387
  document.body.removeChild(link);
 
1389
  };
1390
  };
1391
  }
1392
+ // Settings functionality
 
1393
  function loadSettings() {
1394
  const request = indexedDB.open("GeminiPersonaDB", 1);
1395
 
 
1470
  };
1471
  };
1472
  }
 
1473
  function exportAllData() {
1474
  const request = indexedDB.open("GeminiPersonaDB", 1);
1475
 
 
1498
  const url = URL.createObjectURL(dataBlob);
1499
  const link = document.createElement('a');
1500
  link.href = url;
1501
+ link.download = `smart-assistant-backup-${new Date().toISOString().split('T')[0]}.json`;
1502
  document.body.appendChild(link);
1503
  link.click();
1504
  document.body.removeChild(link);
 
1507
  };
1508
  }
1509
 
1510
+ function importData(event) {
1511
+ const file = event.target.files[0];
1512
+ if (!file) return;
1513
+
1514
+ const reader = new FileReader();
1515
+ reader.onload = function(e) {
1516
+ try {
1517
+ const data = JSON.parse(e.target.result);
1518
+
1519
+ const request = indexedDB.open("GeminiPersonaDB", 1);
1520
+
1521
+ request.onsuccess = function(event) {
1522
+ const db = event.target.result;
1523
+ const transaction = db.transaction(['conversations', 'characters', 'settings'], 'readwrite');
1524
+
1525
+ // Clear existing data
1526
+ transaction.objectStore('conversations').clear();
1527
+ transaction.objectStore('characters').clear();
1528
+ transaction.objectStore('settings').clear();
1529
+
1530
+ // Import new data
1531
+ if (data.conversations && data.conversations.length > 0) {
1532
+ const conversationsStore = transaction.objectStore('conversations');
1533
+ data.conversations.forEach(conv => {
1534
+ delete conv.id; // Let IndexedDB generate new ID
1535
+ conversationsStore.add(conv);
1536
+ });
1537
+ }
1538
+
1539
+ if (data.characters && data.characters.length > 0) {
1540
+ const charactersStore = transaction.objectStore('characters');
1541
+ data.characters.forEach(char => {
1542
+ delete char.id; // Let IndexedDB generate new ID
1543
+ charactersStore.add(char);
1544
+ });
1545
+ }
1546
+
1547
+ if (data.settings && data.settings.length > 0) {
1548
+ const settingsStore = transaction.objectStore('settings');
1549
+ data.settings.forEach(setting => {
1550
+ settingsStore.add(setting);
1551
+ });
1552
+ }
1553
+
1554
+ transaction.oncomplete = function() {
1555
+ alert('تم استيراد البيانات بنجاح');
1556
+ location.reload();
1557
+ };
1558
+ };
1559
+ } catch (error) {
1560
+ alert('خطأ في قراءة الملف. يرجى التأكد من أنه ملف نسخة احتياطية صحيح.');
1561
+ }
1562
+ };
1563
+
1564
+ reader.readAsText(file);
1565
+ }
1566
+ // Add event listeners for search and sort in characters page
1567
  document.addEventListener('DOMContentLoaded', function() {
1568
  document.getElementById('searchInput')?.addEventListener('input', function() {
1569
  currentPage = 1;
 
1583
  });
1584
  });
1585
  </script>
1586
+
1587
+ <!-- Footer -->
1588
+ <footer class="bg-gray-800 text-white py-4 mt-auto">
1589
+ <div class="text-center">
1590
+ <p class="text-sm">تصميم المهندس احمد السقاف</p>
1591
+ </div>
1592
+ </footer>
1593
  </body>
1594
  </html>