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

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +87 -3
index.html CHANGED
@@ -9,6 +9,8 @@
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
 
@@ -243,6 +245,11 @@
243
  <i class="fas fa-gavel ml-3"></i>
244
  <span>الأحكام والسوابق</span>
245
  </a>
 
 
 
 
 
246
  </nav>
247
  </div>
248
  </aside>
@@ -478,15 +485,42 @@
478
  </div>
479
  </div>
480
  </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  </main>
482
 
483
  <!-- سكربتات الموقع -->
484
  <script>
485
- // تعريف API الأساسي (نقطة /chat)
486
  const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';
487
  const UPLOAD_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/upload';
 
488
 
489
- // دالة الحصول على البادئة (prompt prefix) بناءً على القسم
490
  function getPromptPrefix(section) {
491
  switch(section) {
492
  case 'analysis':
@@ -755,7 +789,57 @@
755
  });
756
  }
757
 
758
- // تهيئة الصفحة بالقسم الافتراضي "home"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
  document.addEventListener("DOMContentLoaded", () => {
760
  showSection("home");
761
  });
 
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
 
 
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>
255
  </aside>
 
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':
 
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
  });