joermd commited on
Commit
abba06c
·
verified ·
1 Parent(s): 70da030

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +371 -165
index.html CHANGED
@@ -9,8 +9,6 @@
9
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
10
  <!-- ربط مكتبة jsPDF لتحويل النص إلى PDF -->
11
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
12
- <!-- (اختياري) ربط مكتبة PicoCSS لتنسيق قسم OCR -->
13
- <link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
14
  <style>
15
  @import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap");
16
 
@@ -53,6 +51,7 @@
53
  transition: all 0.3s ease;
54
  border-radius: 0.5rem;
55
  margin: 0.25rem 0.5rem;
 
56
  }
57
  .nav-link:hover {
58
  background: #f3f4f6;
@@ -200,7 +199,6 @@
200
  <aside class="sidebar">
201
  <div class="p-6">
202
  <div class="flex items-center gap-4 mb-8">
203
- <!-- استخدام الصورة المطلوبة كشعار -->
204
  <img src="https://ufastpro.com/wp-content/uploads/2025/02/تصميم-بدون-عنوان.png" alt="شعار المنصة" class="w-12 h-12 rounded-full" />
205
  <div>
206
  <h1 class="text-xl font-bold text-gray-800">المنصة القانونية</h1>
@@ -214,7 +212,7 @@
214
  </a>
215
  <a href="#" class="nav-link" data-section="analysis">
216
  <i class="fas fa-balance-scale ml-3"></i>
217
- <span>التحليل القانوني</span>
218
  </a>
219
  <a href="#" class="nav-link" data-section="mindMap">
220
  <i class="fas fa-project-diagram ml-3"></i>
@@ -234,21 +232,16 @@
234
  </a>
235
  <a href="#" class="nav-link" data-section="consultation">
236
  <i class="fas fa-comments ml-3"></i>
237
- <span>استشارة قانونية</span>
238
  </a>
239
- <!-- رابط قسم إنشاء العقود -->
240
  <a href="#" class="nav-link" data-section="contracts">
241
  <i class="fas fa-file-contract ml-3"></i>
242
  <span>العقود</span>
243
  </a>
244
- <a href="#" class="nav-link" data-section="precedents">
245
- <i class="fas fa-gavel ml-3"></i>
246
- <span>الأحكام والسوابق</span>
247
- </a>
248
- <!-- إضافة قسم OCR -->
249
- <a href="#" class="nav-link" data-section="ocr">
250
- <i class="fas fa-image ml-3"></i>
251
- <span>OCR</span>
252
  </a>
253
  </nav>
254
  </div>
@@ -257,7 +250,7 @@
257
  <!-- المحتوى الرئيسي -->
258
  <main class="main-content">
259
  <!-- بحث عالمي -->
260
- <div class="search-container mb-6">
261
  <input type="text" class="search-input w-full p-3 rounded border" placeholder="ابحث في المنصة..." id="globalSearch" />
262
  <i class="fas fa-search absolute top-1/2 right-4 transform -translate-y-1/2 text-gray-400"></i>
263
  </div>
@@ -270,9 +263,9 @@
270
  <div class="feature-card p-6">
271
  <div class="text-center">
272
  <i class="fas fa-balance-scale text-3xl mb-4 text-blue-600"></i>
273
- <h3 class="text-xl font-bold text-gray-800 mb-3">التحليل القانوني</h3>
274
  <p class="text-gray-600 mb-4">
275
- تحليل متكامل للقضايا والمستندات القانونية باستخدام الذكاء الاصطناعي
276
  </p>
277
  <button class="action-button" onclick="showSection('analysis')">ابدأ التحليل</button>
278
  </div>
@@ -282,7 +275,7 @@
282
  <i class="fas fa-project-diagram text-3xl mb-4 text-blue-600"></i>
283
  <h3 class="text-xl font-bold text-gray-800 mb-3">خريطة التفكير</h3>
284
  <p class="text-gray-600 mb-4">
285
- إنشاء خرائط ذهنية للقضايا القانونية وتحليل العلاقات
286
  </p>
287
  <button class="action-button" onclick="showSection('mindMap')">إنشاء خريطة</button>
288
  </div>
@@ -292,7 +285,7 @@
292
  <i class="fas fa-search text-3xl mb-4 text-blue-600"></i>
293
  <h3 class="text-xl font-bold text-gray-800 mb-3">البحث القانوني</h3>
294
  <p class="text-gray-600 mb-4">
295
- بحث متقدم في السوابق والقضايا المشابهة
296
  </p>
297
  <button class="action-button" onclick="showSection('search')">ابدأ البحث</button>
298
  </div>
@@ -302,7 +295,7 @@
302
  <i class="fas fa-file-alt text-3xl mb-4 text-blue-600"></i>
303
  <h3 class="text-xl font-bold text-gray-800 mb-3">المستندات</h3>
304
  <p class="text-gray-600 mb-4">
305
- إنشاء وتحرير المستندات القانونية بمساعدة الذكاء الاصطناعي
306
  </p>
307
  <button class="action-button" onclick="showSection('documents')">إنشاء مستند</button>
308
  </div>
@@ -312,7 +305,7 @@
312
  <i class="fas fa-language text-3xl mb-4 text-blue-600"></i>
313
  <h3 class="text-xl font-bold text-gray-800 mb-3">الترجمة القانونية</h3>
314
  <p class="text-gray-600 mb-4">
315
- ترجمة احترافية للوثائق القانونية بدقة عالية مع إمكانية تنزيلها كملف PDF
316
  </p>
317
  <button class="action-button" onclick="showSection('translation')">ترجم الآن</button>
318
  </div>
@@ -320,9 +313,9 @@
320
  <div class="feature-card p-6">
321
  <div class="text-center">
322
  <i class="fas fa-comments text-3xl mb-4 text-blue-600"></i>
323
- <h3 class="text-xl font-bold text-gray-800 mb-3">استشارة قانونية</h3>
324
  <p class="text-gray-600 mb-4">
325
- احصل على استشارة قانونية فورية من خبرائنا
326
  </p>
327
  <button class="action-button" onclick="showSection('consultation')">استشر الآن</button>
328
  </div>
@@ -330,15 +323,19 @@
330
  </div>
331
  </section>
332
 
333
- <!-- الأقسام الأخرى -->
334
  <!-- قسم التحليل القانوني -->
335
  <section id="analysis" class="section hidden">
336
- <h2 class="text-3xl font-bold text-gray-800 mb-8">التحليل القانوني</h2>
337
  <div class="input-group bg-white rounded p-6 shadow">
338
- <!-- حقل رفع ملف PDF (اختياري) -->
339
- <input type="file" id="analysisPDF" accept=".pdf" class="mb-4" />
340
- <textarea class="w-full p-3 border rounded" placeholder="اكتب وصف القضية أو المستند الذي تريد تحليله..."></textarea>
341
- <button class="action-button mt-4" onclick="handleSubmit('analysis', 'قم بتحليل هذه القضية: ')">تحليل</button>
 
 
 
 
 
342
  <div id="analysisResult" class="mt-4 response-container"></div>
343
  </div>
344
  </section>
@@ -348,17 +345,20 @@
348
  <h2 class="text-3xl font-bold text-gray-800 mb-8">إنشاء مستند قانوني</h2>
349
  <div class="input-group bg-white rounded p-6 shadow">
350
  <textarea class="w-full p-3 border rounded" placeholder="اكتب وصف المستند المطلوب إنشاؤه..."></textarea>
351
- <button class="action-button mt-4" onclick="handleSubmit('documents', 'قم بإنشاء مستند قانوني بناءً على الوصف التالي: ')">إنشاء المستند</button>
352
  <div id="documentsResult" class="mt-4 response-container"></div>
353
  </div>
354
  </section>
355
 
356
- <!-- قسم خريطة التفكير القانونية -->
357
  <section id="mindMap" class="section hidden">
358
  <h2 class="text-3xl font-bold text-gray-800 mb-8">خريطة التفكير القانونية</h2>
359
- <div class="input-group bg-white rounded p-6 shadow">
360
- <textarea class="w-full p-3 border rounded" placeholder="اكتب ��صف الموضوع الذي تريد إنشاء خريطة ذهنية له..."></textarea>
361
- <button class="action-button mt-4" onclick="handleSubmit('mindMap', 'قم بإنشاء خريطة ذهنية قانونية للموضوع التالي: ')">إنشاء خريطة التفكير</button>
 
 
 
362
  <div id="mindMapResult" class="mt-4 response-container"></div>
363
  </div>
364
  </section>
@@ -366,9 +366,16 @@
366
  <!-- قسم البحث القانوني -->
367
  <section id="search" class="section hidden">
368
  <h2 class="text-3xl font-bold text-gray-800 mb-8">البحث القانوني</h2>
369
- <div class="input-group bg-white rounded p-6 shadow">
370
- <textarea class="w-full p-3 border rounded" placeholder="اكتب استعلام البحث القانوني..."></textarea>
371
- <button class="action-button mt-4" onclick="handleSubmit('search', 'ابحث عن معلومات قانونية حول: ')">بحث</button>
 
 
 
 
 
 
 
372
  <div id="searchResult" class="mt-4 response-container"></div>
373
  </div>
374
  </section>
@@ -376,19 +383,23 @@
376
  <!-- قسم الترجمة القانونية -->
377
  <section id="translation" class="section hidden">
378
  <h2 class="text-3xl font-bold text-gray-800 mb-8">الترجمة القانونية</h2>
379
- <div class="input-group bg-white rounded p-6 shadow">
380
- <textarea class="w-full p-3 border rounded" placeholder="اكتب النص المراد ترجمته..."></textarea>
 
 
 
 
381
  <div class="flex gap-4 my-4">
382
- <select class="p-3 rounded border w-full" id="fromLang">
383
  <option value="ar">العربية</option>
384
  <option value="en">الإنجليزية</option>
385
  </select>
386
- <select class="p-3 rounded border w-full" id="toLang">
387
  <option value="en">الإنجليزية</option>
388
  <option value="ar">العربية</option>
389
  </select>
390
  </div>
391
- <button class="action-button" onclick="handleSubmit('translation', 'قم بترجمة هذا النص القانوني: ')">ترجمة</button>
392
  <div id="translationResult" class="mt-4 response-container"></div>
393
  <button id="downloadPDFButton" class="action-button mt-4">تنزيل الترجمة كملف PDF</button>
394
  </div>
@@ -399,7 +410,7 @@
399
  <h2 class="text-3xl font-bold text-gray-800 mb-8">استشارة قانونية</h2>
400
  <div class="input-group bg-white rounded p-6 shadow">
401
  <textarea class="w-full p-3 border rounded" placeholder="اكتب سؤالك القانوني هنا..."></textarea>
402
- <button class="action-button mt-4" onclick="handleSubmit('consultation', 'أحتاج استشارة قانونية في الموضوع التالي: ')">احصل على استشارة</button>
403
  <div id="consultationResult" class="mt-4 response-container"></div>
404
  </div>
405
  </section>
@@ -485,52 +496,61 @@
485
  </div>
486
  </div>
487
  </section>
488
-
489
- <!-- قسم OCR للتعرف على النص من الصورة -->
490
- <section id="ocr" class="section hidden">
491
- <h2 class="text-3xl font-bold text-gray-800 mb-8">OCR التعرف على النص</h2>
492
- <div class="bg-white rounded p-6 shadow">
493
- <article style="text-align: center;">
494
- <h3>نموذج OCR</h3>
495
- <p>هذه الواجهة تقوم بمعالجة الصورة وإجراء التعرف على النص.</p>
496
- </article>
497
- <label for="ocrFile">اختر صورة للرفع
498
- <input type="file" id="ocrFile" name="file" accept="image/*">
499
- </label>
500
- <button id="ocrSubmit" class="action-button mt-4">معالجة الصورة</button>
501
- <h4 id="ocrSpinner" style="text-align: center;" aria-busy="true" hidden>جاري المعالجة...</h4>
502
- <section id="ocrParsed" hidden>
503
- <label for="ocrText">💬 النص المعترف عليه:
504
- <pre id="ocrText" style="padding: 10px;"></pre>
505
- </label>
506
- </section>
507
- <section id="ocrRaw" hidden>
508
- <label for="ocrRawResponse">💬 الاستجابة الخام:
509
- <pre id="ocrRawResponse" style="padding: 10px;"></pre>
510
- </label>
511
- </section>
512
- </div>
513
- </section>
514
  </main>
515
 
516
  <!-- سكربتات الموقع -->
517
  <script>
518
- // تعريف API الأساسي (نقطة /chat) ومصادر أخرى
519
  const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';
520
  const UPLOAD_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/upload';
521
- const OCR_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/ocr';
522
 
523
- // دالة الحصول على البادئة (prompt prefix) لكل قسم
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  function getPromptPrefix(section) {
525
- switch(section) {
526
  case 'analysis':
527
  return 'قم بتحليل هذه القضية: ';
528
  case 'documents':
529
  return 'قم بإنشاء مستند قانوني بناءً على الوصف التالي: ';
530
  case 'mindMap':
531
- return 'قم بإنشاء خريطة ذهنية لحل القضية باستخدام تقنية تونى بوزان الشهيرة: ';
532
  case 'search':
533
- return 'ابحث عن معلومات قانونية حول: [منصات: منصة1، منصة2، منصة3] ';
534
  case 'translation':
535
  return 'قم بترجمة هذا النص القانوني: ';
536
  case 'consultation':
@@ -588,26 +608,26 @@
588
  });
589
  });
590
 
591
- // دالة إرسال الطلبات لكافة الأقسام؛ تأخذ معاملين: القسم و (اختياري) prompt مخصص
592
- async function handleSubmit(section, customPrompt) {
593
  const container = document.getElementById(section);
594
- const resultDiv = container.querySelector(".response-container");
 
595
 
596
- // إذا كان القسم "analysis" نتعامل مع احتمال وجود ملف PDF ونص
597
  if (section === 'analysis') {
598
- const fileInput = container.querySelector("#analysisPDF");
 
 
599
  const textArea = container.querySelector("textarea");
600
- const text = textArea.value.trim();
601
- resultDiv.innerHTML = ''; // مسح النتائج السابقة
602
-
603
  let filePromise = null, textPromise = null;
604
 
605
- // إذا تم إرفاق ملف PDF نقوم برفعه وتحليله
606
  if (fileInput && fileInput.files && fileInput.files.length > 0) {
607
  const file = fileInput.files[0];
608
  let formData = new FormData();
609
- // استخدام المفتاح "files" ليتوافق مع نقطة النهاية في FastAPI
610
- formData.append("files", file);
611
  resultDiv.innerHTML += '<div id="fileAnalysisSpinner" class="loading-spinner"></div>';
612
  filePromise = fetch(UPLOAD_URL, {
613
  method: "POST",
@@ -626,13 +646,9 @@
626
  });
627
  }
628
 
629
- // إذا وُجد نص للتحليل (سواءً مع الملف أو بدونه)
630
  if (text) {
631
  resultDiv.innerHTML += '<div id="textAnalysisSpinner" class="loading-spinner"></div>';
632
- const payload = {
633
- message: (customPrompt || getPromptPrefix(section)) + text,
634
- history: []
635
- };
636
  textPromise = fetch(API_URL, {
637
  method: "POST",
638
  headers: { "Content-Type": "application/json" },
@@ -651,35 +667,137 @@
651
  });
652
  }
653
 
654
- // انتظار انتهاء العمليتين (إن وُجدتا)
655
- const fileResult = filePromise ? await filePromise : null;
656
- const textResult = textPromise ? await textPromise : null;
657
 
658
- // عرض النتائج النهائية
659
  resultDiv.innerHTML = '';
660
- if (fileResult) {
661
- resultDiv.innerHTML += `<div><strong>نتيجة تحليل الملف:</strong><br>${fileResult}</div><br>`;
662
- }
663
- if (textResult) {
664
- resultDiv.innerHTML += `<div><strong>نتيجة تحليل النص:</strong><br>${textResult}</div>`;
665
- }
666
  if (!fileResult && !textResult) {
667
- alert("الرجاء إدخال نص أو إرفاق ملف PDF");
668
  return;
669
  }
670
- } else {
671
- // للأقسام الأخرى التي لا تتطلب رفع ملفات
672
- const textArea = container.querySelector("textarea");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  const text = textArea.value.trim();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
  if (!text) {
675
  alert("الرجاء إدخال نص");
676
  return;
677
  }
678
- const payload = {
679
- message: (customPrompt || getPromptPrefix(section)) + text,
680
- history: []
681
- };
682
-
683
  resultDiv.innerHTML = '<div class="loading-spinner"></div>';
684
  try {
685
  const response = await fetch(API_URL, {
@@ -687,9 +805,7 @@
687
  headers: { "Content-Type": "application/json" },
688
  body: JSON.stringify(payload)
689
  });
690
- if (!response.ok) {
691
- throw new Error("فشل الاستجابة من الخادم");
692
- }
693
  const data = await response.json();
694
  resultDiv.innerHTML = data.response || "";
695
  } catch (error) {
@@ -726,12 +842,114 @@
726
  document.querySelectorAll("#firstPartyID, #secondPartyID").forEach(input => {
727
  input.addEventListener("input", function() {
728
  this.value = this.value.replace(/[^0-9]/g, '');
729
- if (this.value.length > 14) {
730
- this.value = this.value.slice(0, 14);
731
- }
732
  });
733
  });
734
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
  // وظيفة تنزيل الترجمة كملف PDF باستخدام مكتبة jsPDF
736
  document.getElementById("downloadPDFButton").addEventListener("click", function() {
737
  const { jsPDF } = window.jspdf;
@@ -746,12 +964,26 @@
746
  doc.save("translation.pdf");
747
  });
748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  // وظيفة إضافة حقل جديد في قسم خريطة التفكير
750
- document.getElementById("addMindMapField")?.addEventListener("click", function() {
751
  const container = document.getElementById("mindMapFields");
752
  const newFieldDiv = document.createElement("div");
753
  newFieldDiv.className = "mb-4";
754
- newFieldDiv.innerHTML = `<label class="block text-gray-700 font-bold mb-2">خط جديد:</label>
755
  <input type="text" class="w-full p-3 border rounded" placeholder="اكتب فكرة جديدة" />`;
756
  container.appendChild(newFieldDiv);
757
  });
@@ -763,7 +995,7 @@
763
  inputs.forEach((input, index) => {
764
  const value = input.value.trim();
765
  if(value) {
766
- collectedText += `الخيط ${index + 1}: ${value}\n`;
767
  }
768
  });
769
  if (!collectedText.trim()) {
@@ -772,7 +1004,7 @@
772
  }
773
  const resultDiv = document.getElementById("mindMapResult");
774
  const prompt = getPromptPrefix("mindMap") + "\n" + collectedText +
775
- "\nاستخدم منهجيات قوية مثل تحليل SWOT و5 خطوات لتحليل الأسباب الجذرية مع النظر في البدائل القانونية لتنظيم القضية بشكل احترافي.";
776
  resultDiv.innerHTML = '<div class="loading-spinner"></div>';
777
  fetch(API_URL, {
778
  method: "POST",
@@ -789,57 +1021,31 @@
789
  });
790
  }
791
 
792
- // دالة التعامل مع رفع ومعالجة الصورة لنظام OCR
793
- document.getElementById("ocrSubmit").addEventListener("click", async function() {
794
- const fileInput = document.getElementById("ocrFile");
795
- const spinner = document.getElementById("ocrSpinner");
796
- const ocrParsedSection = document.getElementById("ocrParsed");
797
- const ocrRawSection = document.getElementById("ocrRaw");
798
- const ocrTextPre = document.getElementById("ocrText");
799
- const ocrRawResponsePre = document.getElementById("ocrRawResponse");
800
-
801
- if (!fileInput.files || fileInput.files.length === 0) {
802
- alert("الرجاء اختيار صورة.");
803
- return;
804
- }
805
-
806
- const file = fileInput.files[0];
807
- let formData = new FormData();
808
- formData.append("file", file);
809
-
810
- spinner.hidden = false;
811
- ocrParsedSection.hidden = true;
812
- ocrRawSection.hidden = true;
813
-
814
  try {
815
- const response = await fetch(OCR_URL, {
816
- method: "POST",
817
- body: formData
818
- });
819
- const data = await response.json();
820
-
821
- // إذا كان النص طويلاً وقُسِم إلى جزئين، يتم دمجهما للعرض
822
- let recognizedText = "";
823
- if (data.text) {
824
- recognizedText = data.text;
825
- } else if (data.part1 && data.part2) {
826
- recognizedText = data.part1 + "\n\n" + data.part2;
827
- }
828
-
829
- ocrTextPre.textContent = recognizedText;
830
- ocrRawResponsePre.textContent = JSON.stringify(data, null, 2);
831
-
832
- ocrParsedSection.hidden = false;
833
- ocrRawSection.hidden = false;
834
  } catch (error) {
835
- console.error("OCR processing error:", error);
836
- alert("حدث خطأ أثناء معالجة الصورة.");
837
  } finally {
838
- spinner.hidden = true;
839
  }
840
  });
841
 
842
- // تهيئة الصفحة للقسم الافتراضي "home"
843
  document.addEventListener("DOMContentLoaded", () => {
844
  showSection("home");
845
  });
 
9
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
10
  <!-- ربط مكتبة jsPDF لتحويل النص إلى PDF -->
11
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
 
 
12
  <style>
13
  @import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap");
14
 
 
51
  transition: all 0.3s ease;
52
  border-radius: 0.5rem;
53
  margin: 0.25rem 0.5rem;
54
+ cursor: pointer;
55
  }
56
  .nav-link:hover {
57
  background: #f3f4f6;
 
199
  <aside class="sidebar">
200
  <div class="p-6">
201
  <div class="flex items-center gap-4 mb-8">
 
202
  <img src="https://ufastpro.com/wp-content/uploads/2025/02/تصميم-بدون-عنوان.png" alt="شعار المنصة" class="w-12 h-12 rounded-full" />
203
  <div>
204
  <h1 class="text-xl font-bold text-gray-800">المنصة القانونية</h1>
 
212
  </a>
213
  <a href="#" class="nav-link" data-section="analysis">
214
  <i class="fas fa-balance-scale ml-3"></i>
215
+ <span>تحليل القضايا</span>
216
  </a>
217
  <a href="#" class="nav-link" data-section="mindMap">
218
  <i class="fas fa-project-diagram ml-3"></i>
 
232
  </a>
233
  <a href="#" class="nav-link" data-section="consultation">
234
  <i class="fas fa-comments ml-3"></i>
235
+ <span>الاستشارة القانونية</span>
236
  </a>
 
237
  <a href="#" class="nav-link" data-section="contracts">
238
  <i class="fas fa-file-contract ml-3"></i>
239
  <span>العقود</span>
240
  </a>
241
+ <!-- زر الأعمال الادارية: رابط خارجي -->
242
+ <a href="https://example.com/administrative" target="_blank" class="nav-link">
243
+ <i class="fas fa-briefcase ml-3"></i>
244
+ <span>الأعمال الادارية</span>
 
 
 
 
245
  </a>
246
  </nav>
247
  </div>
 
250
  <!-- المحتوى الرئيسي -->
251
  <main class="main-content">
252
  <!-- بحث عالمي -->
253
+ <div class="search-container mb-6 relative">
254
  <input type="text" class="search-input w-full p-3 rounded border" placeholder="ابحث في المنصة..." id="globalSearch" />
255
  <i class="fas fa-search absolute top-1/2 right-4 transform -translate-y-1/2 text-gray-400"></i>
256
  </div>
 
263
  <div class="feature-card p-6">
264
  <div class="text-center">
265
  <i class="fas fa-balance-scale text-3xl mb-4 text-blue-600"></i>
266
+ <h3 class="text-xl font-bold text-gray-800 mb-3">تحليل القضايا</h3>
267
  <p class="text-gray-600 mb-4">
268
+ تحليل متكامل للقضايا والمستندات القانونية باستخدام الذكاء الاصطناعي.
269
  </p>
270
  <button class="action-button" onclick="showSection('analysis')">ابدأ التحليل</button>
271
  </div>
 
275
  <i class="fas fa-project-diagram text-3xl mb-4 text-blue-600"></i>
276
  <h3 class="text-xl font-bold text-gray-800 mb-3">خريطة التفكير</h3>
277
  <p class="text-gray-600 mb-4">
278
+ إنشاء خرائط ذهنية للقضايا القانونية وتحليل العلاقات.
279
  </p>
280
  <button class="action-button" onclick="showSection('mindMap')">إنشاء خريطة</button>
281
  </div>
 
285
  <i class="fas fa-search text-3xl mb-4 text-blue-600"></i>
286
  <h3 class="text-xl font-bold text-gray-800 mb-3">البحث القانوني</h3>
287
  <p class="text-gray-600 mb-4">
288
+ بحث متقدم في السوابق والقضايا القانونية مع عرض المصادر.
289
  </p>
290
  <button class="action-button" onclick="showSection('search')">ابدأ البحث</button>
291
  </div>
 
295
  <i class="fas fa-file-alt text-3xl mb-4 text-blue-600"></i>
296
  <h3 class="text-xl font-bold text-gray-800 mb-3">المستندات</h3>
297
  <p class="text-gray-600 mb-4">
298
+ إنشاء وتحرير المستندات القانونية بمساعدة الذكاء الاصطناعي.
299
  </p>
300
  <button class="action-button" onclick="showSection('documents')">إنشاء مستند</button>
301
  </div>
 
305
  <i class="fas fa-language text-3xl mb-4 text-blue-600"></i>
306
  <h3 class="text-xl font-bold text-gray-800 mb-3">الترجمة القانونية</h3>
307
  <p class="text-gray-600 mb-4">
308
+ ترجمة احترافية للوثائق القانونية مع إمكانية تنزيلها كملف PDF.
309
  </p>
310
  <button class="action-button" onclick="showSection('translation')">ترجم الآن</button>
311
  </div>
 
313
  <div class="feature-card p-6">
314
  <div class="text-center">
315
  <i class="fas fa-comments text-3xl mb-4 text-blue-600"></i>
316
+ <h3 class="text-xl font-bold text-gray-800 mb-3">الاستشارة القانونية</h3>
317
  <p class="text-gray-600 mb-4">
318
+ احصل على استشارة قانونية فورية من خبرائنا.
319
  </p>
320
  <button class="action-button" onclick="showSection('consultation')">استشر الآن</button>
321
  </div>
 
323
  </div>
324
  </section>
325
 
 
326
  <!-- قسم التحليل القانوني -->
327
  <section id="analysis" class="section hidden">
328
+ <h2 class="text-3xl font-bold text-gray-800 mb-8">تحليل القضايا</h2>
329
  <div class="input-group bg-white rounded p-6 shadow">
330
+ <!-- زر اختيار الصورة لتحليلها عبر OCR -->
331
+ <button id="chooseImageButton" class="action-button">اختر صورة للرفع (OCR)</button>
332
+ <!-- حقل رفع صورة مخفي -->
333
+ <input type="file" id="ocrFile" accept="image/*" class="hidden">
334
+ <!-- عرض النص المستخرج من الصورة -->
335
+ <div id="ocrResult" class="mt-4 p-3 border rounded bg-gray-50" style="min-height: 50px;"></div>
336
+ <!-- زر لإرسال النص المُستخرج للتحليل -->
337
+ <button id="analyzeOCRButton" class="action-button mt-4" disabled>تحليل النص</button>
338
+ <!-- عرض نتيجة تحليل النص مع كشف النية والحكم الطبيعي والقضايا المشابهة -->
339
  <div id="analysisResult" class="mt-4 response-container"></div>
340
  </div>
341
  </section>
 
345
  <h2 class="text-3xl font-bold text-gray-800 mb-8">إنشاء مستند قانوني</h2>
346
  <div class="input-group bg-white rounded p-6 shadow">
347
  <textarea class="w-full p-3 border rounded" placeholder="اكتب وصف المستند المطلوب إنشاؤه..."></textarea>
348
+ <button class="action-button mt-4" onclick="handleSubmit('documents')">إنشاء المستند</button>
349
  <div id="documentsResult" class="mt-4 response-container"></div>
350
  </div>
351
  </section>
352
 
353
+ <!-- قسم خريطة التفكير -->
354
  <section id="mindMap" class="section hidden">
355
  <h2 class="text-3xl font-bold text-gray-800 mb-8">خريطة التفكير القانونية</h2>
356
+ <div class="input-group bg-white rounded p-6 shadow space-y-4">
357
+ <textarea id="mindMapDescription" class="w-full p-3 border rounded" placeholder="اكتب وصف الموضوع الذي تريد إنشاء خريطة ذهنية له..."></textarea>
358
+ <!-- حاوية الحقول الإضافية -->
359
+ <div id="mindMapFields" class="space-y-4"></div>
360
+ <button id="addMindMapField" class="action-button">أضف حقل فكرة</button>
361
+ <button class="action-button mt-4" onclick="handleMindMap()">إنشاء خريطة التفكير</button>
362
  <div id="mindMapResult" class="mt-4 response-container"></div>
363
  </div>
364
  </section>
 
366
  <!-- قسم البحث القانوني -->
367
  <section id="search" class="section hidden">
368
  <h2 class="text-3xl font-bold text-gray-800 mb-8">البحث القانوني</h2>
369
+ <div class="input-group bg-white rounded p-6 shadow space-y-4">
370
+ <textarea id="searchQuery" class="w-full p-3 border rounded" placeholder="اكتب استعلام البحث القانوني..."></textarea>
371
+ <!-- قائمة المصادر القانونية القابلة للتعديل -->
372
+ <select id="legalSources" multiple class="p-3 rounded border w-full">
373
+ <option value="المحكمة العليا">المحكمة العليا</option>
374
+ <option value="مجلس القضاء">مجلس القضاء</option>
375
+ <option value="وزارة العدل">وزارة العدل</option>
376
+ <option value="الهيئة الوطنية للقضاء">الهيئة الوطنية للقضاء</option>
377
+ </select>
378
+ <button class="action-button" onclick="handleSubmit('search')">بحث</button>
379
  <div id="searchResult" class="mt-4 response-container"></div>
380
  </div>
381
  </section>
 
383
  <!-- قسم الترجمة القانونية -->
384
  <section id="translation" class="section hidden">
385
  <h2 class="text-3xl font-bold text-gray-800 mb-8">الترجمة القانونية</h2>
386
+ <div class="input-group bg-white rounded p-6 shadow space-y-4">
387
+ <textarea id="translationText" class="w-full p-3 border rounded" placeholder="اكتب النص المراد ترجمته..."></textarea>
388
+ <!-- زر OCR ملف للترجمة -->
389
+ <button id="chooseImageButtonTranslation" class="action-button">OCR ملف</button>
390
+ <!-- حقل رفع صورة مخفي للترجمة -->
391
+ <input type="file" id="translationOCRFile" accept="image/*" class="hidden">
392
  <div class="flex gap-4 my-4">
393
+ <select id="fromLang" class="p-3 rounded border w-full">
394
  <option value="ar">العربية</option>
395
  <option value="en">الإنجليزية</option>
396
  </select>
397
+ <select id="toLang" class="p-3 rounded border w-full">
398
  <option value="en">الإنجليزية</option>
399
  <option value="ar">العربية</option>
400
  </select>
401
  </div>
402
+ <button class="action-button" onclick="handleSubmit('translation')">ترجمة</button>
403
  <div id="translationResult" class="mt-4 response-container"></div>
404
  <button id="downloadPDFButton" class="action-button mt-4">تنزيل الترجمة كملف PDF</button>
405
  </div>
 
410
  <h2 class="text-3xl font-bold text-gray-800 mb-8">استشارة قانونية</h2>
411
  <div class="input-group bg-white rounded p-6 shadow">
412
  <textarea class="w-full p-3 border rounded" placeholder="اكتب سؤالك القانوني هنا..."></textarea>
413
+ <button class="action-button mt-4" onclick="handleSubmit('consultation')">احصل على استشارة</button>
414
  <div id="consultationResult" class="mt-4 response-container"></div>
415
  </div>
416
  </section>
 
496
  </div>
497
  </div>
498
  </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  </main>
500
 
501
  <!-- سكربتات الموقع -->
502
  <script>
503
+ // تعريف API الأساسي (للنصوص وطلبات التحليل)
504
  const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';
505
  const UPLOAD_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/upload';
 
506
 
507
+ // إعدادات OCR باستخدام API4AI (الوضع التجريبي)
508
+ const OCR_MODE = 'demo';
509
+ const OCR_OPTIONS = {
510
+ demo: {
511
+ url: 'https://demo.api4ai.cloud/ocr/v1/results',
512
+ headers: { 'A4A-CLIENT-APP-ID': 'sample' }
513
+ },
514
+ rapidapi: {
515
+ url: 'https://ocr43.p.rapidapi.com/v1/results',
516
+ headers: { 'X-RapidAPI-Key': '' }
517
+ }
518
+ };
519
+
520
+ // دالة استخراج النص من الصورة باستخدام OCR
521
+ function doOCR(file) {
522
+ return new Promise((resolve, reject) => {
523
+ let form = new FormData();
524
+ form.append('image', file);
525
+ fetch(OCR_OPTIONS[OCR_MODE].url, {
526
+ method: 'POST',
527
+ body: form,
528
+ headers: OCR_OPTIONS[OCR_MODE].headers
529
+ })
530
+ .then(response => response.json())
531
+ .then(data => {
532
+ try {
533
+ const extractedText = data.results[0].entities[0].objects[0].entities[0].text;
534
+ resolve(extractedText);
535
+ } catch (e) {
536
+ reject('خطأ في استخراج النص من الصورة');
537
+ }
538
+ })
539
+ .catch(err => reject(err));
540
+ });
541
+ }
542
+
543
+ // دالة الحصول على البادئة (prompt prefix) بناءً على القسم
544
  function getPromptPrefix(section) {
545
+ switch(section) {
546
  case 'analysis':
547
  return 'قم بتحليل هذه القضية: ';
548
  case 'documents':
549
  return 'قم بإنشاء مستند قانوني بناءً على الوصف التالي: ';
550
  case 'mindMap':
551
+ return 'قم بإنشاء خريطة ذهنية لحل القضية: ';
552
  case 'search':
553
+ return 'ابحث عن معلومات قانونية حول: ';
554
  case 'translation':
555
  return 'قم بترجمة هذا النص القانوني: ';
556
  case 'consultation':
 
608
  });
609
  });
610
 
611
+ // دالة إرسال الطلبات للأقسام المختلفة
612
+ async function handleSubmit(section) {
613
  const container = document.getElementById(section);
614
+ let resultDiv;
615
+ let payload = { history: [] };
616
 
617
+ // خاص للتعامل مع الأقسام التي تحتوي على ملف أو نص
618
  if (section === 'analysis') {
619
+ resultDiv = container.querySelector(".response-container");
620
+ // التعامل مع رفع ملف (PDF أو صورة)
621
+ const fileInput = container.querySelector("#ocrFile");
622
  const textArea = container.querySelector("textarea");
623
+ const text = textArea ? textArea.value.trim() : "";
624
+ resultDiv.innerHTML = '';
 
625
  let filePromise = null, textPromise = null;
626
 
 
627
  if (fileInput && fileInput.files && fileInput.files.length > 0) {
628
  const file = fileInput.files[0];
629
  let formData = new FormData();
630
+ formData.append("file", file);
 
631
  resultDiv.innerHTML += '<div id="fileAnalysisSpinner" class="loading-spinner"></div>';
632
  filePromise = fetch(UPLOAD_URL, {
633
  method: "POST",
 
646
  });
647
  }
648
 
 
649
  if (text) {
650
  resultDiv.innerHTML += '<div id="textAnalysisSpinner" class="loading-spinner"></div>';
651
+ payload.message = getPromptPrefix(section) + text;
 
 
 
652
  textPromise = fetch(API_URL, {
653
  method: "POST",
654
  headers: { "Content-Type": "application/json" },
 
667
  });
668
  }
669
 
670
+ const fileResult = filePromise ? await filePromise : "";
671
+ const textResult = textPromise ? await textPromise : "";
 
672
 
 
673
  resultDiv.innerHTML = '';
674
+ if (fileResult) resultDiv.innerHTML += `<div><strong>نتيجة تحليل الملف:</strong><br>${fileResult}</div><br>`;
675
+ if (textResult) resultDiv.innerHTML += `<div><strong>نتيجة تحليل النص:</strong><br>${textResult}</div>`;
 
 
 
 
676
  if (!fileResult && !textResult) {
677
+ alert("الرجاء إدخال نص أو إرفاق ملف");
678
  return;
679
  }
680
+
681
+ // دمج النتائج للتحليل
682
+ let combinedText = "";
683
+ if (typeof fileResult === "string") combinedText += fileResult + "\n";
684
+ if (typeof textResult === "string") combinedText += textResult + "\n";
685
+
686
+ // خطوة كشف نية القضية
687
+ resultDiv.innerHTML += '<div id="intentSpinner" class="loading-spinner"></div>';
688
+ try {
689
+ const intentPayload = {
690
+ message: "كشف نية لهذه القضية (مثل: قتل، سرقة) بناءً على النص التالي:\n" + combinedText,
691
+ history: []
692
+ };
693
+ const intentResponse = await fetch(API_URL, {
694
+ method: "POST",
695
+ headers: { "Content-Type": "application/json" },
696
+ body: JSON.stringify(intentPayload)
697
+ });
698
+ if (!intentResponse.ok) throw new Error("فشل الكشف عن نية القضية");
699
+ const intentData = await intentResponse.json();
700
+ const caseNature = intentData.response || "غير محدد";
701
+ resultDiv.innerHTML += `<br><div><strong>كشف نية القضية:</strong> ${caseNature}</div>`;
702
+
703
+ // البحث عن الحكم الطبيعي للقضية
704
+ resultDiv.innerHTML += '<div id="rulingSpinner" class="loading-spinner"></div>';
705
+ const searchPayload = {
706
+ message: "ابحث عن حكم طبيعي لقضية " + caseNature,
707
+ history: []
708
+ };
709
+ const rulingResponse = await fetch(API_URL, {
710
+ method: "POST",
711
+ headers: { "Content-Type": "application/json" },
712
+ body: JSON.stringify(searchPayload)
713
+ });
714
+ if (!rulingResponse.ok) throw new Error("فشل الحصول على الحكم الطبيعي");
715
+ const rulingData = await rulingResponse.json();
716
+ const ruling = rulingData.response || "";
717
+ resultDiv.innerHTML += `<br><div><strong>الحكم الطبيعي:</strong><br>${ruling}</div>`;
718
+
719
+ // البحث عن قضايا مشابهة
720
+ resultDiv.innerHTML += '<div id="similarSpinner" class="loading-spinner"></div>';
721
+ const similarPayload = {
722
+ message: "ابحث عن قضايا مشابهة لقضية " + caseNature,
723
+ history: []
724
+ };
725
+ const similarResponse = await fetch(API_URL, {
726
+ method: "POST",
727
+ headers: { "Content-Type": "application/json" },
728
+ body: JSON.stringify(similarPayload)
729
+ });
730
+ if (!similarResponse.ok) throw new Error("فشل البحث عن القضايا المشابهة");
731
+ const similarData = await similarResponse.json();
732
+ const similarCases = similarData.response || "";
733
+ resultDiv.innerHTML += `<br><div><strong>القضايا المشابهة:</strong><br>${similarCases}</div>`;
734
+ } catch (error) {
735
+ console.error("Error in intent/ruling analysis:", error);
736
+ resultDiv.innerHTML += `<br><div class="text-red-500">حدث خطأ أثناء الكشف عن نية القضية أو البحث عن الحكم الطبيعي/القضايا المشابهة.</div>`;
737
+ }
738
+ }
739
+ else if (section === 'translation') {
740
+ resultDiv = document.getElementById("translationResult");
741
+ const textArea = document.getElementById("translationText");
742
  const text = textArea.value.trim();
743
+ if (!text) {
744
+ alert("الرجاء إدخال نص للترجمة");
745
+ return;
746
+ }
747
+ // إذا كان البحث في الترجمة لا يحتاج لملفات، نقوم بإرسال النص فقط
748
+ payload.message = getPromptPrefix(section) + text;
749
+ resultDiv.innerHTML = '<div class="loading-spinner"></div>';
750
+ try {
751
+ const response = await fetch(API_URL, {
752
+ method: "POST",
753
+ headers: { "Content-Type": "application/json" },
754
+ body: JSON.stringify(payload)
755
+ });
756
+ if (!response.ok) throw new Error("فشل الاستجابة من الخادم");
757
+ const data = await response.json();
758
+ resultDiv.innerHTML = data.response || "";
759
+ } catch (error) {
760
+ console.error("Error:", error);
761
+ resultDiv.innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
762
+ }
763
+ }
764
+ else if (section === 'search') {
765
+ resultDiv = document.getElementById("searchResult");
766
+ const queryText = document.getElementById("searchQuery").value.trim();
767
+ if (!queryText) {
768
+ alert("الرجاء إدخال استعلام البحث");
769
+ return;
770
+ }
771
+ // الحصول على المصادر القانونية المختارة
772
+ const sourcesSelect = document.getElementById("legalSources");
773
+ const selectedSources = Array.from(sourcesSelect.selectedOptions).map(opt => opt.value).join(", ");
774
+ let extra = selectedSources ? " المصادر المستخدمة: " + selectedSources : "";
775
+ payload.message = getPromptPrefix(section) + queryText + extra;
776
+ resultDiv.innerHTML = '<div class="loading-spinner"></div>';
777
+ try {
778
+ const response = await fetch(API_URL, {
779
+ method: "POST",
780
+ headers: { "Content-Type": "application/json" },
781
+ body: JSON.stringify(payload)
782
+ });
783
+ if (!response.ok) throw new Error("فشل الاستجابة من الخادم");
784
+ const data = await response.json();
785
+ resultDiv.innerHTML = data.response || "";
786
+ } catch (error) {
787
+ console.error("Error:", error);
788
+ resultDiv.innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
789
+ }
790
+ }
791
+ else {
792
+ // للأقسام الأخرى (documents, consultation، الخ)
793
+ resultDiv = container.querySelector(".response-container") || container.querySelector("#consultationResult");
794
+ const textarea = container.querySelector("textarea");
795
+ const text = textarea.value.trim();
796
  if (!text) {
797
  alert("الرجاء إدخال نص");
798
  return;
799
  }
800
+ payload.message = getPromptPrefix(section) + text;
 
 
 
 
801
  resultDiv.innerHTML = '<div class="loading-spinner"></div>';
802
  try {
803
  const response = await fetch(API_URL, {
 
805
  headers: { "Content-Type": "application/json" },
806
  body: JSON.stringify(payload)
807
  });
808
+ if (!response.ok) throw new Error("فشل الاستجابة من الخادم");
 
 
809
  const data = await response.json();
810
  resultDiv.innerHTML = data.response || "";
811
  } catch (error) {
 
842
  document.querySelectorAll("#firstPartyID, #secondPartyID").forEach(input => {
843
  input.addEventListener("input", function() {
844
  this.value = this.value.replace(/[^0-9]/g, '');
845
+ if (this.value.length > 14) this.value = this.value.slice(0, 14);
 
 
846
  });
847
  });
848
 
849
+ // وظيفة زر إنشاء العقد
850
+ document.getElementById("generateButton").addEventListener("click", async function() {
851
+ const button = this;
852
+ const outputDiv = document.getElementById("contractOutput");
853
+ const formData = {
854
+ contractTitle: document.getElementById("contractTitle").value.trim(),
855
+ contractDate: document.getElementById("contractDate").value,
856
+ firstPartyName: document.getElementById("firstPartyName").value.trim(),
857
+ firstPartyID: document.getElementById("firstPartyID").value.trim(),
858
+ firstPartyTitle: document.getElementById("firstPartyTitle").value.trim(),
859
+ firstPartyNationality: document.getElementById("firstPartyNationality").value.trim(),
860
+ firstPartyAddress: document.getElementById("firstPartyAddress").value.trim(),
861
+ secondPartyName: document.getElementById("secondPartyName").value.trim(),
862
+ secondPartyID: document.getElementById("secondPartyID").value.trim(),
863
+ secondPartyTitle: document.getElementById("secondPartyTitle").value.trim(),
864
+ secondPartyNationality: document.getElementById("secondPartyNationality").value.trim(),
865
+ secondPartyAddress: document.getElementById("secondPartyAddress").value.trim(),
866
+ contractPreamble: document.getElementById("contractPreamble").value.trim(),
867
+ contractTerms: document.getElementById("contractTerms").value.trim()
868
+ };
869
+
870
+ const requiredFields = Object.keys(formData);
871
+ const missingFields = requiredFields.filter(field => !formData[field]);
872
+ if (missingFields.length > 0) {
873
+ outputDiv.innerHTML = `
874
+ <div class="text-red-500 font-bold mb-4">يرجى ملء جميع الحقول المطلوبة</div>
875
+ <ul class="list-disc list-inside text-red-500">
876
+ ${missingFields.map(field => `<li>${field}</li>`).join('')}
877
+ </ul>
878
+ `;
879
+ return;
880
+ }
881
+
882
+ button.textContent = 'جاري إنشاء العقد...';
883
+ button.disabled = true;
884
+ outputDiv.innerHTML = `
885
+ <div class="flex items-center justify-center space-x-4 text-gray-600">
886
+ <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
887
+ <span>جاري إنشاء العقد باستخدام الذكاء الاصطناعي...</span>
888
+ </div>
889
+ `;
890
+
891
+ try {
892
+ const dateObj = new Date(formData.contractDate);
893
+ const arabicDate = new Intl.DateTimeFormat('ar-EG', {
894
+ year: 'numeric',
895
+ month: 'long',
896
+ day: 'numeric'
897
+ }).format(dateObj);
898
+
899
+ const prompt = `قم بإنشاء عقد قانوني مصري رسمي باللغة العربية يتضمن البيانات التالية:
900
+
901
+ عنوان العقد: ${formData.contractTitle}
902
+ تاريخ العقد: ${arabicDate}
903
+
904
+ الطرف الأول:
905
+ - الاسم: ${formData.firstPartyName}
906
+ - الرقم القومي: ${formData.firstPartyID}
907
+ - الصفة: ${formData.firstPartyTitle}
908
+ - الجنسية: ${formData.firstPartyNationality}
909
+ - العنوان: ${formData.firstPartyAddress}
910
+
911
+ الطرف الثاني:
912
+ - الاسم: ${formData.secondPartyName}
913
+ - الرقم القومي: ${formData.secondPartyID}
914
+ - الصفة: ${formData.secondPartyTitle}
915
+ - الجنسية: ${formData.secondPartyNationality}
916
+ - العنوان: ${formData.secondPartyAddress}
917
+
918
+ التمهيد:
919
+ ${formData.contractPreamble}
920
+
921
+ بنود العقد:
922
+ ${formData.contractTerms}
923
+
924
+ يجب أن يتضمن العقد:
925
+ 1. النص القانوني: "وبعد أن أقر طرفي هذا العقد بكامل أهليتهما المعتبرة قانوناً وشرعاً وبخلو إرادتهما من أي عيب من عيوب الإرادة وبأنهما غير ممنوعين من التصرف وغير محجور عليهما لأي سبب من الأسباب وعدم خضوعهم لقانون الحراسات أو الكسب غير المشروع وبخلوهما من كافة الموانع القانونية والشرعية اللازمة للتعاقد اتفقوا على الآتي"
926
+ 2. بند حكم التمهيد يوضح أن التمهيد جزء لا يتجزأ من العقد
927
+ 3. تنسيق قانوني رسمي
928
+ 4. مكان للتوقيع في النهاية مع كتابة "طرف أول" و "طرف ثاني"`;
929
+
930
+ const response = await fetch(API_URL, {
931
+ method: 'POST',
932
+ headers: { 'Content-Type': 'application/json' },
933
+ body: JSON.stringify({ message: prompt, history: [] })
934
+ });
935
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
936
+ const data = await response.json();
937
+ outputDiv.innerHTML = `<div dir="rtl" style="white-space: pre-wrap;">${data.response}</div>`;
938
+ } catch (error) {
939
+ outputDiv.innerHTML = `
940
+ <div class="text-red-600 font-bold">
941
+ عذراً، حدث خطأ في إنشاء العقد. يرجى المحاولة مرة أخرى.
942
+ <br>
943
+ تفاصيل الخطأ: ${error.message}
944
+ </div>
945
+ `;
946
+ console.error('Error:', error);
947
+ } finally {
948
+ button.textContent = 'إنشاء العقد';
949
+ button.disabled = false;
950
+ }
951
+ });
952
+
953
  // وظيفة تنزيل الترجمة كملف PDF باستخدام مكتبة jsPDF
954
  document.getElementById("downloadPDFButton").addEventListener("click", function() {
955
  const { jsPDF } = window.jspdf;
 
964
  doc.save("translation.pdf");
965
  });
966
 
967
+ // وظيفة تنزيل تحليل القضايا كملف PDF باستخدام مكتبة jsPDF
968
+ document.getElementById("downloadAnalysisPDFButton")?.addEventListener("click", function() {
969
+ const { jsPDF } = window.jspdf;
970
+ const doc = new jsPDF({ orientation: "portrait", unit: "pt", format: "a4" });
971
+ const content = document.getElementById("analysisResult").innerText;
972
+ if (!content.trim()) {
973
+ alert("لا يوجد نص للتحليل لتنزيله");
974
+ return;
975
+ }
976
+ doc.setFont("Tajawal", "normal");
977
+ doc.text(content, 40, 60, { maxWidth: 515 });
978
+ doc.save("analysis.pdf");
979
+ });
980
+
981
  // وظيفة إضافة حقل جديد في قسم خريطة التفكير
982
+ document.getElementById("addMindMapField").addEventListener("click", function() {
983
  const container = document.getElementById("mindMapFields");
984
  const newFieldDiv = document.createElement("div");
985
  newFieldDiv.className = "mb-4";
986
+ newFieldDiv.innerHTML = `<label class="block text-gray-700 font-bold mb-2">حقل فكرة:</label>
987
  <input type="text" class="w-full p-3 border rounded" placeholder="اكتب فكرة جديدة" />`;
988
  container.appendChild(newFieldDiv);
989
  });
 
995
  inputs.forEach((input, index) => {
996
  const value = input.value.trim();
997
  if(value) {
998
+ collectedText += `الفكرة ${index + 1}: ${value}\n`;
999
  }
1000
  });
1001
  if (!collectedText.trim()) {
 
1004
  }
1005
  const resultDiv = document.getElementById("mindMapResult");
1006
  const prompt = getPromptPrefix("mindMap") + "\n" + collectedText +
1007
+ "\nاستخدم منهجيات مثل تحليل SWOT و5 خطوات لتحليل الأسباب الجذرية لتنظيم القضية بشكل احترافي.";
1008
  resultDiv.innerHTML = '<div class="loading-spinner"></div>';
1009
  fetch(API_URL, {
1010
  method: "POST",
 
1021
  });
1022
  }
1023
 
1024
+ // وظيفة رفع ملف OCR في قسم الترجمة: عند الضغط على زر "OCR ملف"
1025
+ document.getElementById("chooseImageButtonTranslation").addEventListener("click", function() {
1026
+ document.getElementById("translationOCRFile").click();
1027
+ });
1028
+ // عند اختيار ملف في قسم الترجمة يتم استخراج النص ووضعه في حقل الترجمة
1029
+ document.getElementById("translationOCRFile").addEventListener("change", async function() {
1030
+ const file = this.files[0];
1031
+ if (!file) return;
1032
+ const textArea = document.getElementById("translationText");
1033
+ textArea.value = "";
1034
+ // إظهار مؤشر التحميل مؤقتاً
1035
+ const originalPlaceholder = textArea.placeholder;
1036
+ textArea.placeholder = "جارٍ استخراج النص من الصورة...";
 
 
 
 
 
 
 
 
 
1037
  try {
1038
+ const ocrText = await doOCR(file);
1039
+ textArea.value = ocrText;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
  } catch (error) {
1041
+ console.error("Error in translation OCR:", error);
1042
+ alert("حدث خطأ أثناء استخراج النص من الصورة");
1043
  } finally {
1044
+ textArea.placeholder = originalPlaceholder;
1045
  }
1046
  });
1047
 
1048
+ // تهيئة الصفحة بالقسم الافتراضي "home"
1049
  document.addEventListener("DOMContentLoaded", () => {
1050
  showSection("home");
1051
  });