Spaces:
Running
Running
File size: 34,462 Bytes
0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 0a032b3 454e2e1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>المنصة القانونية الذكية - وإنشاء العقود</title>
<!-- ربط مكتبات Tailwind وFont Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
<!-- ربط مكتبة jsPDF لتحويل النص إلى PDF -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
@import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap");
:root {
--primary-color: #2563eb;
--primary-hover: #1d4ed8;
--background-light: #f8fafc;
--card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
body {
font-family: "Tajawal", sans-serif;
background: var(--background-light);
}
/* الشريط الجانبي */
.sidebar {
background: white;
width: 280px;
position: fixed;
right: 0;
top: 0;
height: 100vh;
z-index: 40;
transition: transform 0.3s ease;
box-shadow: var(--card-shadow);
}
.main-content {
margin-right: 280px;
transition: margin 0.3s ease;
min-height: 100vh;
padding: 2rem;
background: var(--background-light);
}
.nav-link {
display: flex;
align-items: center;
padding: 1rem 1.5rem;
color: #374151;
transition: all 0.3s ease;
border-radius: 0.5rem;
margin: 0.25rem 0.5rem;
}
.nav-link:hover {
background: #f3f4f6;
color: var(--primary-color);
}
.nav-link.active {
background: var(--primary-color);
color: white;
}
.feature-card {
background: white;
border-radius: 1rem;
box-shadow: var(--card-shadow);
transition: all 0.3s ease;
overflow: hidden;
height: 100%;
}
.feature-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.action-button {
background: var(--primary-color);
color: white;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
transition: all 0.3s ease;
border: none;
font-weight: 500;
width: 100%;
text-align: center;
}
.action-button:hover {
background: var(--primary-hover);
transform: translateY(-1px);
}
.input-group {
position: relative;
}
.input-group.focused input,
.input-group.focused textarea {
border-color: var(--primary-color);
transform: translateY(-2px);
}
.loading-spinner {
border: 3px solid #f3f3f3;
border-radius: 50%;
border-top: 3px solid var(--primary-color);
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.response-container {
white-space: pre-wrap;
font-family: "Tajawal", sans-serif;
line-height: 1.6;
max-height: 400px;
overflow-y: auto;
}
/* تنسيق قسم إنشاء العقود */
.split-screen {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
margin-top: 1rem;
}
.contract-card {
background: white;
border-radius: 1.5rem;
box-shadow: var(--card-shadow);
padding: 2rem;
border: 1px solid #f3f4f6;
}
.contract-output {
background: #fafafa;
border-radius: 1rem;
padding: 2rem;
min-height: 300px;
line-height: 1.8;
font-size: 1.1rem;
border: 1px solid #f3f4f6;
white-space: pre-wrap;
}
.copy-btn {
position: absolute;
top: 1rem;
left: 1rem;
padding: 0.5rem 1rem;
background: #f3f4f6;
border-radius: 0.75rem;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.9rem;
color: #4b5563;
}
.copy-btn:hover {
background: #e5e7eb;
}
.success-message {
position: fixed;
bottom: 2rem;
right: 2rem;
background: #10b981;
color: white;
padding: 1rem 2rem;
border-radius: 1rem;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.section-title {
font-size: 1.25rem;
color: #1f2937;
margin-bottom: 1.5rem;
padding-bottom: 0.75rem;
border-bottom: 2px solid #e5e7eb;
font-weight: 600;
}
/* تحسين التنسيق على الأجهزة المحمولة */
@media (max-width: 768px) {
.sidebar { transform: translateX(100%); }
.sidebar.open { transform: translateX(0); }
.main-content { margin-right: 0; }
.split-screen { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<!-- زر إظهار/إخفاء الشريط الجانبي -->
<button id="sidebarToggle" class="fixed top-4 right-4 z-50 p-2 rounded-lg bg-white shadow-lg md:hidden">
<i class="fas fa-bars text-xl"></i>
</button>
<!-- الشريط الجانبي -->
<aside class="sidebar">
<div class="p-6">
<div class="flex items-center gap-4 mb-8">
<!-- استخدام الصورة المطلوبة كشعار -->
<img src="https://ufastpro.com/wp-content/uploads/2025/02/تصميم-بدون-عنوان.png" alt="شعار المنصة" class="w-12 h-12 rounded-full" />
<div>
<h1 class="text-xl font-bold text-gray-800">المنصة القانونية</h1>
<p class="text-sm text-gray-500">خدمات قانونية ذكية</p>
</div>
</div>
<nav class="space-y-1">
<a href="#" class="nav-link active" data-section="home">
<i class="fas fa-home ml-3"></i>
<span>الرئيسية</span>
</a>
<a href="#" class="nav-link" data-section="analysis">
<i class="fas fa-balance-scale ml-3"></i>
<span>التحليل القانوني</span>
</a>
<a href="#" class="nav-link" data-section="mindMap">
<i class="fas fa-project-diagram ml-3"></i>
<span>خريطة التفكير</span>
</a>
<a href="#" class="nav-link" data-section="search">
<i class="fas fa-search ml-3"></i>
<span>البحث القانوني</span>
</a>
<a href="#" class="nav-link" data-section="documents">
<i class="fas fa-file-alt ml-3"></i>
<span>المستندات</span>
</a>
<a href="#" class="nav-link" data-section="translation">
<i class="fas fa-language ml-3"></i>
<span>الترجمة القانونية</span>
</a>
<a href="#" class="nav-link" data-section="consultation">
<i class="fas fa-comments ml-3"></i>
<span>استشارة قانونية</span>
</a>
<!-- رابط قسم إنشاء العقود -->
<a href="#" class="nav-link" data-section="contracts">
<i class="fas fa-file-contract ml-3"></i>
<span>العقود</span>
</a>
<a href="#" class="nav-link" data-section="precedents">
<i class="fas fa-gavel ml-3"></i>
<span>الأحكام والسوابق</span>
</a>
</nav>
</div>
</aside>
<!-- المحتوى الرئيسي -->
<main class="main-content">
<!-- بحث عالمي -->
<div class="search-container mb-6">
<input type="text" class="search-input w-full p-3 rounded border" placeholder="ابحث في المنصة..." id="globalSearch" />
<i class="fas fa-search absolute top-1/2 right-4 transform -translate-y-1/2 text-gray-400"></i>
</div>
<!-- قسم الرئيسية -->
<section id="home" class="section">
<h2 class="text-3xl font-bold text-gray-800 mb-8">الخدمات القانونية</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- بطاقات الخدمة (نفس الشكل كما سابقاً) -->
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-balance-scale text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">التحليل القانوني</h3>
<p class="text-gray-600 mb-4">
تحليل متكامل للقضايا والمستندات القانونية باستخدام الذكاء الاصطناعي
</p>
<button class="action-button" onclick="showSection('analysis')">ابدأ التحليل</button>
</div>
</div>
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-project-diagram text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">خريطة التفكير</h3>
<p class="text-gray-600 mb-4">
إنشاء خرائط ذهنية للقضايا القانونية وتحليل العلاقات
</p>
<button class="action-button" onclick="showSection('mindMap')">إنشاء خريطة</button>
</div>
</div>
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-search text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">البحث القانوني</h3>
<p class="text-gray-600 mb-4">
بحث متقدم في السوابق والقضايا المشابهة
</p>
<button class="action-button" onclick="showSection('search')">ابدأ البحث</button>
</div>
</div>
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-file-alt text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">المستندات</h3>
<p class="text-gray-600 mb-4">
إنشاء وتحرير المستندات القانونية بمساعدة الذكاء الاصطناعي
</p>
<button class="action-button" onclick="showSection('documents')">إنشاء مستند</button>
</div>
</div>
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-language text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">الترجمة القانونية</h3>
<p class="text-gray-600 mb-4">
ترجمة احترافية للوثائق القانونية بدقة عالية مع إمكانية تنزيلها كملف PDF
</p>
<button class="action-button" onclick="showSection('translation')">ترجم الآن</button>
</div>
</div>
<div class="feature-card p-6">
<div class="text-center">
<i class="fas fa-comments text-3xl mb-4 text-blue-600"></i>
<h3 class="text-xl font-bold text-gray-800 mb-3">استشارة قانونية</h3>
<p class="text-gray-600 mb-4">
احصل على استشارة قانونية فورية من خبرائنا
</p>
<button class="action-button" onclick="showSection('consultation')">استشر الآن</button>
</div>
</div>
</div>
</section>
<!-- الأقسام الأخرى (التحليل، المستندات، خريطة التفكير، البحث، الترجمة، الاستشارة) -->
<section id="analysis" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">التحليل القانوني</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب وصف القضية أو المستند الذي تريد تحليله..."></textarea>
<button class="action-button mt-4" onclick="handleSubmit('analysis', 'قم بتحليل هذه القضية: ')">تحليل</button>
<div id="analysisResult" class="mt-4 response-container"></div>
</div>
</section>
<section id="documents" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">إنشاء مستند قانوني</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب وصف المستند المطلوب إنشاؤه..."></textarea>
<button class="action-button mt-4" onclick="handleSubmit('documents', 'قم بإنشاء مستند قانوني بناءً على الوصف التالي: ')">إنشاء المستند</button>
<div id="documentsResult" class="mt-4 response-container"></div>
</div>
</section>
<section id="mindMap" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">خريطة التفكير القانونية</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب وصف الموضوع الذي تريد إنشاء خريطة ذهنية له..."></textarea>
<button class="action-button mt-4" onclick="handleSubmit('mindMap', 'قم بإنشاء خريطة ذهنية قانونية للموضوع التالي: ')">إنشاء خريطة التفكير</button>
<div id="mindMapResult" class="mt-4 response-container"></div>
</div>
</section>
<section id="search" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">البحث القانوني</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب استعلام البحث القانوني..."></textarea>
<button class="action-button mt-4" onclick="handleSubmit('search', 'ابحث عن معلومات قانونية حول: ')">بحث</button>
<div id="searchResult" class="mt-4 response-container"></div>
</div>
</section>
<!-- قسم الترجمة القانونية مع إضافة زر تنزيل PDF -->
<section id="translation" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">الترجمة القانونية</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب النص المراد ترجمته..."></textarea>
<div class="flex gap-4 my-4">
<select class="p-3 rounded border w-full" id="fromLang">
<option value="ar">العربية</option>
<option value="en">الإنجليزية</option>
</select>
<select class="p-3 rounded border w-full" id="toLang">
<option value="en">الإنجليزية</option>
<option value="ar">العربية</option>
</select>
</div>
<button class="action-button" onclick="handleSubmit('translation', 'قم بترجمة هذا النص القانوني: ')">ترجمة</button>
<div id="translationResult" class="mt-4 response-container"></div>
<button id="downloadPDFButton" class="action-button mt-4">تنزيل الترجمة كملف PDF</button>
</div>
</section>
<section id="consultation" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">استشارة قانونية</h2>
<div class="input-group bg-white rounded p-6 shadow">
<textarea class="w-full p-3 border rounded" placeholder="اكتب سؤالك القانوني هنا..."></textarea>
<button class="action-button mt-4" onclick="handleSubmit('consultation', 'أحتاج استشارة قانونية في الموضوع التالي: ')">احصل على استشارة</button>
<div id="consultationResult" class="mt-4 response-container"></div>
</div>
</section>
<!-- قسم إنشاء العقود -->
<section id="contracts" class="section hidden">
<h2 class="text-3xl font-bold text-gray-800 mb-8">منشئ العقود المصري الذكي</h2>
<div class="split-screen">
<!-- نموذج بيانات العقد -->
<div class="contract-card">
<div class="space-y-6">
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">عنوان العقد:</label>
<input type="text" id="contractTitle" placeholder="عنوان العقد" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">تاريخ تحرير العقد:</label>
<input type="date" id="contractDate" class="w-full p-2 border rounded" />
</div>
<h3 class="section-title">بيانات الطرف الأول</h3>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">اسم الطرف الأول:</label>
<input type="text" id="firstPartyName" placeholder="الاسم الكامل" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">الرقم القومي للطرف الأول:</label>
<input type="text" id="firstPartyID" placeholder="14 رقم" maxlength="14" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">الصفة:</label>
<input type="text" id="firstPartyTitle" placeholder="مثال: مالك، مدير شركة" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">جنسية الطرف الأول:</label>
<input type="text" id="firstPartyNationality" placeholder="الجنسية" value="مصري" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">عنوان الطرف الأول:</label>
<input type="text" id="firstPartyAddress" placeholder="العنوان التفصيلي" class="w-full p-2 border rounded" />
</div>
<h3 class="section-title">بيانات الطرف الثاني</h3>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">اسم الطرف الثاني:</label>
<input type="text" id="secondPartyName" placeholder="الاسم الكامل" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">الرقم القومي للطرف الثاني:</label>
<input type="text" id="secondPartyID" placeholder="14 رقم" maxlength="14" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">الصفة:</label>
<input type="text" id="secondPartyTitle" placeholder="مثال: مستأجر، مشتري" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">جنسية الطرف الثاني:</label>
<input type="text" id="secondPartyNationality" placeholder="الجنسية" value="مصري" class="w-full p-2 border rounded" />
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">عنوان الطرف الثاني:</label>
<input type="text" id="secondPartyAddress" placeholder="العنوان التفصيلي" class="w-full p-2 border rounded" />
</div>
<h3 class="section-title">تفاصيل العقد</h3>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">البند التمهيدي:</label>
<textarea id="contractPreamble" placeholder="اكتب مضمون العقد والغرض منه" class="w-full p-2 border rounded h-24"></textarea>
</div>
<div class="mb-4 input-group">
<label class="block text-gray-700 font-bold mb-2">بنود العقد:</label>
<textarea id="contractTerms" placeholder="اكتب بنود العقد الأساسية" class="w-full p-2 border rounded h-48"></textarea>
</div>
</div>
<div class="mt-4 text-center">
<button id="generateButton" class="action-button">إنشاء العقد</button>
</div>
</div>
<!-- عرض العقد المنشأ مع إمكانية النسخ -->
<div class="contract-card relative">
<h3 class="text-2xl font-bold text-gray-800 mb-4">العقد المنشأ</h3>
<button class="copy-btn" id="copyButton">
<i class="fas fa-copy"></i> نسخ العقد
</button>
<div id="contractOutput" class="contract-output"></div>
</div>
</div>
</section>
</main>
<!-- سكربتات الموقع -->
<script>
// تعريف رابط API الخاص بنا
const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';
// تفعيل التنقل بين الأقسام
document.querySelectorAll(".nav-link").forEach(link => {
link.addEventListener("click", (e) => {
e.preventDefault();
const section = e.currentTarget.getAttribute("data-section");
showSection(section);
});
});
function showSection(sectionId) {
document.querySelectorAll(".section").forEach(section => {
section.classList.add("hidden");
});
document.getElementById(sectionId).classList.remove("hidden");
document.querySelectorAll(".nav-link").forEach(link => {
link.classList.remove("active");
if (link.getAttribute("data-section") === sectionId) {
link.classList.add("active");
}
});
}
// زر القائمة على الهاتف
document.getElementById("sidebarToggle").addEventListener("click", () => {
document.querySelector(".sidebar").classList.toggle("open");
});
// إضافة مستمعي الأحداث لحقول الإدخال لتحسين التأثير عند التركيز
document.querySelectorAll("input, textarea").forEach(element => {
element.addEventListener("focus", function() {
const group = this.closest(".input-group");
if(group) group.classList.add("focused");
this.style.transform = 'translateY(-2px)';
});
element.addEventListener("blur", function() {
const group = this.closest(".input-group");
if(group) group.classList.remove("focused");
this.style.transform = 'translateY(0)';
});
});
// دالة إرسال الطلبات العامة (تحليل، مستند، خريطة، بحث، ترجمة، استشارة)
async function handleSubmit(section, promptPrefix) {
// الحصول على textarea والنتيجة
const textarea = document.querySelector(`#${section} textarea`);
const resultDiv = document.getElementById(`${section}Result`) || document.getElementById(`${section}Result`);
const text = textarea.value.trim();
if (!text) {
alert("الرجاء إدخال نص");
return;
}
const payload = {
message: promptPrefix + text,
history: []
};
try {
// عرض مؤشر التحميل
if(document.getElementById(`${section}Result`))
document.getElementById(`${section}Result`).innerHTML = '<div class="loading-spinner"></div>';
else if(resultDiv)
resultDiv.innerHTML = '<div class="loading-spinner"></div>';
const response = await fetch(API_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error("Network response was not ok");
}
const data = await response.json();
if(document.getElementById(`${section}Result`))
document.getElementById(`${section}Result`).innerHTML = data.response || "";
else if(resultDiv)
resultDiv.innerHTML = data.response || "";
} catch (error) {
console.error("Error:", error);
if(document.getElementById(`${section}Result`))
document.getElementById(`${section}Result`).innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
else if(resultDiv)
resultDiv.innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
}
}
// وظيفة زر النسخ في قسم إنشاء العقود
document.getElementById("copyButton").addEventListener("click", async function() {
const contractText = document.getElementById("contractOutput").innerText;
try {
await navigator.clipboard.writeText(contractText);
showSuccessMessage("تم نسخ العقد بنجاح!");
} catch (err) {
console.error("فشل نسخ النص:", err);
}
});
// وظيفة إظهار رسالة النجاح عند النسخ
function showSuccessMessage(message) {
const successMessage = document.createElement("div");
successMessage.className = "success-message animate__animated animate__fadeIn";
successMessage.textContent = message;
document.body.appendChild(successMessage);
setTimeout(() => {
successMessage.classList.add("animate__fadeOut");
setTimeout(() => successMessage.remove(), 300);
}, 2000);
}
// التحقق من صحة الرقم القومي للطرف الأول والثاني
document.querySelectorAll("#firstPartyID, #secondPartyID").forEach(input => {
input.addEventListener("input", function() {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value.length > 14) {
this.value = this.value.slice(0, 14);
}
});
});
// دالة الحصول على تسمية الحقل لعرضها في رسائل الخطأ
function getFieldLabel(field) {
const labels = {
contractTitle: 'عنوان العقد',
contractDate: 'تاريخ العقد',
firstPartyName: 'اسم الطرف الأول',
firstPartyID: 'الرقم القومي للطرف الأول',
firstPartyTitle: 'صفة الطرف الأول',
firstPartyNationality: 'جنسية الطرف الأول',
firstPartyAddress: 'عنوان الطرف الأول',
secondPartyName: 'اسم الطرف الثاني',
secondPartyID: 'الرقم القومي للطرف الثاني',
secondPartyTitle: 'صفة الطرف الثاني',
secondPartyNationality: 'جنسية الطرف الثاني',
secondPartyAddress: 'عنوان الطرف الثاني',
contractPreamble: 'البند التمهيدي',
contractTerms: 'بنود العقد'
};
return labels[field] || field;
}
// وظيفة زر إنشاء العقد
document.getElementById("generateButton").addEventListener("click", async function() {
const button = this;
const outputDiv = document.getElementById("contractOutput");
// جمع بيانات النموذج
const formData = {
contractTitle: document.getElementById("contractTitle").value.trim(),
contractDate: document.getElementById("contractDate").value,
firstPartyName: document.getElementById("firstPartyName").value.trim(),
firstPartyID: document.getElementById("firstPartyID").value.trim(),
firstPartyTitle: document.getElementById("firstPartyTitle").value.trim(),
firstPartyNationality: document.getElementById("firstPartyNationality").value.trim(),
firstPartyAddress: document.getElementById("firstPartyAddress").value.trim(),
secondPartyName: document.getElementById("secondPartyName").value.trim(),
secondPartyID: document.getElementById("secondPartyID").value.trim(),
secondPartyTitle: document.getElementById("secondPartyTitle").value.trim(),
secondPartyNationality: document.getElementById("secondPartyNationality").value.trim(),
secondPartyAddress: document.getElementById("secondPartyAddress").value.trim(),
contractPreamble: document.getElementById("contractPreamble").value.trim(),
contractTerms: document.getElementById("contractTerms").value.trim()
};
// التحقق من البيانات المطلوبة
const requiredFields = Object.keys(formData);
const missingFields = requiredFields.filter(field => !formData[field]);
if (missingFields.length > 0) {
outputDiv.innerHTML = `
<div class="text-red-500 font-bold mb-4">يرجى ملء جميع الحقول المطلوبة</div>
<ul class="list-disc list-inside text-red-500">
${missingFields.map(field => `<li>${getFieldLabel(field)}</li>`).join('')}
</ul>
`;
return;
}
// تحديث واجهة المستخدم لحالة التحميل
button.textContent = 'جاري إنشاء العقد...';
button.disabled = true;
outputDiv.innerHTML = `
<div class="flex items-center justify-center space-x-4 text-gray-600">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
<span>جاري إنشاء العقد باستخدام الذكاء الاصطناعي...</span>
</div>
`;
try {
// تحويل التاريخ إلى التنسيق العربي
const dateObj = new Date(formData.contractDate);
const arabicDate = new Intl.DateTimeFormat('ar-EG', {
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(dateObj);
// إنشاء نص الطلب
const prompt = `قم بإنشاء عقد قانوني مصري رسمي باللغة العربية يتضمن البيانات التالية:
عنوان العقد: ${formData.contractTitle}
تاريخ العقد: ${arabicDate}
الطرف الأول:
- الاسم: ${formData.firstPartyName}
- الرقم القومي: ${formData.firstPartyID}
- الصفة: ${formData.firstPartyTitle}
- الجنسية: ${formData.firstPartyNationality}
- العنوان: ${formData.firstPartyAddress}
الطرف الثاني:
- الاسم: ${formData.secondPartyName}
- الرقم القومي: ${formData.secondPartyID}
- الصفة: ${formData.secondPartyTitle}
- الجنسية: ${formData.secondPartyNationality}
- العنوان: ${formData.secondPartyAddress}
التمهيد:
${formData.contractPreamble}
بنود العقد:
${formData.contractTerms}
يجب أن يتضمن العقد:
1. النص القانوني: "وبعد أن أقر طرفي هذا العقد بكامل أهليتهما المعتبرة قانوناً وشرعاً وبخلو إرادتهما من أي عيب من عيوب الإرادة وبأنهما غير ممنوعين من التصرف وغير محجور عليهما لأي سبب من الأسباب وعدم خضوعهم لقانون الحراسات أو الكسب غير المشروع وبخلوهما من كافة الموانع القانونية والشرعية اللازمة للتعاقد اتفقوا على الآتي"
2. بند حكم التمهيد يوضح أن التمهيد جزء لا يتجزأ من العقد
3. تنسيق قانوني رسمي
4. مكان للتوقيع في النهاية مع كتابة "طرف أول" و "طرف ثاني"`;
// إرسال الطلب إلى API
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: prompt,
history: []
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
outputDiv.innerHTML = `<div dir="rtl" style="white-space: pre-wrap;">${data.response}</div>`;
} catch (error) {
outputDiv.innerHTML = `
<div class="text-red-600 font-bold">
عذراً، حدث خطأ في إنشاء العقد. يرجى المحاولة مرة أخرى.
<br>
تفاصيل الخطأ: ${error.message}
</div>
`;
console.error('Error:', error);
} finally {
button.textContent = 'إنشاء العقد';
button.disabled = false;
}
});
// وظيفة تنزيل الترجمة كملف PDF (باستخدام مكتبة jsPDF)
document.getElementById("downloadPDFButton").addEventListener("click", function() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: "portrait", unit: "pt", format: "a4" });
const content = document.getElementById("translationResult").innerText;
if (!content.trim()) {
alert("لا يوجد نص للترجمة لتنزيله");
return;
}
doc.setFont("Tajawal", "normal");
doc.text(content, 40, 60, { maxWidth: 515 });
doc.save("translation.pdf");
});
// تهيئة الصفحة بالعرض الافتراضي للقسم "home"
document.addEventListener("DOMContentLoaded", () => {
showSection("home");
});
</script>
</body>
</html>
|