amrora0011 commited on
Commit
e0b995f
·
verified ·
1 Parent(s): cc215a2

Add 2 files

Browse files
Files changed (2) hide show
  1. index.html +175 -166
  2. prompts.txt +2 -1
index.html CHANGED
@@ -1,4 +1,4 @@
1
- سأقوم بإصلاح مشكلة اختيار البلد عند الضغط عليها. المشكلة تكمن في أن الدالة `selectCountry` غير معرّفة بشكل صحيح أو غير مرتبطة بشكل صحيح بالأزرار. إليك الكود المعدل:
2
 
3
  ```html
4
  <!DOCTYPE html>
@@ -57,11 +57,11 @@
57
  <div class="bg-white rounded-lg p-8 w-full max-w-md mx-4">
58
  <h2 class="text-2xl font-bold text-center mb-6">اختر بلدك</h2>
59
  <div class="flex flex-col space-y-4">
60
- <button class="flex items-center justify-center py-4 px-6 border border-gray-300 rounded-lg hover:bg-gray-100 transition country-btn" data-country="sa">
61
  <img src="https://flagcdn.com/w20/sa.png" class="country-flag" alt="Saudi Arabia">
62
  <span class="font-medium">السعودية (ريال سعودي)</span>
63
  </button>
64
- <button class="flex items-center justify-center py-4 px-6 border border-gray-300 rounded-lg hover:bg-gray-100 transition country-btn" data-country="eg">
65
  <img src="https://flagcdn.com/w20/eg.png" class="country-flag" alt="Egypt">
66
  <span class="font-medium">مصر (جنيه مصري)</span>
67
  </button>
@@ -74,25 +74,25 @@
74
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
75
  <div class="flex justify-between h-16">
76
  <div class="flex items-center">
77
- <a href="#" class="flex-shrink-0 flex items-center">
78
  <span class="text-blue-600 font-bold text-xl">جاري</span>
79
  </a>
80
  </div>
81
  <div class="hidden md:ml-6 md:flex md:items-center md:space-x-4 space-x-reverse">
82
- <button id="homeTab" class="px-3 py-2 text-sm font-medium tab-active">الرئيسية</button>
83
- <button id="addItemTab" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">إضافة غرض</button>
84
- <button id="loginTab" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">تسجيل الدخول</button>
85
- <button id="profileTab" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600 hidden">حسابي</button>
86
- <button id="logoutBtn" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600 hidden">تسجيل خروج</button>
87
  <div id="countrySelector" class="flex items-center">
88
  <span id="currentCountry" class="text-sm text-gray-600"></span>
89
- <button class="ml-2 text-blue-600 hover:text-blue-800 text-sm change-country-btn">
90
  <i class="fas fa-exchange-alt"></i>
91
  </button>
92
  </div>
93
  </div>
94
  <div class="-mr-2 flex items-center md:hidden">
95
- <button class="inline-flex items-center justify-center p-2 rounded-md text-gray-700 hover:text-blue-600 hover:bg-gray-100 focus:outline-none mobile-menu-btn">
96
  <i class="fas fa-bars text-xl"></i>
97
  </button>
98
  </div>
@@ -102,14 +102,14 @@
102
  <!-- Mobile menu -->
103
  <div id="mobileMenu" class="hidden md:hidden bg-white border-t">
104
  <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
105
- <button class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 home-btn">الرئيسية</button>
106
- <button class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 add-item-btn">إضافة غرض</button>
107
- <button id="mobileLoginTab" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 login-btn">تسجيل الدخول</button>
108
- <button id="mobileProfileTab" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 hidden profile-btn">حسابي</button>
109
- <button id="mobileLogoutBtn" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 hidden logout-btn">تسجيل خروج</button>
110
  <div class="flex items-center justify-between px-3 py-2">
111
  <span id="mobileCurrentCountry" class="text-sm text-gray-600"></span>
112
- <button class="text-blue-600 hover:text-blue-800 text-sm change-country-btn">
113
  <i class="fas fa-exchange-alt"></i> تغيير البلد
114
  </button>
115
  </div>
@@ -285,7 +285,7 @@
285
  <h1 class="text-2xl font-bold">حسابي</h1>
286
  <p id="profileEmail" class="text-blue-100 mt-1"></p>
287
  </div>
288
- <button class="bg-white text-blue-600 px-4 py-2 rounded-md text-sm font-medium hover:bg-blue-50 edit-profile-btn">
289
  تعديل الملف الشخصي
290
  </button>
291
  </div>
@@ -340,7 +340,7 @@
340
  <!-- Edit Profile Page -->
341
  <div id="editProfilePage" class="hidden max-w-2xl mx-auto">
342
  <div class="flex items-center mb-6">
343
- <button class="text-blue-600 hover:text-blue-800 mr-2 back-to-profile-btn">
344
  <i class="fas fa-arrow-right"></i>
345
  </button>
346
  <h1 class="text-2xl font-bold text-gray-900">تعديل الملف الشخصي</h1>
@@ -385,7 +385,7 @@
385
  <div class="bg-white rounded-lg p-6 w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto">
386
  <div class="flex justify-between items-start mb-4">
387
  <h2 id="itemDetailsTitle" class="text-xl font-bold"></h2>
388
- <button class="text-gray-500 hover:text-gray-700 close-item-details-btn">
389
  <i class="fas fa-times"></i>
390
  </button>
391
  </div>
@@ -432,7 +432,7 @@
432
 
433
  <div class="flex items-center">
434
  <input type="text" id="itemDetailsMessage" placeholder="اكتب رسالتك..." class="flex-1 border border-gray-300 rounded-l-md py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
435
- <button class="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700 send-message-btn">
436
  <i class="fas fa-paper-plane"></i>
437
  </button>
438
  </div>
@@ -441,7 +441,7 @@
441
  </div>
442
 
443
  <div class="mt-6 pt-4 border-t">
444
- <button id="rentItemBtn" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 request-rental-btn">
445
  طلب الإيجار
446
  </button>
447
  </div>
@@ -453,7 +453,7 @@
453
  <div class="bg-white rounded-lg p-6 w-full max-w-md mx-4">
454
  <div class="flex justify-between items-start mb-4">
455
  <h2 class="text-xl font-bold">طلب إيجار</h2>
456
- <button class="text-gray-500 hover:text-gray-700 close-rental-modal-btn">
457
  <i class="fas fa-times"></i>
458
  </button>
459
  </div>
@@ -488,7 +488,7 @@
488
  <div class="bg-white rounded-lg p-6 w-full max-w-md mx-4">
489
  <div class="flex justify-between items-start mb-4">
490
  <h2 id="rentalRequestTitle" class="text-xl font-bold">تفاصيل طلب الإيجار</h2>
491
- <button class="text-gray-500 hover:text-gray-700 close-rental-details-btn">
492
  <i class="fas fa-times"></i>
493
  </button>
494
  </div>
@@ -534,9 +534,9 @@
534
  <div>
535
  <h3 class="text-lg font-medium text-gray-900 mb-4">روابط سريعة</h3>
536
  <ul class="space-y-2">
537
- <li><a href="#" class="text-gray-500 hover:text-blue-600 text-sm home-link">الرئيسية</a></li>
538
- <li><a href="#" class="text-gray-500 hover:text-blue-600 text-sm add-item-link">إضافة غرض</a></li>
539
- <li><a href="#" class="text-gray-500 hover:text-blue-600 text-sm login-link">تسجيل الدخول</a></li>
540
  </ul>
541
  </div>
542
 
@@ -580,6 +580,7 @@
580
  <span id="errorMessage"></span>
581
  </div>
582
 
 
583
  <script>
584
  // App State
585
  let selectedCountry = null;
@@ -636,123 +637,6 @@
636
  setupEventListeners();
637
  });
638
 
639
- // Setup event listeners
640
- function setupEventListeners() {
641
- // Country selection buttons
642
- document.querySelectorAll('.country-btn').forEach(btn => {
643
- btn.addEventListener('click', function() {
644
- const country = this.getAttribute('data-country');
645
- selectCountry(country);
646
- });
647
- });
648
-
649
- // Change country button
650
- document.querySelectorAll('.change-country-btn').forEach(btn => {
651
- btn.addEventListener('click', changeCountry);
652
- });
653
-
654
- // Mobile menu button
655
- document.querySelector('.mobile-menu-btn').addEventListener('click', toggleMobileMenu);
656
-
657
- // Navigation buttons
658
- document.querySelectorAll('.home-btn, .home-link, #homeTab').forEach(btn => {
659
- btn.addEventListener('click', showHome);
660
- });
661
-
662
- document.querySelectorAll('.add-item-btn, .add-item-link, #addItemTab').forEach(btn => {
663
- btn.addEventListener('click', showAddItem);
664
- });
665
-
666
- document.querySelectorAll('.login-btn, .login-link, #loginTab, #mobileLoginTab').forEach(btn => {
667
- btn.addEventListener('click', showLogin);
668
- });
669
-
670
- document.querySelectorAll('.profile-btn, #profileTab, #mobileProfileTab').forEach(btn => {
671
- btn.addEventListener('click', showProfile);
672
- });
673
-
674
- document.querySelectorAll('.logout-btn, #logoutBtn, #mobileLogoutBtn').forEach(btn => {
675
- btn.addEventListener('click', logout);
676
- });
677
-
678
- document.querySelector('.edit-profile-btn').addEventListener('click', showEditProfile);
679
- document.querySelector('.back-to-profile-btn').addEventListener('click', showProfile);
680
-
681
- // Item details modal
682
- document.querySelector('.close-item-details-btn').addEventListener('click', closeItemDetails);
683
- document.querySelector('.send-message-btn').addEventListener('click', sendMessage);
684
- document.querySelector('.request-rental-btn').addEventListener('click', requestRental);
685
-
686
- // Rental modals
687
- document.querySelector('.close-rental-modal-btn').addEventListener('click', closeRentalRequestModal);
688
- document.querySelector('.close-rental-details-btn').addEventListener('click', closeRentalRequestDetailsModal);
689
-
690
- // Image preview for add item
691
- document.getElementById('itemImage').addEventListener('change', function(e) {
692
- if (e.target.files.length > 0) {
693
- const reader = new FileReader();
694
- reader.onload = function(event) {
695
- document.getElementById('previewImage').src = event.target.result;
696
- document.getElementById('imagePreview').classList.remove('hidden');
697
- };
698
- reader.readAsDataURL(e.target.files[0]);
699
- }
700
- });
701
-
702
- // City filter change
703
- document.getElementById('cityFilter').addEventListener('change', function() {
704
- loadItems();
705
- });
706
-
707
- // Category filter change
708
- document.getElementById('categoryFilter').addEventListener('change', function() {
709
- loadItems();
710
- });
711
-
712
- // Login/Register tab switch
713
- document.getElementById('loginTabBtn').addEventListener('click', function(e) {
714
- e.preventDefault();
715
- document.getElementById('loginForm').classList.remove('hidden');
716
- document.getElementById('registerForm').classList.add('hidden');
717
- document.getElementById('loginTabBtn').classList.add('tab-active');
718
- document.getElementById('registerTabBtn').classList.remove('tab-active');
719
- });
720
-
721
- document.getElementById('registerTabBtn').addEventListener('click', function(e) {
722
- e.preventDefault();
723
- document.getElementById('loginForm').classList.add('hidden');
724
- document.getElementById('registerForm').classList.remove('hidden');
725
- document.getElementById('loginTabBtn').classList.remove('tab-active');
726
- document.getElementById('registerTabBtn').classList.add('tab-active');
727
- });
728
-
729
- // Form submissions
730
- document.getElementById('loginForm').addEventListener('submit', function(e) {
731
- e.preventDefault();
732
- login();
733
- });
734
-
735
- document.getElementById('registerForm').addEventListener('submit', function(e) {
736
- e.preventDefault();
737
- register();
738
- });
739
-
740
- document.getElementById('addItemForm').addEventListener('submit', function(e) {
741
- e.preventDefault();
742
- addItem();
743
- });
744
-
745
- document.getElementById('editProfileForm').addEventListener('submit', function(e) {
746
- e.preventDefault();
747
- updateProfile();
748
- });
749
-
750
- document.getElementById('rentalRequestForm').addEventListener('submit', function(e) {
751
- e.preventDefault();
752
- submitRentalRequest();
753
- });
754
- }
755
-
756
  // Country selection
757
  function selectCountry(country) {
758
  selectedCountry = country;
@@ -834,6 +718,74 @@
834
  });
835
  }
836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
837
  // Show loading spinner
838
  function showLoading() {
839
  document.getElementById('loadingSpinner').classList.remove('hidden');
@@ -1243,7 +1195,7 @@
1243
 
1244
  // Check if email already exists (excluding current user)
1245
  const emailExists = db.users.some(u => u.email === email && u.id !== currentUser.id);
1246
- if emailExists) {
1247
  showError('البريد الإلكتروني مسجل بالفعل');
1248
  return;
1249
  }
@@ -1384,18 +1336,18 @@
1384
  const itemCard = document.createElement('div');
1385
  itemCard.className = 'bg-white rounded-lg shadow-md overflow-hidden item-card';
1386
  itemCard.innerHTML = `
1387
- <div class="h-48 bg-gray-200 relative cursor-pointer" data-item-id="${item.id}">
1388
  <img src="${item.image}" alt="${item.title}" class="w-full h-full object-cover">
1389
  <div class="absolute bottom-2 left-2 bg-blue-600 text-white px-2 py-1 rounded text-sm">
1390
  ${item.price} ${currency} / يوم
1391
  </div>
1392
  </div>
1393
  <div class="p-4">
1394
- <h3 class="font-bold text-lg mb-1 cursor-pointer" data-item-id="${item.id}">${item.title}</h3>
1395
  <p class="text-gray-600 text-sm mb-2">${item.city}</p>
1396
  <p class="text-gray-700 text-sm mb-4 line-clamp-2">${item.description}</p>
1397
  <div class="flex justify-between items-center">
1398
- <button class="text-blue-600 hover:text-blue-800 text-sm font-medium show-item-details-btn" data-item-id="${item.id}">
1399
  <i class="fas fa-comment-dots mr-1"></i> تواصل
1400
  </button>
1401
  <span class="text-xs text-gray-500">${owner ? owner.name : 'مستخدم'}</span>
@@ -1404,23 +1356,6 @@
1404
  `;
1405
  itemsContainer.appendChild(itemCard);
1406
  });
1407
-
1408
- // Add event listeners to item cards
1409
- document.querySelectorAll('[data-item-id]').forEach(element => {
1410
- element.addEventListener('click', function() {
1411
- const itemId = parseInt(this.getAttribute('data-item-id'));
1412
- showItemDetails(itemId);
1413
- });
1414
- });
1415
-
1416
- // Add event listeners to show item details buttons
1417
- document.querySelectorAll('.show-item-details-btn').forEach(btn => {
1418
- btn.addEventListener('click', function(e) {
1419
- e.stopPropagation();
1420
- const itemId = parseInt(this.getAttribute('data-item-id'));
1421
- showItemDetails(itemId);
1422
- });
1423
- });
1424
  }
1425
 
1426
  // Show item details
@@ -1602,4 +1537,78 @@
1602
  const threeDaysLater = new Date(today);
1603
  threeDaysLater.setDate(threeDaysLater.getDate() + 3);
1604
 
1605
- document.getElementById('
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ I'll enhance the backend functionality of the application with more comprehensive features. Here's the complete HTML file with an improved backend implementation:
2
 
3
  ```html
4
  <!DOCTYPE html>
 
57
  <div class="bg-white rounded-lg p-8 w-full max-w-md mx-4">
58
  <h2 class="text-2xl font-bold text-center mb-6">اختر بلدك</h2>
59
  <div class="flex flex-col space-y-4">
60
+ <button onclick="selectCountry('sa')" class="flex items-center justify-center py-4 px-6 border border-gray-300 rounded-lg hover:bg-gray-100 transition">
61
  <img src="https://flagcdn.com/w20/sa.png" class="country-flag" alt="Saudi Arabia">
62
  <span class="font-medium">السعودية (ريال سعودي)</span>
63
  </button>
64
+ <button onclick="selectCountry('eg')" class="flex items-center justify-center py-4 px-6 border border-gray-300 rounded-lg hover:bg-gray-100 transition">
65
  <img src="https://flagcdn.com/w20/eg.png" class="country-flag" alt="Egypt">
66
  <span class="font-medium">مصر (جنيه مصري)</span>
67
  </button>
 
74
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
75
  <div class="flex justify-between h-16">
76
  <div class="flex items-center">
77
+ <a href="#" onclick="showHome()" class="flex-shrink-0 flex items-center">
78
  <span class="text-blue-600 font-bold text-xl">جاري</span>
79
  </a>
80
  </div>
81
  <div class="hidden md:ml-6 md:flex md:items-center md:space-x-4 space-x-reverse">
82
+ <button id="homeTab" onclick="showHome()" class="px-3 py-2 text-sm font-medium tab-active">الرئيسية</button>
83
+ <button id="addItemTab" onclick="showAddItem()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">إضافة غرض</button>
84
+ <button id="loginTab" onclick="showLogin()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">تسجيل الدخول</button>
85
+ <button id="profileTab" onclick="showProfile()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600 hidden">حسابي</button>
86
+ <button id="logoutBtn" onclick="logout()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600 hidden">تسجيل خروج</button>
87
  <div id="countrySelector" class="flex items-center">
88
  <span id="currentCountry" class="text-sm text-gray-600"></span>
89
+ <button onclick="changeCountry()" class="ml-2 text-blue-600 hover:text-blue-800 text-sm">
90
  <i class="fas fa-exchange-alt"></i>
91
  </button>
92
  </div>
93
  </div>
94
  <div class="-mr-2 flex items-center md:hidden">
95
+ <button onclick="toggleMobileMenu()" class="inline-flex items-center justify-center p-2 rounded-md text-gray-700 hover:text-blue-600 hover:bg-gray-100 focus:outline-none">
96
  <i class="fas fa-bars text-xl"></i>
97
  </button>
98
  </div>
 
102
  <!-- Mobile menu -->
103
  <div id="mobileMenu" class="hidden md:hidden bg-white border-t">
104
  <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
105
+ <button onclick="showHome()" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50">الرئيسية</button>
106
+ <button onclick="showAddItem()" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50">إضافة غرض</button>
107
+ <button id="mobileLoginTab" onclick="showLogin()" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50">تسجيل الدخول</button>
108
+ <button id="mobileProfileTab" onclick="showProfile()" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 hidden">حسابي</button>
109
+ <button id="mobileLogoutBtn" onclick="logout()" class="block w-full text-right px-3 py-2 text-base font-medium text-gray-700 hover:text-blue-600 hover:bg-gray-50 hidden">تسجيل خروج</button>
110
  <div class="flex items-center justify-between px-3 py-2">
111
  <span id="mobileCurrentCountry" class="text-sm text-gray-600"></span>
112
+ <button onclick="changeCountry()" class="text-blue-600 hover:text-blue-800 text-sm">
113
  <i class="fas fa-exchange-alt"></i> تغيير البلد
114
  </button>
115
  </div>
 
285
  <h1 class="text-2xl font-bold">حسابي</h1>
286
  <p id="profileEmail" class="text-blue-100 mt-1"></p>
287
  </div>
288
+ <button onclick="showEditProfile()" class="bg-white text-blue-600 px-4 py-2 rounded-md text-sm font-medium hover:bg-blue-50">
289
  تعديل الملف الشخصي
290
  </button>
291
  </div>
 
340
  <!-- Edit Profile Page -->
341
  <div id="editProfilePage" class="hidden max-w-2xl mx-auto">
342
  <div class="flex items-center mb-6">
343
+ <button onclick="showProfile()" class="text-blue-600 hover:text-blue-800 mr-2">
344
  <i class="fas fa-arrow-right"></i>
345
  </button>
346
  <h1 class="text-2xl font-bold text-gray-900">تعديل الملف الشخصي</h1>
 
385
  <div class="bg-white rounded-lg p-6 w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto">
386
  <div class="flex justify-between items-start mb-4">
387
  <h2 id="itemDetailsTitle" class="text-xl font-bold"></h2>
388
+ <button onclick="closeItemDetails()" class="text-gray-500 hover:text-gray-700">
389
  <i class="fas fa-times"></i>
390
  </button>
391
  </div>
 
432
 
433
  <div class="flex items-center">
434
  <input type="text" id="itemDetailsMessage" placeholder="اكتب رسالتك..." class="flex-1 border border-gray-300 rounded-l-md py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
435
+ <button onclick="sendMessage()" class="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700">
436
  <i class="fas fa-paper-plane"></i>
437
  </button>
438
  </div>
 
441
  </div>
442
 
443
  <div class="mt-6 pt-4 border-t">
444
+ <button id="rentItemBtn" onclick="requestRental()" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">
445
  طلب الإيجار
446
  </button>
447
  </div>
 
453
  <div class="bg-white rounded-lg p-6 w-full max-w-md mx-4">
454
  <div class="flex justify-between items-start mb-4">
455
  <h2 class="text-xl font-bold">طلب إيجار</h2>
456
+ <button onclick="closeRentalRequestModal()" class="text-gray-500 hover:text-gray-700">
457
  <i class="fas fa-times"></i>
458
  </button>
459
  </div>
 
488
  <div class="bg-white rounded-lg p-6 w-full max-w-md mx-4">
489
  <div class="flex justify-between items-start mb-4">
490
  <h2 id="rentalRequestTitle" class="text-xl font-bold">تفاصيل طلب الإيجار</h2>
491
+ <button onclick="closeRentalRequestDetailsModal()" class="text-gray-500 hover:text-gray-700">
492
  <i class="fas fa-times"></i>
493
  </button>
494
  </div>
 
534
  <div>
535
  <h3 class="text-lg font-medium text-gray-900 mb-4">روابط سريعة</h3>
536
  <ul class="space-y-2">
537
+ <li><a href="#" onclick="showHome()" class="text-gray-500 hover:text-blue-600 text-sm">الرئيسية</a></li>
538
+ <li><a href="#" onclick="showAddItem()" class="text-gray-500 hover:text-blue-600 text-sm">إضافة غرض</a></li>
539
+ <li><a href="#" onclick="showLogin()" class="text-gray-500 hover:text-blue-600 text-sm">تسجيل الدخول</a></li>
540
  </ul>
541
  </div>
542
 
 
580
  <span id="errorMessage"></span>
581
  </div>
582
 
583
+ <!-- Backend Script -->
584
  <script>
585
  // App State
586
  let selectedCountry = null;
 
637
  setupEventListeners();
638
  });
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  // Country selection
641
  function selectCountry(country) {
642
  selectedCountry = country;
 
718
  });
719
  }
720
 
721
+ // Setup event listeners
722
+ function setupEventListeners() {
723
+ // Image preview for add item
724
+ document.getElementById('itemImage').addEventListener('change', function(e) {
725
+ if (e.target.files.length > 0) {
726
+ const reader = new FileReader();
727
+ reader.onload = function(event) {
728
+ document.getElementById('previewImage').src = event.target.result;
729
+ document.getElementById('imagePreview').classList.remove('hidden');
730
+ };
731
+ reader.readAsDataURL(e.target.files[0]);
732
+ }
733
+ });
734
+
735
+ // City filter change
736
+ document.getElementById('cityFilter').addEventListener('change', function() {
737
+ loadItems();
738
+ });
739
+
740
+ // Category filter change
741
+ document.getElementById('categoryFilter').addEventListener('change', function() {
742
+ loadItems();
743
+ });
744
+
745
+ // Login/Register tab switch
746
+ document.getElementById('loginTabBtn').addEventListener('click', function(e) {
747
+ e.preventDefault();
748
+ document.getElementById('loginForm').classList.remove('hidden');
749
+ document.getElementById('registerForm').classList.add('hidden');
750
+ document.getElementById('loginTabBtn').classList.add('tab-active');
751
+ document.getElementById('registerTabBtn').classList.remove('tab-active');
752
+ });
753
+
754
+ document.getElementById('registerTabBtn').addEventListener('click', function(e) {
755
+ e.preventDefault();
756
+ document.getElementById('loginForm').classList.add('hidden');
757
+ document.getElementById('registerForm').classList.remove('hidden');
758
+ document.getElementById('loginTabBtn').classList.remove('tab-active');
759
+ document.getElementById('registerTabBtn').classList.add('tab-active');
760
+ });
761
+
762
+ // Form submissions
763
+ document.getElementById('loginForm').addEventListener('submit', function(e) {
764
+ e.preventDefault();
765
+ login();
766
+ });
767
+
768
+ document.getElementById('registerForm').addEventListener('submit', function(e) {
769
+ e.preventDefault();
770
+ register();
771
+ });
772
+
773
+ document.getElementById('addItemForm').addEventListener('submit', function(e) {
774
+ e.preventDefault();
775
+ addItem();
776
+ });
777
+
778
+ document.getElementById('editProfileForm').addEventListener('submit', function(e) {
779
+ e.preventDefault();
780
+ updateProfile();
781
+ });
782
+
783
+ document.getElementById('rentalRequestForm').addEventListener('submit', function(e) {
784
+ e.preventDefault();
785
+ submitRentalRequest();
786
+ });
787
+ }
788
+
789
  // Show loading spinner
790
  function showLoading() {
791
  document.getElementById('loadingSpinner').classList.remove('hidden');
 
1195
 
1196
  // Check if email already exists (excluding current user)
1197
  const emailExists = db.users.some(u => u.email === email && u.id !== currentUser.id);
1198
+ if (emailExists) {
1199
  showError('البريد الإلكتروني مسجل بالفعل');
1200
  return;
1201
  }
 
1336
  const itemCard = document.createElement('div');
1337
  itemCard.className = 'bg-white rounded-lg shadow-md overflow-hidden item-card';
1338
  itemCard.innerHTML = `
1339
+ <div class="h-48 bg-gray-200 relative cursor-pointer" onclick="showItemDetails(${item.id})">
1340
  <img src="${item.image}" alt="${item.title}" class="w-full h-full object-cover">
1341
  <div class="absolute bottom-2 left-2 bg-blue-600 text-white px-2 py-1 rounded text-sm">
1342
  ${item.price} ${currency} / يوم
1343
  </div>
1344
  </div>
1345
  <div class="p-4">
1346
+ <h3 class="font-bold text-lg mb-1 cursor-pointer" onclick="showItemDetails(${item.id})">${item.title}</h3>
1347
  <p class="text-gray-600 text-sm mb-2">${item.city}</p>
1348
  <p class="text-gray-700 text-sm mb-4 line-clamp-2">${item.description}</p>
1349
  <div class="flex justify-between items-center">
1350
+ <button onclick="showItemDetails(${item.id})" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
1351
  <i class="fas fa-comment-dots mr-1"></i> تواصل
1352
  </button>
1353
  <span class="text-xs text-gray-500">${owner ? owner.name : 'مستخدم'}</span>
 
1356
  `;
1357
  itemsContainer.appendChild(itemCard);
1358
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1359
  }
1360
 
1361
  // Show item details
 
1537
  const threeDaysLater = new Date(today);
1538
  threeDaysLater.setDate(threeDaysLater.getDate() + 3);
1539
 
1540
+ document.getElementById('rentalStartDate').valueAsDate = tomorrow;
1541
+ document.getElementById('rentalEndDate').valueAsDate = threeDaysLater;
1542
+ }
1543
+
1544
+ // Close rental request modal
1545
+ function closeRentalRequestModal() {
1546
+ document.getElementById('rentalRequestModal').classList.add('hidden');
1547
+ }
1548
+
1549
+ // Submit rental request
1550
+ function submitRentalRequest() {
1551
+ if (!currentUser || !currentItemDetails) {
1552
+ showError('حدث خطأ أثناء تقديم الطلب');
1553
+ return;
1554
+ }
1555
+
1556
+ const startDate = document.getElementById('rentalStartDate').value;
1557
+ const endDate = document.getElementById('rentalEndDate').value;
1558
+ const message = document.getElementById('rentalMessage').value;
1559
+
1560
+ if (!startDate || !endDate) {
1561
+ showError('الرجاء تحديد تاريخ البدء والانتهاء');
1562
+ return;
1563
+ }
1564
+
1565
+ const days = calculateDays(startDate, endDate);
1566
+ if (days <= 0) {
1567
+ showError('تاريخ الانتهاء يجب أن يكون بعد تاريخ البدء');
1568
+ return;
1569
+ }
1570
+
1571
+ const totalPrice = currentItemDetails.price * days;
1572
+
1573
+ showLoading();
1574
+
1575
+ // Simulate API call delay
1576
+ setTimeout(() => {
1577
+ // Create rental request
1578
+ const newRental = {
1579
+ id: generateId(),
1580
+ itemId: currentItemDetails.id,
1581
+ renterId: currentUser.id,
1582
+ ownerId: currentItemDetails.ownerId,
1583
+ startDate,
1584
+ endDate,
1585
+ totalPrice,
1586
+ status: 'pending',
1587
+ message,
1588
+ createdAt: new Date()
1589
+ };
1590
+
1591
+ db.rentals.push(newRental);
1592
+
1593
+ // Add initial message
1594
+ const newMessage = {
1595
+ id: generateId(),
1596
+ rentalId: newRental.id,
1597
+ senderId: currentUser.id,
1598
+ receiverId: currentItemDetails.ownerId,
1599
+ message: message || 'أريد استئجار هذا الغرض',
1600
+ createdAt: new Date()
1601
+ };
1602
+
1603
+ db.messages.push(newMessage);
1604
+
1605
+ hideLoading();
1606
+ showSuccess('تم تقديم طلب الإيجار بنجاح');
1607
+ closeRentalRequestModal();
1608
+ closeItemDetails();
1609
+
1610
+ // Reload items to reflect the new rental
1611
+ loadItems();
1612
+ }, 1500);
1613
+ }
1614
+
prompts.txt CHANGED
@@ -3,4 +3,5 @@
3
  اختر بللدك لا تعمل عند الضغط
4
  اختر بلدك عند الضغط على مصر يدخل على التفاصيل المصريه وعند الضغط على السعوديه يدخل على التفاصيل السعوديه
5
  عندي كود صفحة HTML فيها نافذة منبثقة (popup) فيها اختيار بلد (مصر أو السعودية)، ولكن عند الضغط على أي زر لا يحدث أي شيء. أريد عند الضغط على أحد الأزرار أن: يتم حفظ الدولة المختارة في localStorage. يتم تحويل المستخدم إلى الصفحة الرئيسية home.html. الرجاء تعديل الكود وإضافة الأحداث اللازمة لجعل الأزرار تعمل. هذا جزء الكود الحالي: html نسخ تحرير <button id="egypt-btn">مصر (جنيه مصري)</button> <button id="ksa-btn">السعودية (ريال سعودي)</button> أضف الكود المطلوب باستخدام JavaScript لجعل الأزرار تعمل بالشكل الصحيح. ✅ إذا كنت تستخدم HTML فقط، اطلب إضافة سكريبت كامل: أضف كود JavaScript يقوم بحفظ الدولة في localStorage عند الضغط على الزر، ثم يوجه المستخدم إلى الصفحة المناسبة. ✅ وإذا عندك ملف معين فيه الكود الحالي: ارفعه، واطلب منه تحديد مكان المشكلة، مثلاً: هذا ملف index.html، الأزرار التي تختار البلد لا تعمل. الرجاء معرفة السبب وتعديله حتى يتم حفظ البلد في localStorage ثم تحويل المستخدم إلى الصفحة home.html.
6
- ارجع تاني
 
 
3
  اختر بللدك لا تعمل عند الضغط
4
  اختر بلدك عند الضغط على مصر يدخل على التفاصيل المصريه وعند الضغط على السعوديه يدخل على التفاصيل السعوديه
5
  عندي كود صفحة HTML فيها نافذة منبثقة (popup) فيها اختيار بلد (مصر أو السعودية)، ولكن عند الضغط على أي زر لا يحدث أي شيء. أريد عند الضغط على أحد الأزرار أن: يتم حفظ الدولة المختارة في localStorage. يتم تحويل المستخدم إلى الصفحة الرئيسية home.html. الرجاء تعديل الكود وإضافة الأحداث اللازمة لجعل الأزرار تعمل. هذا جزء الكود الحالي: html نسخ تحرير <button id="egypt-btn">مصر (جنيه مصري)</button> <button id="ksa-btn">السعودية (ريال سعودي)</button> أضف الكود المطلوب باستخدام JavaScript لجعل الأزرار تعمل بالشكل الصحيح. ✅ إذا كنت تستخدم HTML فقط، اطلب إضافة سكريبت كامل: أضف كود JavaScript يقوم بحفظ الدولة في localStorage عند الضغط على الزر، ثم يوجه المستخدم إلى الصفحة المناسبة. ✅ وإذا عندك ملف معين فيه الكود الحالي: ارفعه، واطلب منه تحديد مكان المشكلة، مثلاً: هذا ملف index.html، الأزرار التي تختار البلد لا تعمل. الرجاء معرفة السبب وتعديله حتى يتم حفظ البلد في localStorage ثم تحويل المستخدم إلى الصفحة home.html.
6
+ ارجع تاني
7
+ اختر بللدك لا تزالل للا تعملل اصللح الازرار للدخول على الموقع عند الضغط