File size: 38,779 Bytes
0551fdd | 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 | <!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>جاري - تأجير الأغراض بين الأفراد</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap');
body {
font-family: 'Tajawal', sans-serif;
}
.country-flag {
width: 30px;
height: 20px;
object-fit: cover;
border-radius: 2px;
margin-left: 8px;
}
.item-card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.item-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-50">
<!-- Country Selection Modal -->
<div id="countryModal" class="fixed inset-0 bg-gray-900 bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg p-8 w-full max-w-md mx-4">
<h2 class="text-2xl font-bold text-center mb-6">اختر بلدك</h2>
<div class="flex flex-col space-y-4">
<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">
<img src="https://flagcdn.com/w20/sa.png" class="country-flag" alt="Saudi Arabia">
<span class="font-medium">السعودية (ريال سعودي)</span>
</button>
<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">
<img src="https://flagcdn.com/w20/eg.png" class="country-flag" alt="Egypt">
<span class="font-medium">مصر (جنيه مصري)</span>
</button>
</div>
</div>
</div>
<!-- Navigation -->
<nav class="bg-white shadow-sm sticky top-0 z-40">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<a href="#" onclick="showHome()" class="flex-shrink-0 flex items-center">
<span class="text-blue-600 font-bold text-xl">جاري</span>
</a>
</div>
<div class="hidden md:ml-6 md:flex md:items-center md:space-x-4 space-x-reverse">
<button id="homeTab" onclick="showHome()" class="px-3 py-2 text-sm font-medium tab-active">الرئيسية</button>
<button id="addItemTab" onclick="showAddItem()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">إضافة غرض</button>
<button id="loginTab" onclick="showLogin()" class="px-3 py-2 text-sm font-medium text-gray-700 hover:text-blue-600">تسجيل الدخول</button>
<div id="countrySelector" class="flex items-center">
<span id="currentCountry" class="text-sm text-gray-600"></span>
<button onclick="changeCountry()" class="ml-2 text-blue-600 hover:text-blue-800 text-sm">
<i class="fas fa-exchange-alt"></i>
</button>
</div>
</div>
<div class="-mr-2 flex items-center md:hidden">
<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">
<i class="fas fa-bars text-xl"></i>
</button>
</div>
</div>
</div>
<!-- Mobile menu -->
<div id="mobileMenu" class="hidden md:hidden bg-white border-t">
<div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
<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>
<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>
<button 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>
<div class="flex items-center justify-between px-3 py-2">
<span id="mobileCurrentCountry" class="text-sm text-gray-600"></span>
<button onclick="changeCountry()" class="text-blue-600 hover:text-blue-800 text-sm">
<i class="fas fa-exchange-alt"></i> تغيير البلد
</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Home Page -->
<div id="homePage">
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">الأغراض المتاحة للإيجار</h1>
<div class="flex items-center">
<select id="cityFilter" class="border border-gray-300 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">كل المدن</option>
</select>
</div>
</div>
<div id="itemsContainer" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Items will be loaded here -->
</div>
</div>
<!-- Add Item Page -->
<div id="addItemPage" class="hidden max-w-2xl mx-auto">
<h1 class="text-2xl font-bold text-gray-900 mb-6">إضافة غرض جديد للإيجار</h1>
<form id="addItemForm" class="space-y-4">
<div>
<label for="itemTitle" class="block text-sm font-medium text-gray-700">عنوان الغرض</label>
<input type="text" id="itemTitle" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="itemDescription" class="block text-sm font-medium text-gray-700">وصف الغرض</label>
<textarea id="itemDescription" rows="4" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500"></textarea>
</div>
<div>
<label for="itemImage" class="block text-sm font-medium text-gray-700">صورة الغرض</label>
<input type="file" id="itemImage" accept="image/*" class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
<div id="imagePreview" class="mt-2 hidden">
<img id="previewImage" src="#" alt="Preview" class="h-32 object-cover rounded-md">
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="itemPrice" class="block text-sm font-medium text-gray-700">السعر اليومي</label>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<span id="priceCurrency" class="text-gray-500 sm:text-sm">ريال</span>
</div>
<input type="number" id="itemPrice" min="1" required class="focus:ring-blue-500 focus:border-blue-500 block w-full pr-12 pl-16 py-2 sm:text-sm border-gray-300 rounded-md">
</div>
</div>
<div>
<label for="itemCity" class="block text-sm font-medium text-gray-700">المدينة</label>
<select id="itemCity" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
<option value="">اختر المدينة</option>
</select>
</div>
</div>
<div>
<label for="itemCategory" class="block text-sm font-medium text-gray-700">التصنيف</label>
<select id="itemCategory" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
<option value="">اختر التصنيف</option>
<option value="electronics">إلكترونيات</option>
<option value="tools">أدوات</option>
<option value="sports">رياضة</option>
<option value="fashion">أزياء</option>
<option value="home">أدوات منزلية</option>
<option value="other">أخرى</option>
</select>
</div>
<div class="pt-4">
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
إضافة الغرض
</button>
</div>
</form>
</div>
<!-- Login/Register Page -->
<div id="loginPage" class="hidden max-w-md mx-auto">
<div class="bg-white py-8 px-4 shadow rounded-lg sm:px-10">
<div class="text-center mb-8">
<h1 class="text-2xl font-bold text-gray-900">مرحباً بك في جاري</h1>
<p class="mt-2 text-sm text-gray-600">سجل الدخول أو أنشئ حساباً جديداً</p>
</div>
<div class="flex border-b mb-6">
<button id="loginTabBtn" class="flex-1 py-2 px-4 text-center font-medium tab-active">تسجيل الدخول</button>
<button id="registerTabBtn" class="flex-1 py-2 px-4 text-center font-medium text-gray-500 hover:text-blue-600">إنشاء حساب</button>
</div>
<form id="loginForm" class="space-y-4">
<div>
<label for="loginEmail" class="block text-sm font-medium text-gray-700">البريد الإلكتروني</label>
<input type="email" id="loginEmail" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="loginPassword" class="block text-sm font-medium text-gray-700">كلمة المرور</label>
<input type="password" id="loginPassword" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
تسجيل الدخول
</button>
</div>
</form>
<form id="registerForm" class="hidden space-y-4">
<div>
<label for="registerName" class="block text-sm font-medium text-gray-700">الاسم الكامل</label>
<input type="text" id="registerName" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="registerEmail" class="block text-sm font-medium text-gray-700">البريد الإلكتروني</label>
<input type="email" id="registerEmail" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="registerPhone" class="block text-sm font-medium text-gray-700">رقم الهاتف</label>
<input type="tel" id="registerPhone" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="registerPassword" class="block text-sm font-medium text-gray-700">كلمة المرور</label>
<input type="password" id="registerPassword" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="registerConfirmPassword" class="block text-sm font-medium text-gray-700">تأكيد كلمة المرور</label>
<input type="password" id="registerConfirmPassword" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
إنشاء حساب
</button>
</div>
</form>
<div class="mt-4 text-center">
<p class="text-sm text-gray-600">
بمتابعتك أنت توافق على
<a href="#" class="font-medium text-blue-600 hover:text-blue-500">شروط الاستخدام</a>
و
<a href="#" class="font-medium text-blue-600 hover:text-blue-500">سياسة الخصوصية</a>
</p>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-white border-t mt-12">
<div class="max-w-7xl mx-auto py-8 px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">جاري</h3>
<p id="footerDescription" class="text-gray-500 text-sm">منصة لتأجير الأغراض الشخصية بين الأفراد</p>
</div>
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">روابط سريعة</h3>
<ul class="space-y-2">
<li><a href="#" onclick="showHome()" class="text-gray-500 hover:text-blue-600 text-sm">الرئيسية</a></li>
<li><a href="#" onclick="showAddItem()" class="text-gray-500 hover:text-blue-600 text-sm">إضافة غرض</a></li>
<li><a href="#" onclick="showLogin()" class="text-gray-500 hover:text-blue-600 text-sm">تسجيل الدخول</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">تواصل معنا</h3>
<div class="flex space-x-4 space-x-reverse">
<a href="#" class="text-gray-500 hover:text-blue-600">
<i class="fab fa-facebook-f"></i>
</a>
<a href="#" class="text-gray-500 hover:text-blue-600">
<i class="fab fa-twitter"></i>
</a>
<a href="#" class="text-gray-500 hover:text-blue-600">
<i class="fab fa-instagram"></i>
</a>
</div>
<p class="text-gray-500 text-sm mt-4">info@jari.com</p>
</div>
</div>
<div class="mt-8 pt-8 border-t border-gray-200 text-center">
<p class="text-gray-500 text-sm">© 2023 جاري. جميع الحقوق محفوظة.</p>
</div>
</div>
</footer>
<!-- Loading Spinner -->
<div id="loadingSpinner" class="fixed inset-0 bg-gray-900 bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500"></div>
</div>
<!-- Success Notification -->
<div id="successNotification" class="fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded-md shadow-lg flex items-center hidden z-50">
<i class="fas fa-check-circle mr-2"></i>
<span id="successMessage"></span>
</div>
<!-- Error Notification -->
<div id="errorNotification" class="fixed bottom-4 right-4 bg-red-500 text-white px-4 py-2 rounded-md shadow-lg flex items-center hidden z-50">
<i class="fas fa-exclamation-circle mr-2"></i>
<span id="errorMessage"></span>
</div>
<script>
// App State
let selectedCountry = null;
let currentPage = null;
// Cities data
const cities = {
sa: ['الرياض', 'جدة', 'مكة المكرمة', 'المدينة المنورة', 'الدمام', 'الخبر', 'الطائف', 'بريدة', 'تبوك', 'نجران'],
eg: ['القاهرة', 'الجيزة', 'الإسكندرية', 'المنصورة', 'طنطا', 'المنيا', 'أسيوط', 'سوهاج', 'الأقصر', 'أسوان']
};
// Sample items data
const sampleItems = {
sa: [
{
id: 1,
title: "كاميرا احترافية",
description: "كاميرا كانون EOS 5D مارك الرابع مع عدسة 24-70mm، حالة ممتازة",
price: 150,
city: "الرياض",
category: "electronics",
image: "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
},
{
id: 2,
title: "دراجة هوائية",
description: "دراجة هوائية ماركة تريك بحالة جيدة، مناسبة للطرق الوعرة",
price: 80,
city: "جدة",
category: "sports",
image: "https://images.unsplash.com/photo-1485965120184-e220f721d03e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
},
{
id: 3,
title: "أدوات كهربائية",
description: "مجموعة أدوات كهربائية كاملة مع صندوق تخزين، جديدة تماماً",
price: 50,
city: "الدمام",
category: "tools",
image: "https://images.unsplash.com/photo-1585771724684-38269d6639fd?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
}
],
eg: [
{
id: 1,
title: "كاميرا احترافية",
description: "كاميرا نيكون D850 مع عدسة 24-70mm، حالة ممتازة",
price: 200,
city: "القاهرة",
category: "electronics",
image: "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
},
{
id: 2,
title: "ماكينة خياطة",
description: "ماكينة خياطة سنجر جديدة، مع جميع الملحقات",
price: 40,
city: "الجيزة",
category: "home",
image: "https://images.unsplash.com/photo-1565350736281-0510a3a1b5e2?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
},
{
id: 3,
title: "مولد كهرباء",
description: "مولد كهرباء 5 كيلو وات، يعمل بالبنزين، بحالة جيدة",
price: 120,
city: "الإسكندرية",
category: "tools",
image: "https://images.unsplash.com/photo-1615242860221-8a9d594f2a4a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80"
}
]
};
// Initialize the app
document.addEventListener('DOMContentLoaded', function() {
// Check if country is already selected
const savedCountry = localStorage.getItem('country');
if (savedCountry) {
selectedCountry = savedCountry;
initApp();
} else {
// Show country selection modal
document.getElementById('countryModal').classList.remove('hidden');
}
// Setup event listeners
setupEventListeners();
});
// Country selection
function selectCountry(country) {
selectedCountry = country;
localStorage.setItem('country', country);
document.getElementById('countryModal').classList.add('hidden');
initApp();
}
// Change country
function changeCountry() {
localStorage.removeItem('country');
selectedCountry = null;
document.getElementById('countryModal').classList.remove('hidden');
}
// Initialize the app after country selection
function initApp() {
// Set currency and cities based on country
const currency = selectedCountry === 'sa' ? 'ريال' : 'جنيه';
const countryName = selectedCountry === 'sa' ? 'السعودية' : 'مصر';
document.getElementById('priceCurrency').textContent = currency;
document.getElementById('currentCountry').textContent = countryName;
document.getElementById('mobileCurrentCountry').textContent = countryName;
// Update footer description
document.getElementById('footerDescription').textContent =
`منصة لتأجير الأغراض الشخصية بين الأفراد في ${countryName}`;
// Populate city filters
populateCitySelect('cityFilter', 'كل المدن');
populateCitySelect('itemCity', 'اختر المدينة');
// Load items for selected country
loadItems();
// Load home page by default
showHome();
}
// Populate city select dropdown
function populateCitySelect(selectId, defaultText) {
const select = document.getElementById(selectId);
select.innerHTML = '';
const defaultOption = document.createElement('option');
defaultOption.value = '';
defaultOption.textContent = defaultText;
select.appendChild(defaultOption);
cities[selectedCountry].forEach(city => {
const option = document.createElement('option');
option.value = city;
option.textContent = city;
select.appendChild(option);
});
}
// Setup event listeners
function setupEventListeners() {
// Image preview for add item
document.getElementById('itemImage').addEventListener('change', function(e) {
if (e.target.files.length > 0) {
const reader = new FileReader();
reader.onload = function(event) {
document.getElementById('previewImage').src = event.target.result;
document.getElementById('imagePreview').classList.remove('hidden');
};
reader.readAsDataURL(e.target.files[0]);
}
});
// City filter change
document.getElementById('cityFilter').addEventListener('change', function() {
loadItems();
});
// Login/Register tab switch
document.getElementById('loginTabBtn').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('loginForm').classList.remove('hidden');
document.getElementById('registerForm').classList.add('hidden');
document.getElementById('loginTabBtn').classList.add('tab-active');
document.getElementById('registerTabBtn').classList.remove('tab-active');
});
document.getElementById('registerTabBtn').addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('loginForm').classList.add('hidden');
document.getElementById('registerForm').classList.remove('hidden');
document.getElementById('loginTabBtn').classList.remove('tab-active');
document.getElementById('registerTabBtn').classList.add('tab-active');
});
// Form submissions
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
login();
});
document.getElementById('registerForm').addEventListener('submit', function(e) {
e.preventDefault();
register();
});
document.getElementById('addItemForm').addEventListener('submit', function(e) {
e.preventDefault();
addItem();
});
}
// Show loading spinner
function showLoading() {
document.getElementById('loadingSpinner').classList.remove('hidden');
}
// Hide loading spinner
function hideLoading() {
document.getElementById('loadingSpinner').classList.add('hidden');
}
// Show success notification
function showSuccess(message) {
const notification = document.getElementById('successNotification');
document.getElementById('successMessage').textContent = message;
notification.classList.remove('hidden');
setTimeout(() => {
notification.classList.add('hidden');
}, 3000);
}
// Show error notification
function showError(message) {
const notification = document.getElementById('errorNotification');
document.getElementById('errorMessage').textContent = message;
notification.classList.remove('hidden');
setTimeout(() => {
notification.classList.add('hidden');
}, 3000);
}
// Toggle mobile menu
function toggleMobileMenu() {
document.getElementById('mobileMenu').classList.toggle('hidden');
}
// Page navigation functions
function showHome() {
if (!selectedCountry) {
document.getElementById('countryModal').classList.remove('hidden');
return;
}
hideAllPages();
document.getElementById('homePage').classList.remove('hidden');
document.getElementById('homeTab').classList.add('tab-active');
document.getElementById('addItemTab').classList.remove('tab-active');
document.getElementById('loginTab').classList.remove('tab-active');
currentPage = 'home';
}
function showAddItem() {
if (!selectedCountry) {
document.getElementById('countryModal').classList.remove('hidden');
return;
}
hideAllPages();
document.getElementById('addItemPage').classList.remove('hidden');
document.getElementById('homeTab').classList.remove('tab-active');
document.getElementById('addItemTab').classList.add('tab-active');
document.getElementById('loginTab').classList.remove('tab-active');
currentPage = 'addItem';
}
function showLogin() {
if (!selectedCountry) {
document.getElementById('countryModal').classList.remove('hidden');
return;
}
hideAllPages();
document.getElementById('loginPage').classList.remove('hidden');
document.getElementById('homeTab').classList.remove('tab-active');
document.getElementById('addItemTab').classList.remove('tab-active');
document.getElementById('loginTab').classList.add('tab-active');
currentPage = 'login';
}
function hideAllPages() {
const pages = ['homePage', 'addItemPage', 'loginPage'];
pages.forEach(page => {
document.getElementById(page).classList.add('hidden');
});
}
// Load items for home page
function loadItems() {
if (!selectedCountry) return;
const cityFilter = document.getElementById('cityFilter').value;
let items = sampleItems[selectedCountry];
// Filter by city if selected
if (cityFilter) {
items = items.filter(item => item.city === cityFilter);
}
const itemsContainer = document.getElementById('itemsContainer');
itemsContainer.innerHTML = '';
if (items.length === 0) {
itemsContainer.innerHTML = `
<div class="col-span-full text-center py-12">
<i class="fas fa-box-open text-4xl text-gray-300 mb-4"></i>
<p class="text-gray-500">لا توجد أغراض متاحة للإيجار حالياً</p>
</div>
`;
return;
}
const currency = selectedCountry === 'sa' ? 'ريال' : 'جنيه';
items.forEach(item => {
const itemCard = document.createElement('div');
itemCard.className = 'bg-white rounded-lg shadow-md overflow-hidden item-card';
itemCard.innerHTML = `
<div class="h-48 bg-gray-200 relative">
<img src="${item.image}" alt="${item.title}" class="w-full h-full object-cover">
<div class="absolute bottom-2 left-2 bg-blue-600 text-white px-2 py-1 rounded text-sm">
${item.price} ${currency} / يوم
</div>
</div>
<div class="p-4">
<h3 class="font-bold text-lg mb-1">${item.title}</h3>
<p class="text-gray-600 text-sm mb-2">${item.city}</p>
<p class="text-gray-700 text-sm mb-4 line-clamp-2">${item.description}</p>
<div class="flex justify-between items-center">
<button class="text-blue-600 hover:text-blue-800 text-sm font-medium">
<i class="fas fa-comment-dots mr-1"></i> تواصل
</button>
<span class="text-xs text-gray-500">منذ يومين</span>
</div>
</div>
`;
itemsContainer.appendChild(itemCard);
});
}
// Login function (simulated)
function login() {
const email = document.getElementById('loginEmail').value;
const password = document.getElementById('loginPassword').value;
if (!email || !password) {
showError('الرجاء إدخال البريد الإلكتروني وكلمة المرور');
return;
}
showLoading();
// Simulate API call
setTimeout(() => {
hideLoading();
showSuccess('تم تسجيل الدخول بنجاح');
showHome();
}, 1000);
}
// Register function (simulated)
function register() {
const name = document.getElementById('registerName').value;
const email = document.getElementById('registerEmail').value;
const phone = document.getElementById('registerPhone').value;
const password = document.getElementById('registerPassword').value;
const confirmPassword = document.getElementById('registerConfirmPassword').value;
if (!name || !email || !phone || !password || !confirmPassword) {
showError('الرجاء ملء جميع الحقول');
return;
}
if (password !== confirmPassword) {
showError('كلمة المرور غير متطابقة');
return;
}
if (password.length < 6) {
showError('كلمة المرور يجب أن تكون 6 أحرف على الأقل');
return;
}
showLoading();
// Simulate API call
setTimeout(() => {
hideLoading();
showSuccess('تم إنشاء الحساب بنجاح، الرجاء تسجيل الدخول');
document.getElementById('loginTabBtn').click();
document.getElementById('loginEmail').value = email;
document.getElementById('loginPassword').value = '';
}, 1500);
}
// Add item function (simulated)
function addItem() {
const title = document.getElementById('itemTitle').value;
const description = document.getElementById('itemDescription').value;
const price = document.getElementById('itemPrice').value;
const city = document.getElementById('itemCity').value;
const category = document.getElementById('itemCategory').value;
const imageFile = document.getElementById('itemImage').files[0];
if (!title || !description || !price || !city || !category) {
showError('الرجاء ملء جميع الحقول المطلوبة');
return;
}
showLoading();
// Simulate API call
setTimeout(() => {
hideLoading();
// Reset form
document.getElementById('addItemForm').reset();
document.getElementById('imagePreview').classList.add('hidden');
showSuccess('تم إضافة الغرض بنجاح');
showHome();
}, 1500);
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=amrora00/https-enzostvs-deepsite-hf-space" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |