Add 1 files
Browse files- index.html +641 -73
index.html
CHANGED
|
@@ -16,6 +16,7 @@
|
|
| 16 |
--bg-light: #fafafa;
|
| 17 |
--error-color: #ed4956;
|
| 18 |
--success-color: #4BB543;
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
* {
|
|
@@ -58,12 +59,30 @@
|
|
| 58 |
.header-icons {
|
| 59 |
display: flex;
|
| 60 |
gap: 20px;
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
.header-icons i {
|
| 64 |
font-size: 24px;
|
| 65 |
cursor: pointer;
|
| 66 |
color: var(--text-dark);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
/* Main Content */
|
|
@@ -129,14 +148,14 @@
|
|
| 129 |
text-decoration: none;
|
| 130 |
}
|
| 131 |
|
| 132 |
-
.friend-request-item, .suggested-friend-item {
|
| 133 |
display: flex;
|
| 134 |
align-items: center;
|
| 135 |
padding: 10px 0;
|
| 136 |
border-bottom: 1px solid var(--border-color);
|
| 137 |
}
|
| 138 |
|
| 139 |
-
.friend-avatar {
|
| 140 |
width: 50px;
|
| 141 |
height: 50px;
|
| 142 |
border-radius: 50%;
|
|
@@ -144,22 +163,22 @@
|
|
| 144 |
margin-left: 15px;
|
| 145 |
}
|
| 146 |
|
| 147 |
-
.friend-info {
|
| 148 |
flex: 1;
|
| 149 |
}
|
| 150 |
|
| 151 |
-
.friend-name {
|
| 152 |
font-weight: 600;
|
| 153 |
font-size: 14px;
|
| 154 |
margin-bottom: 3px;
|
| 155 |
}
|
| 156 |
|
| 157 |
-
.friend-meta {
|
| 158 |
color: var(--text-gray);
|
| 159 |
font-size: 12px;
|
| 160 |
}
|
| 161 |
|
| 162 |
-
.friend-actions {
|
| 163 |
display: flex;
|
| 164 |
gap: 8px;
|
| 165 |
}
|
|
@@ -363,15 +382,146 @@
|
|
| 363 |
color: var(--primary-color);
|
| 364 |
}
|
| 365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
/* Font for Instagram-like logo */
|
| 367 |
@font-face {
|
| 368 |
font-family: 'Billabong';
|
| 369 |
src: url('https://fonts.cdnfonts.com/s/13949/Billabong.woff') format('woff');
|
| 370 |
}
|
| 371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
/* Responsive */
|
| 373 |
@media (max-width: 450px) {
|
| 374 |
-
.friend-avatar, .message-avatar {
|
| 375 |
width: 45px;
|
| 376 |
height: 45px;
|
| 377 |
}
|
|
@@ -380,6 +530,11 @@
|
|
| 380 |
padding: 5px 8px;
|
| 381 |
font-size: 11px;
|
| 382 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
}
|
| 384 |
</style>
|
| 385 |
</head>
|
|
@@ -388,7 +543,9 @@
|
|
| 388 |
<div class="header">
|
| 389 |
<div class="header-logo">إنستا</div>
|
| 390 |
<div class="header-icons">
|
| 391 |
-
<i class="far fa-heart" id="notificationsBtn">
|
|
|
|
|
|
|
| 392 |
<i class="far fa-paper-plane" id="messagesBtn"></i>
|
| 393 |
</div>
|
| 394 |
</div>
|
|
@@ -400,6 +557,7 @@
|
|
| 400 |
<div class="tab-btn active" data-tab="friends">طلبات الصداقة</div>
|
| 401 |
<div class="tab-btn" data-tab="suggestions">اقتراحات</div>
|
| 402 |
<div class="tab-btn" data-tab="messages">المراسلة</div>
|
|
|
|
| 403 |
</div>
|
| 404 |
|
| 405 |
<!-- Friend Requests Tab -->
|
|
@@ -437,14 +595,36 @@
|
|
| 437 |
<!-- سيتم ملؤها بالرسائل ديناميكيًا -->
|
| 438 |
</div>
|
| 439 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
</div>
|
| 441 |
|
| 442 |
<!-- Bottom Navigation -->
|
| 443 |
<div class="bottom-nav">
|
| 444 |
<i class="fas fa-home active"></i>
|
| 445 |
-
<i class="fas fa-search"></i>
|
| 446 |
<i class="far fa-plus-square"></i>
|
| 447 |
-
<i class="far fa-heart"></i>
|
| 448 |
<i class="fas fa-user"></i>
|
| 449 |
</div>
|
| 450 |
|
|
@@ -467,6 +647,24 @@
|
|
| 467 |
</div>
|
| 468 |
</div>
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
<script>
|
| 471 |
// بيانات التطبيق
|
| 472 |
const appData = {
|
|
@@ -610,7 +808,118 @@
|
|
| 610 |
]
|
| 611 |
}
|
| 612 |
],
|
| 613 |
-
friends: []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
};
|
| 615 |
|
| 616 |
// عناصر DOM
|
|
@@ -627,16 +936,42 @@
|
|
| 627 |
const chatTitle = document.getElementById('chatTitle');
|
| 628 |
const messagesBtn = document.getElementById('messagesBtn');
|
| 629 |
const notificationsBtn = document.getElementById('notificationsBtn');
|
|
|
|
| 630 |
const seeAllRequests = document.getElementById('seeAllRequests');
|
| 631 |
const refreshSuggestions = document.getElementById('refreshSuggestions');
|
| 632 |
const newMessageBtn = document.getElementById('newMessageBtn');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
|
| 634 |
// تهيئة الصفحة
|
| 635 |
function initPage() {
|
| 636 |
renderFriendRequests();
|
| 637 |
renderSuggestedFriends();
|
| 638 |
renderMessages();
|
|
|
|
|
|
|
| 639 |
setupEventListeners();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 640 |
}
|
| 641 |
|
| 642 |
// إعداد مستمعي الأحداث
|
|
@@ -661,13 +996,10 @@
|
|
| 661 |
document.getElementById('messages-tab').classList.add('active');
|
| 662 |
});
|
| 663 |
|
| 664 |
-
notificationsBtn.addEventListener('click',
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
tabContents.forEach(content => content.classList.remove('active'));
|
| 669 |
-
document.getElementById('friends-tab').classList.add('active');
|
| 670 |
-
});
|
| 671 |
|
| 672 |
chatBackBtn.addEventListener('click', closeChat);
|
| 673 |
|
|
@@ -696,6 +1028,46 @@
|
|
| 696 |
e.preventDefault();
|
| 697 |
startNewMessage();
|
| 698 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 699 |
}
|
| 700 |
|
| 701 |
// عرض طلبات الصداقة
|
|
@@ -780,6 +1152,127 @@
|
|
| 780 |
});
|
| 781 |
}
|
| 782 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 783 |
// قبول طلب صداقة
|
| 784 |
function acceptFriendRequest(userId) {
|
| 785 |
const requestIndex = appData.friendRequests.findIndex(req => req.id === userId);
|
|
@@ -797,11 +1290,20 @@
|
|
| 797 |
// إزالة الطلب من القائمة
|
| 798 |
appData.friendRequests.splice(requestIndex, 1);
|
| 799 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 800 |
// عرض تنبيه
|
| 801 |
showAlert('تم قبول طلب الصداقة بنجاح', 'success');
|
| 802 |
|
| 803 |
// تحديث الواجهة
|
| 804 |
renderFriendRequests();
|
|
|
|
|
|
|
| 805 |
}
|
| 806 |
}
|
| 807 |
|
|
@@ -822,6 +1324,13 @@
|
|
| 822 |
const friend = appData.suggestedFriends[friendIndex];
|
| 823 |
showAlert(`تم إرسال طلب صداقة إلى ${friend.name}`, 'success');
|
| 824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
// في تطبيق حقيقي، سيتم إرسال الطلب إلى الخادم
|
| 826 |
setTimeout(() => {
|
| 827 |
removeSuggestion(userId);
|
|
@@ -835,6 +1344,11 @@
|
|
| 835 |
if (friendIndex !== -1) {
|
| 836 |
appData.suggestedFriends.splice(friendIndex, 1);
|
| 837 |
renderSuggestedFriends();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 838 |
}
|
| 839 |
}
|
| 840 |
|
|
@@ -941,6 +1455,13 @@
|
|
| 941 |
|
| 942 |
if (!chatModal.style.display || chatModal.style.display === 'none') {
|
| 943 |
message.unread = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 944 |
} else {
|
| 945 |
const replyElement = document.createElement('div');
|
| 946 |
replyElement.className = 'message-bubble message-in';
|
|
@@ -953,6 +1474,7 @@
|
|
| 953 |
}
|
| 954 |
|
| 955 |
renderMessages();
|
|
|
|
| 956 |
}, 2000);
|
| 957 |
}
|
| 958 |
}
|
|
@@ -987,66 +1509,112 @@
|
|
| 987 |
}
|
| 988 |
}
|
| 989 |
|
| 990 |
-
//
|
| 991 |
-
function
|
| 992 |
-
const
|
| 993 |
-
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
const replies = [
|
| 1003 |
-
"نعم، بالتأكيد!",
|
| 1004 |
-
"سأرد عليك لاحقًا",
|
| 1005 |
-
"شكرًا لك",
|
| 1006 |
-
"أنا مشغول الآن، سأتحدث معك لاحقًا",
|
| 1007 |
-
"حسنًا، فهمت",
|
| 1008 |
-
"ممتاز!",
|
| 1009 |
-
"هل يمكننا التحدث غدًا؟",
|
| 1010 |
-
"أنا موافق على ذلك",
|
| 1011 |
-
"هذا رائع!",
|
| 1012 |
-
"لا أعتقد أن هذا ممكن"
|
| 1013 |
-
];
|
| 1014 |
-
return replies[Math.floor(Math.random() * replies.length)];
|
| 1015 |
-
}
|
| 1016 |
-
|
| 1017 |
-
// عرض تنبيه
|
| 1018 |
-
function showAlert(message, type) {
|
| 1019 |
-
const alertDiv = document.createElement('div');
|
| 1020 |
-
alertDiv.style.position = 'fixed';
|
| 1021 |
-
alertDiv.style.top = '20px';
|
| 1022 |
-
alertDiv.style.left = '50%';
|
| 1023 |
-
alertDiv.style.transform = 'translateX(-50%)';
|
| 1024 |
-
alertDiv.style.padding = '10px 20px';
|
| 1025 |
-
alertDiv.style.borderRadius = '8px';
|
| 1026 |
-
alertDiv.style.color = 'white';
|
| 1027 |
-
alertDiv.style.fontWeight = '600';
|
| 1028 |
-
alertDiv.style.zIndex = '1000';
|
| 1029 |
-
alertDiv.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
|
| 1030 |
-
alertDiv.style.animation = 'fadeIn 0.3s, fadeOut 0.3s 2.7s';
|
| 1031 |
-
|
| 1032 |
-
if (type === 'success') {
|
| 1033 |
-
alertDiv.style.backgroundColor = 'var(--success-color)';
|
| 1034 |
-
} else if (type === 'error') {
|
| 1035 |
-
alertDiv.style.backgroundColor = 'var(--error-color)';
|
| 1036 |
} else {
|
| 1037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1038 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
|
| 1040 |
-
|
| 1041 |
-
|
|
|
|
|
|
|
| 1042 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1043 |
setTimeout(() => {
|
| 1044 |
-
|
| 1045 |
-
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1046 |
}
|
| 1047 |
|
| 1048 |
-
//
|
| 1049 |
-
window.addEventListener('DOMContentLoaded', initPage);
|
| 1050 |
-
</script>
|
| 1051 |
-
</body>
|
| 1052 |
</html>
|
|
|
|
| 16 |
--bg-light: #fafafa;
|
| 17 |
--error-color: #ed4956;
|
| 18 |
--success-color: #4BB543;
|
| 19 |
+
--notification-badge: #ff3040;
|
| 20 |
}
|
| 21 |
|
| 22 |
* {
|
|
|
|
| 59 |
.header-icons {
|
| 60 |
display: flex;
|
| 61 |
gap: 20px;
|
| 62 |
+
position: relative;
|
| 63 |
}
|
| 64 |
|
| 65 |
.header-icons i {
|
| 66 |
font-size: 24px;
|
| 67 |
cursor: pointer;
|
| 68 |
color: var(--text-dark);
|
| 69 |
+
position: relative;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.notification-badge {
|
| 73 |
+
position: absolute;
|
| 74 |
+
top: -5px;
|
| 75 |
+
right: -5px;
|
| 76 |
+
background-color: var(--notification-badge);
|
| 77 |
+
color: white;
|
| 78 |
+
border-radius: 50%;
|
| 79 |
+
width: 18px;
|
| 80 |
+
height: 18px;
|
| 81 |
+
display: flex;
|
| 82 |
+
align-items: center;
|
| 83 |
+
justify-content: center;
|
| 84 |
+
font-size: 10px;
|
| 85 |
+
font-weight: bold;
|
| 86 |
}
|
| 87 |
|
| 88 |
/* Main Content */
|
|
|
|
| 148 |
text-decoration: none;
|
| 149 |
}
|
| 150 |
|
| 151 |
+
.friend-request-item, .suggested-friend-item, .notification-item {
|
| 152 |
display: flex;
|
| 153 |
align-items: center;
|
| 154 |
padding: 10px 0;
|
| 155 |
border-bottom: 1px solid var(--border-color);
|
| 156 |
}
|
| 157 |
|
| 158 |
+
.friend-avatar, .notification-avatar {
|
| 159 |
width: 50px;
|
| 160 |
height: 50px;
|
| 161 |
border-radius: 50%;
|
|
|
|
| 163 |
margin-left: 15px;
|
| 164 |
}
|
| 165 |
|
| 166 |
+
.friend-info, .notification-info {
|
| 167 |
flex: 1;
|
| 168 |
}
|
| 169 |
|
| 170 |
+
.friend-name, .notification-text {
|
| 171 |
font-weight: 600;
|
| 172 |
font-size: 14px;
|
| 173 |
margin-bottom: 3px;
|
| 174 |
}
|
| 175 |
|
| 176 |
+
.friend-meta, .notification-time {
|
| 177 |
color: var(--text-gray);
|
| 178 |
font-size: 12px;
|
| 179 |
}
|
| 180 |
|
| 181 |
+
.friend-actions, .notification-actions {
|
| 182 |
display: flex;
|
| 183 |
gap: 8px;
|
| 184 |
}
|
|
|
|
| 382 |
color: var(--primary-color);
|
| 383 |
}
|
| 384 |
|
| 385 |
+
/* Notifications Modal */
|
| 386 |
+
.notifications-modal {
|
| 387 |
+
position: fixed;
|
| 388 |
+
top: 54px;
|
| 389 |
+
right: 10px;
|
| 390 |
+
width: 350px;
|
| 391 |
+
max-height: 500px;
|
| 392 |
+
overflow-y: auto;
|
| 393 |
+
background-color: var(--bg-white);
|
| 394 |
+
border-radius: 10px;
|
| 395 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 396 |
+
z-index: 150;
|
| 397 |
+
display: none;
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
.notifications-header {
|
| 401 |
+
padding: 15px;
|
| 402 |
+
border-bottom: 1px solid var(--border-color);
|
| 403 |
+
font-weight: 600;
|
| 404 |
+
display: flex;
|
| 405 |
+
justify-content: space-between;
|
| 406 |
+
align-items: center;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
.notifications-close {
|
| 410 |
+
cursor: pointer;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
.notifications-list {
|
| 414 |
+
padding: 0;
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
.notification-item {
|
| 418 |
+
padding: 12px 15px;
|
| 419 |
+
cursor: pointer;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
.notification-item.unread {
|
| 423 |
+
background-color: rgba(0, 149, 246, 0.05);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
.notification-item:hover {
|
| 427 |
+
background-color: var(--bg-light);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/* Search Section */
|
| 431 |
+
.search-container {
|
| 432 |
+
padding: 15px;
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
.search-input {
|
| 436 |
+
width: 100%;
|
| 437 |
+
padding: 12px 15px;
|
| 438 |
+
border-radius: 8px;
|
| 439 |
+
border: 1px solid var(--border-color);
|
| 440 |
+
font-size: 14px;
|
| 441 |
+
margin-bottom: 15px;
|
| 442 |
+
background-color: var(--bg-light);
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
.search-tabs {
|
| 446 |
+
display: flex;
|
| 447 |
+
border-bottom: 1px solid var(--border-color);
|
| 448 |
+
margin-bottom: 15px;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
.search-tab {
|
| 452 |
+
padding: 10px 15px;
|
| 453 |
+
cursor: pointer;
|
| 454 |
+
font-weight: 600;
|
| 455 |
+
color: var(--text-gray);
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
.search-tab.active {
|
| 459 |
+
color: var(--text-dark);
|
| 460 |
+
border-bottom: 2px solid var(--text-dark);
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
.posts-grid {
|
| 464 |
+
display: grid;
|
| 465 |
+
grid-template-columns: repeat(3, 1fr);
|
| 466 |
+
gap: 2px;
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
.post-thumbnail {
|
| 470 |
+
width: 100%;
|
| 471 |
+
aspect-ratio: 1/1;
|
| 472 |
+
object-fit: cover;
|
| 473 |
+
cursor: pointer;
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
/* Font for Instagram-like logo */
|
| 477 |
@font-face {
|
| 478 |
font-family: 'Billabong';
|
| 479 |
src: url('https://fonts.cdnfonts.com/s/13949/Billabong.woff') format('woff');
|
| 480 |
}
|
| 481 |
|
| 482 |
+
/* Push Notifications */
|
| 483 |
+
.push-notification {
|
| 484 |
+
position: fixed;
|
| 485 |
+
top: 20px;
|
| 486 |
+
left: 50%;
|
| 487 |
+
transform: translateX(-50%);
|
| 488 |
+
background-color: var(--bg-white);
|
| 489 |
+
padding: 12px 20px;
|
| 490 |
+
border-radius: 8px;
|
| 491 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
| 492 |
+
z-index: 300;
|
| 493 |
+
display: flex;
|
| 494 |
+
align-items: center;
|
| 495 |
+
opacity: 0;
|
| 496 |
+
transition: opacity 0.3s, top 0.3s;
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
.push-notification.show {
|
| 500 |
+
opacity: 1;
|
| 501 |
+
top: 30px;
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
.push-notification-avatar {
|
| 505 |
+
width: 40px;
|
| 506 |
+
height: 40px;
|
| 507 |
+
border-radius: 50%;
|
| 508 |
+
object-fit: cover;
|
| 509 |
+
margin-left: 10px;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
.push-notification-text {
|
| 513 |
+
flex: 1;
|
| 514 |
+
font-size: 14px;
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
.push-notification-close {
|
| 518 |
+
color: var(--text-gray);
|
| 519 |
+
cursor: pointer;
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
/* Responsive */
|
| 523 |
@media (max-width: 450px) {
|
| 524 |
+
.friend-avatar, .message-avatar, .notification-avatar {
|
| 525 |
width: 45px;
|
| 526 |
height: 45px;
|
| 527 |
}
|
|
|
|
| 530 |
padding: 5px 8px;
|
| 531 |
font-size: 11px;
|
| 532 |
}
|
| 533 |
+
|
| 534 |
+
.notifications-modal {
|
| 535 |
+
width: 300px;
|
| 536 |
+
right: 5px;
|
| 537 |
+
}
|
| 538 |
}
|
| 539 |
</style>
|
| 540 |
</head>
|
|
|
|
| 543 |
<div class="header">
|
| 544 |
<div class="header-logo">إنستا</div>
|
| 545 |
<div class="header-icons">
|
| 546 |
+
<i class="far fa-heart" id="notificationsBtn">
|
| 547 |
+
<span class="notification-badge" id="notificationBadge" style="display: none;">0</span>
|
| 548 |
+
</i>
|
| 549 |
<i class="far fa-paper-plane" id="messagesBtn"></i>
|
| 550 |
</div>
|
| 551 |
</div>
|
|
|
|
| 557 |
<div class="tab-btn active" data-tab="friends">طلبات الصداقة</div>
|
| 558 |
<div class="tab-btn" data-tab="suggestions">اقتراحات</div>
|
| 559 |
<div class="tab-btn" data-tab="messages">المراسلة</div>
|
| 560 |
+
<div class="tab-btn" data-tab="search">بحث</div>
|
| 561 |
</div>
|
| 562 |
|
| 563 |
<!-- Friend Requests Tab -->
|
|
|
|
| 595 |
<!-- سيتم ملؤها بالرسائل ديناميكيًا -->
|
| 596 |
</div>
|
| 597 |
</div>
|
| 598 |
+
|
| 599 |
+
<!-- Search Tab -->
|
| 600 |
+
<div class="tab-content" id="search-tab">
|
| 601 |
+
<div class="search-container">
|
| 602 |
+
<input type="text" class="search-input" placeholder="ابحث عن أشخاص أو منشورات..." id="searchInput">
|
| 603 |
+
|
| 604 |
+
<div class="search-tabs">
|
| 605 |
+
<div class="search-tab active" data-search-tab="posts">منشورات</div>
|
| 606 |
+
<div class="search-tab" data-search-tab="people">أشخاص</div>
|
| 607 |
+
</div>
|
| 608 |
+
|
| 609 |
+
<div id="searchResults">
|
| 610 |
+
<div class="posts-grid" id="postsGrid">
|
| 611 |
+
<!-- سيتم ملؤها بالمنشورات ديناميكيًا -->
|
| 612 |
+
</div>
|
| 613 |
+
|
| 614 |
+
<div id="peopleResults" style="display: none;">
|
| 615 |
+
<!-- سيتم ملؤها بالأشخاص ديناميكيًا -->
|
| 616 |
+
</div>
|
| 617 |
+
</div>
|
| 618 |
+
</div>
|
| 619 |
+
</div>
|
| 620 |
</div>
|
| 621 |
|
| 622 |
<!-- Bottom Navigation -->
|
| 623 |
<div class="bottom-nav">
|
| 624 |
<i class="fas fa-home active"></i>
|
| 625 |
+
<i class="fas fa-search" id="searchBtn"></i>
|
| 626 |
<i class="far fa-plus-square"></i>
|
| 627 |
+
<i class="far fa-heart" id="notificationsBtnMobile"></i>
|
| 628 |
<i class="fas fa-user"></i>
|
| 629 |
</div>
|
| 630 |
|
|
|
|
| 647 |
</div>
|
| 648 |
</div>
|
| 649 |
|
| 650 |
+
<!-- Notifications Modal -->
|
| 651 |
+
<div class="notifications-modal" id="notificationsModal">
|
| 652 |
+
<div class="notifications-header">
|
| 653 |
+
<span>الإشعارات</span>
|
| 654 |
+
<i class="fas fa-times notifications-close" id="notificationsClose"></i>
|
| 655 |
+
</div>
|
| 656 |
+
<div class="notifications-list" id="notificationsList">
|
| 657 |
+
<!-- سيتم ملؤها بالإشعارات ديناميكيًا -->
|
| 658 |
+
</div>
|
| 659 |
+
</div>
|
| 660 |
+
|
| 661 |
+
<!-- Push Notification -->
|
| 662 |
+
<div class="push-notification" id="pushNotification">
|
| 663 |
+
<img src="" class="push-notification-avatar" id="pushNotificationAvatar">
|
| 664 |
+
<div class="push-notification-text" id="pushNotificationText"></div>
|
| 665 |
+
<i class="fas fa-times push-notification-close" id="pushNotificationClose"></i>
|
| 666 |
+
</div>
|
| 667 |
+
|
| 668 |
<script>
|
| 669 |
// بيانات التطبيق
|
| 670 |
const appData = {
|
|
|
|
| 808 |
]
|
| 809 |
}
|
| 810 |
],
|
| 811 |
+
friends: [],
|
| 812 |
+
notifications: [
|
| 813 |
+
{
|
| 814 |
+
id: 1,
|
| 815 |
+
type: "like",
|
| 816 |
+
user: {
|
| 817 |
+
id: 2,
|
| 818 |
+
name: "أحمد محمد",
|
| 819 |
+
avatar: "https://randomuser.me/api/portraits/men/32.jpg"
|
| 820 |
+
},
|
| 821 |
+
post: {
|
| 822 |
+
id: 101,
|
| 823 |
+
thumbnail: "https://picsum.photos/id/101/300/300"
|
| 824 |
+
},
|
| 825 |
+
time: "منذ دقائق",
|
| 826 |
+
read: false
|
| 827 |
+
},
|
| 828 |
+
{
|
| 829 |
+
id: 2,
|
| 830 |
+
type: "comment",
|
| 831 |
+
user: {
|
| 832 |
+
id: 3,
|
| 833 |
+
name: "ليلى خالد",
|
| 834 |
+
avatar: "https://randomuser.me/api/portraits/women/63.jpg"
|
| 835 |
+
},
|
| 836 |
+
post: {
|
| 837 |
+
id: 102,
|
| 838 |
+
thumbnail: "https://picsum.photos/id/102/300/300"
|
| 839 |
+
},
|
| 840 |
+
text: "هذه الصورة رائعة!",
|
| 841 |
+
time: "منذ ساعة",
|
| 842 |
+
read: false
|
| 843 |
+
},
|
| 844 |
+
{
|
| 845 |
+
id: 3,
|
| 846 |
+
type: "friend_request",
|
| 847 |
+
user: {
|
| 848 |
+
id: 4,
|
| 849 |
+
name: "محمد علي",
|
| 850 |
+
avatar: "https://randomuser.me/api/portraits/men/45.jpg"
|
| 851 |
+
},
|
| 852 |
+
time: "منذ يوم",
|
| 853 |
+
read: true
|
| 854 |
+
},
|
| 855 |
+
{
|
| 856 |
+
id: 4,
|
| 857 |
+
type: "follow",
|
| 858 |
+
user: {
|
| 859 |
+
id: 5,
|
| 860 |
+
name: "نورا سعيد",
|
| 861 |
+
avatar: "https://randomuser.me/api/portraits/women/22.jpg"
|
| 862 |
+
},
|
| 863 |
+
time: "منذ يومين",
|
| 864 |
+
read: true
|
| 865 |
+
}
|
| 866 |
+
],
|
| 867 |
+
posts: [
|
| 868 |
+
{
|
| 869 |
+
id: 101,
|
| 870 |
+
image: "https://picsum.photos/id/101/800/800",
|
| 871 |
+
thumbnail: "https://picsum.photos/id/101/300/300",
|
| 872 |
+
likes: 124,
|
| 873 |
+
comments: 23,
|
| 874 |
+
caption: "يوم جميل في الطبيعة 🌿",
|
| 875 |
+
time: "منذ 3 ساعات"
|
| 876 |
+
},
|
| 877 |
+
{
|
| 878 |
+
id: 102,
|
| 879 |
+
image: "https://picsum.photos/id/102/800/800",
|
| 880 |
+
thumbnail: "https://picsum.photos/id/102/300/300",
|
| 881 |
+
likes: 89,
|
| 882 |
+
comments: 12,
|
| 883 |
+
caption: "وجبة غداء لذيذة 🍽️",
|
| 884 |
+
time: "منذ يوم"
|
| 885 |
+
},
|
| 886 |
+
{
|
| 887 |
+
id: 103,
|
| 888 |
+
image: "https://picsum.photos/id/103/800/800",
|
| 889 |
+
thumbnail: "https://picsum.photos/id/103/300/300",
|
| 890 |
+
likes: 215,
|
| 891 |
+
comments: 45,
|
| 892 |
+
caption: "رحلتي إلى الجبل ⛰️",
|
| 893 |
+
time: "منذ 3 أيام"
|
| 894 |
+
},
|
| 895 |
+
{
|
| 896 |
+
id: 104,
|
| 897 |
+
image: "https://picsum.photos/id/104/800/800",
|
| 898 |
+
thumbnail: "https://picsum.photos/id/104/300/300",
|
| 899 |
+
likes: 56,
|
| 900 |
+
comments: 8,
|
| 901 |
+
caption: "قراءة كتاب جديد 📖",
|
| 902 |
+
time: "منذ أسبوع"
|
| 903 |
+
},
|
| 904 |
+
{
|
| 905 |
+
id: 105,
|
| 906 |
+
image: "https://picsum.photos/id/105/800/800",
|
| 907 |
+
thumbnail: "https://picsum.photos/id/105/300/300",
|
| 908 |
+
likes: 312,
|
| 909 |
+
comments: 67,
|
| 910 |
+
caption: "حفل موسيقي رائع 🎵",
|
| 911 |
+
time: "منذ أسبوعين"
|
| 912 |
+
},
|
| 913 |
+
{
|
| 914 |
+
id: 106,
|
| 915 |
+
image: "https://picsum.photos/id/106/800/800",
|
| 916 |
+
thumbnail: "https://picsum.photos/id/106/300/300",
|
| 917 |
+
likes: 78,
|
| 918 |
+
comments: 15,
|
| 919 |
+
caption: "وقت ممتع مع الأصدقاء 👫",
|
| 920 |
+
time: "منذ شهر"
|
| 921 |
+
}
|
| 922 |
+
]
|
| 923 |
};
|
| 924 |
|
| 925 |
// عناصر DOM
|
|
|
|
| 936 |
const chatTitle = document.getElementById('chatTitle');
|
| 937 |
const messagesBtn = document.getElementById('messagesBtn');
|
| 938 |
const notificationsBtn = document.getElementById('notificationsBtn');
|
| 939 |
+
const notificationsBtnMobile = document.getElementById('notificationsBtnMobile');
|
| 940 |
const seeAllRequests = document.getElementById('seeAllRequests');
|
| 941 |
const refreshSuggestions = document.getElementById('refreshSuggestions');
|
| 942 |
const newMessageBtn = document.getElementById('newMessageBtn');
|
| 943 |
+
const searchBtn = document.getElementById('searchBtn');
|
| 944 |
+
const searchInput = document.getElementById('searchInput');
|
| 945 |
+
const searchTabs = document.querySelectorAll('.search-tab');
|
| 946 |
+
const postsGrid = document.getElementById('postsGrid');
|
| 947 |
+
const peopleResults = document.getElementById('peopleResults');
|
| 948 |
+
const notificationsModal = document.getElementById('notificationsModal');
|
| 949 |
+
const notificationsList = document.getElementById('notificationsList');
|
| 950 |
+
const notificationsClose = document.getElementById('notificationsClose');
|
| 951 |
+
const notificationBadge = document.getElementById('notificationBadge');
|
| 952 |
+
const pushNotification = document.getElementById('pushNotification');
|
| 953 |
+
const pushNotificationAvatar = document.getElementById('pushNotificationAvatar');
|
| 954 |
+
const pushNotificationText = document.getElementById('pushNotificationText');
|
| 955 |
+
const pushNotificationClose = document.getElementById('pushNotificationClose');
|
| 956 |
|
| 957 |
// تهيئة الصفحة
|
| 958 |
function initPage() {
|
| 959 |
renderFriendRequests();
|
| 960 |
renderSuggestedFriends();
|
| 961 |
renderMessages();
|
| 962 |
+
renderPosts();
|
| 963 |
+
renderNotifications();
|
| 964 |
setupEventListeners();
|
| 965 |
+
updateNotificationBadge();
|
| 966 |
+
|
| 967 |
+
// محاكاة إشعارات واردة عند الخروج من التطبيق
|
| 968 |
+
window.addEventListener('blur', () => {
|
| 969 |
+
setTimeout(() => {
|
| 970 |
+
if (document.hidden) {
|
| 971 |
+
showRandomPushNotification();
|
| 972 |
+
}
|
| 973 |
+
}, 3000);
|
| 974 |
+
});
|
| 975 |
}
|
| 976 |
|
| 977 |
// إعداد مستمعي الأحداث
|
|
|
|
| 996 |
document.getElementById('messages-tab').classList.add('active');
|
| 997 |
});
|
| 998 |
|
| 999 |
+
notificationsBtn.addEventListener('click', toggleNotificationsModal);
|
| 1000 |
+
notificationsBtnMobile.addEventListener('click', toggleNotificationsModal);
|
| 1001 |
+
|
| 1002 |
+
notificationsClose.addEventListener('click', toggleNotificationsModal);
|
|
|
|
|
|
|
|
|
|
| 1003 |
|
| 1004 |
chatBackBtn.addEventListener('click', closeChat);
|
| 1005 |
|
|
|
|
| 1028 |
e.preventDefault();
|
| 1029 |
startNewMessage();
|
| 1030 |
});
|
| 1031 |
+
|
| 1032 |
+
// البحث
|
| 1033 |
+
searchBtn.addEventListener('click', () => {
|
| 1034 |
+
tabBtns.forEach(b => b.classList.remove('active'));
|
| 1035 |
+
document.querySelector('.tab-btn[data-tab="search"]').classList.add('active');
|
| 1036 |
+
|
| 1037 |
+
tabContents.forEach(content => content.classList.remove('active'));
|
| 1038 |
+
document.getElementById('search-tab').classList.add('active');
|
| 1039 |
+
});
|
| 1040 |
+
|
| 1041 |
+
// تبويبات البحث
|
| 1042 |
+
searchTabs.forEach(tab => {
|
| 1043 |
+
tab.addEventListener('click', () => {
|
| 1044 |
+
searchTabs.forEach(t => t.classList.remove('active'));
|
| 1045 |
+
tab.classList.add('active');
|
| 1046 |
+
|
| 1047 |
+
if (tab.dataset.searchTab === 'posts') {
|
| 1048 |
+
postsGrid.style.display = 'grid';
|
| 1049 |
+
peopleResults.style.display = 'none';
|
| 1050 |
+
} else {
|
| 1051 |
+
postsGrid.style.display = 'none';
|
| 1052 |
+
peopleResults.style.display = 'block';
|
| 1053 |
+
renderPeopleSearchResults();
|
| 1054 |
+
}
|
| 1055 |
+
});
|
| 1056 |
+
});
|
| 1057 |
+
|
| 1058 |
+
// حقل البحث
|
| 1059 |
+
searchInput.addEventListener('input', (e) => {
|
| 1060 |
+
const query = e.target.value.trim();
|
| 1061 |
+
if (query.length > 0) {
|
| 1062 |
+
// في تطبيق حقيقي، سيتم البحث في الخادم
|
| 1063 |
+
console.log('بحث عن:', query);
|
| 1064 |
+
}
|
| 1065 |
+
});
|
| 1066 |
+
|
| 1067 |
+
// إغلاق الإشعار العاجل
|
| 1068 |
+
pushNotificationClose.addEventListener('click', () => {
|
| 1069 |
+
pushNotification.classList.remove('show');
|
| 1070 |
+
});
|
| 1071 |
}
|
| 1072 |
|
| 1073 |
// عرض طلبات الصداقة
|
|
|
|
| 1152 |
});
|
| 1153 |
}
|
| 1154 |
|
| 1155 |
+
// عرض المنشورات
|
| 1156 |
+
function renderPosts() {
|
| 1157 |
+
postsGrid.innerHTML = '';
|
| 1158 |
+
|
| 1159 |
+
appData.posts.forEach(post => {
|
| 1160 |
+
const postElement = document.createElement('div');
|
| 1161 |
+
postElement.innerHTML = `
|
| 1162 |
+
<img src="${post.thumbnail}" class="post-thumbnail" alt="منشور ${post.id}">
|
| 1163 |
+
`;
|
| 1164 |
+
|
| 1165 |
+
postElement.addEventListener('click', () => viewPost(post.id));
|
| 1166 |
+
postsGrid.appendChild(postElement);
|
| 1167 |
+
});
|
| 1168 |
+
}
|
| 1169 |
+
|
| 1170 |
+
// عرض نتائج البحث عن الأشخاص
|
| 1171 |
+
function renderPeopleSearchResults() {
|
| 1172 |
+
peopleResults.innerHTML = '';
|
| 1173 |
+
|
| 1174 |
+
// عرض اقتراحات الأصدقاء في نتائج البحث
|
| 1175 |
+
appData.suggestedFriends.forEach(friend => {
|
| 1176 |
+
const friendElement = document.createElement('div');
|
| 1177 |
+
friendElement.className = 'suggested-friend-item';
|
| 1178 |
+
friendElement.innerHTML = `
|
| 1179 |
+
<img src="${friend.avatar}" class="friend-avatar" alt="${friend.name}">
|
| 1180 |
+
<div class="friend-info">
|
| 1181 |
+
<div class="friend-name">${friend.name}</div>
|
| 1182 |
+
<div class="friend-meta">${friend.mutualFriends} أصدقاء مشتركين</div>
|
| 1183 |
+
</div>
|
| 1184 |
+
<div class="friend-actions">
|
| 1185 |
+
<button class="btn btn-primary" onclick="sendFriendRequest(${friend.id})">إرسال طلب</button>
|
| 1186 |
+
</div>
|
| 1187 |
+
`;
|
| 1188 |
+
|
| 1189 |
+
peopleResults.appendChild(friendElement);
|
| 1190 |
+
});
|
| 1191 |
+
}
|
| 1192 |
+
|
| 1193 |
+
// عرض الإشعارات
|
| 1194 |
+
function renderNotifications() {
|
| 1195 |
+
notificationsList.innerHTML = '';
|
| 1196 |
+
|
| 1197 |
+
if (appData.notifications.length === 0) {
|
| 1198 |
+
notificationsList.innerHTML = '<p style="text-align: center; color: var(--text-gray); padding: 20px;">لا توجد إشعارات جديدة</p>';
|
| 1199 |
+
return;
|
| 1200 |
+
}
|
| 1201 |
+
|
| 1202 |
+
appData.notifications.forEach(notification => {
|
| 1203 |
+
const notificationElement = document.createElement('div');
|
| 1204 |
+
notificationElement.className = `notification-item ${notification.read ? '' : 'unread'}`;
|
| 1205 |
+
|
| 1206 |
+
let notificationContent = '';
|
| 1207 |
+
|
| 1208 |
+
if (notification.type === "like") {
|
| 1209 |
+
notificationContent = `
|
| 1210 |
+
<img src="${notification.user.avatar}" class="notification-avatar" alt="${notification.user.name}">
|
| 1211 |
+
<div class="notification-info">
|
| 1212 |
+
<div class="notification-text">
|
| 1213 |
+
<span>${notification.user.name}</span> أعجب بمنشورك
|
| 1214 |
+
</div>
|
| 1215 |
+
<div class="notification-time">${notification.time}</div>
|
| 1216 |
+
</div>
|
| 1217 |
+
<img src="${notification.post.thumbnail}" class="notification-avatar" alt="منشور">
|
| 1218 |
+
`;
|
| 1219 |
+
} else if (notification.type === "comment") {
|
| 1220 |
+
notificationContent = `
|
| 1221 |
+
<img src="${notification.user.avatar}" class="notification-avatar" alt="${notification.user.name}">
|
| 1222 |
+
<div class="notification-info">
|
| 1223 |
+
<div class="notification-text">
|
| 1224 |
+
<span>${notification.user.name}</span> علق على منشورك: ${notification.text}
|
| 1225 |
+
</div>
|
| 1226 |
+
<div class="notification-time">${notification.time}</div>
|
| 1227 |
+
</div>
|
| 1228 |
+
<img src="${notification.post.thumbnail}" class="notification-avatar" alt="منشور">
|
| 1229 |
+
`;
|
| 1230 |
+
} else if (notification.type === "friend_request") {
|
| 1231 |
+
notificationContent = `
|
| 1232 |
+
<img src="${notification.user.avatar}" class="notification-avatar" alt="${notification.user.name}">
|
| 1233 |
+
<div class="notification-info">
|
| 1234 |
+
<div class="notification-text">
|
| 1235 |
+
<span>${notification.user.name}</span> أرسل لك طلب صداقة
|
| 1236 |
+
</div>
|
| 1237 |
+
<div class="notification-time">${notification.time}</div>
|
| 1238 |
+
</div>
|
| 1239 |
+
<div class="notification-actions">
|
| 1240 |
+
<button class="btn btn-primary" onclick="acceptFriendRequest(${notification.user.id})">قبول</button>
|
| 1241 |
+
<button class="btn btn-outline" onclick="declineFriendRequest(${notification.user.id})">حذف</button>
|
| 1242 |
+
</div>
|
| 1243 |
+
`;
|
| 1244 |
+
} else if (notification.type === "follow") {
|
| 1245 |
+
notificationContent = `
|
| 1246 |
+
<img src="${notification.user.avatar}" class="notification-avatar" alt="${notification.user.name}">
|
| 1247 |
+
<div class="notification-info">
|
| 1248 |
+
<div class="notification-text">
|
| 1249 |
+
<span>${notification.user.name}</span> بدأ متابعتك
|
| 1250 |
+
</div>
|
| 1251 |
+
<div class="notification-time">${notification.time}</div>
|
| 1252 |
+
</div>
|
| 1253 |
+
<div class="notification-actions">
|
| 1254 |
+
<button class="btn btn-outline">متابعة</button>
|
| 1255 |
+
</div>
|
| 1256 |
+
`;
|
| 1257 |
+
}
|
| 1258 |
+
|
| 1259 |
+
notificationElement.innerHTML = notificationContent;
|
| 1260 |
+
notificationElement.addEventListener('click', () => markNotificationAsRead(notification.id));
|
| 1261 |
+
notificationsList.appendChild(notificationElement);
|
| 1262 |
+
});
|
| 1263 |
+
}
|
| 1264 |
+
|
| 1265 |
+
// تحديث شارة الإشعارات
|
| 1266 |
+
function updateNotificationBadge() {
|
| 1267 |
+
const unreadCount = appData.notifications.filter(n => !n.read).length;
|
| 1268 |
+
if (unreadCount > 0) {
|
| 1269 |
+
notificationBadge.style.display = 'flex';
|
| 1270 |
+
notificationBadge.textContent = unreadCount;
|
| 1271 |
+
} else {
|
| 1272 |
+
notificationBadge.style.display = 'none';
|
| 1273 |
+
}
|
| 1274 |
+
}
|
| 1275 |
+
|
| 1276 |
// قبول طلب صداقة
|
| 1277 |
function acceptFriendRequest(userId) {
|
| 1278 |
const requestIndex = appData.friendRequests.findIndex(req => req.id === userId);
|
|
|
|
| 1290 |
// إزالة الطلب من القائمة
|
| 1291 |
appData.friendRequests.splice(requestIndex, 1);
|
| 1292 |
|
| 1293 |
+
// إضافة إشعار
|
| 1294 |
+
addNotification({
|
| 1295 |
+
type: "friend_accepted",
|
| 1296 |
+
user: acceptedUser,
|
| 1297 |
+
time: "الآن"
|
| 1298 |
+
});
|
| 1299 |
+
|
| 1300 |
// عرض تنبيه
|
| 1301 |
showAlert('تم قبول طلب الصداقة بنجاح', 'success');
|
| 1302 |
|
| 1303 |
// تحديث الواجهة
|
| 1304 |
renderFriendRequests();
|
| 1305 |
+
renderNotifications();
|
| 1306 |
+
updateNotificationBadge();
|
| 1307 |
}
|
| 1308 |
}
|
| 1309 |
|
|
|
|
| 1324 |
const friend = appData.suggestedFriends[friendIndex];
|
| 1325 |
showAlert(`تم إرسال طلب صداقة إلى ${friend.name}`, 'success');
|
| 1326 |
|
| 1327 |
+
// إضافة إشعار للمستخدم الآخر (محاكاة)
|
| 1328 |
+
addNotification({
|
| 1329 |
+
type: "friend_request",
|
| 1330 |
+
user: appData.currentUser,
|
| 1331 |
+
time: "الآن"
|
| 1332 |
+
});
|
| 1333 |
+
|
| 1334 |
// في تطبيق حقيقي، سيتم إرسال الطلب إلى الخادم
|
| 1335 |
setTimeout(() => {
|
| 1336 |
removeSuggestion(userId);
|
|
|
|
| 1344 |
if (friendIndex !== -1) {
|
| 1345 |
appData.suggestedFriends.splice(friendIndex, 1);
|
| 1346 |
renderSuggestedFriends();
|
| 1347 |
+
|
| 1348 |
+
// إذا كانت صفحة البحث مفتوحة، قم بتحديثها أيضًا
|
| 1349 |
+
if (peopleResults.style.display !== 'none') {
|
| 1350 |
+
renderPeopleSearchResults();
|
| 1351 |
+
}
|
| 1352 |
}
|
| 1353 |
}
|
| 1354 |
|
|
|
|
| 1455 |
|
| 1456 |
if (!chatModal.style.display || chatModal.style.display === 'none') {
|
| 1457 |
message.unread = true;
|
| 1458 |
+
|
| 1459 |
+
// إضافة إشعار
|
| 1460 |
+
addNotification({
|
| 1461 |
+
type: "message",
|
| 1462 |
+
user: message.user,
|
| 1463 |
+
time: "الآن"
|
| 1464 |
+
});
|
| 1465 |
} else {
|
| 1466 |
const replyElement = document.createElement('div');
|
| 1467 |
replyElement.className = 'message-bubble message-in';
|
|
|
|
| 1474 |
}
|
| 1475 |
|
| 1476 |
renderMessages();
|
| 1477 |
+
updateNotificationBadge();
|
| 1478 |
}, 2000);
|
| 1479 |
}
|
| 1480 |
}
|
|
|
|
| 1509 |
}
|
| 1510 |
}
|
| 1511 |
|
| 1512 |
+
// عرض منشور
|
| 1513 |
+
function viewPost(postId) {
|
| 1514 |
+
const post = appData.posts.find(p => p.id === postId);
|
| 1515 |
+
if (post) {
|
| 1516 |
+
alert(`عرض المنشور ${postId}: ${post.caption}\nالإعجابات: ${post.likes} | التعليقات: ${post.comments}`);
|
| 1517 |
+
}
|
| 1518 |
+
}
|
| 1519 |
+
|
| 1520 |
+
// تبديل نافذة الإشعارات
|
| 1521 |
+
function toggleNotificationsModal() {
|
| 1522 |
+
if (notificationsModal.style.display === 'block') {
|
| 1523 |
+
notificationsModal.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1524 |
} else {
|
| 1525 |
+
notificationsModal.style.display = 'block';
|
| 1526 |
+
|
| 1527 |
+
// وضع علامة على جميع الإشعارات كمقروءة عند فتحها
|
| 1528 |
+
appData.notifications.forEach(notification => {
|
| 1529 |
+
notification.read = true;
|
| 1530 |
+
});
|
| 1531 |
+
|
| 1532 |
+
updateNotificationBadge();
|
| 1533 |
+
renderNotifications();
|
| 1534 |
}
|
| 1535 |
+
}
|
| 1536 |
+
|
| 1537 |
+
// وضع علامة على إشعار كمقروء
|
| 1538 |
+
function markNotificationAsRead(notificationId) {
|
| 1539 |
+
const notification = appData.notifications.find(n => n.id === notificationId);
|
| 1540 |
+
if (notification && !notification.read) {
|
| 1541 |
+
notification.read = true;
|
| 1542 |
+
updateNotificationBadge();
|
| 1543 |
+
renderNotifications();
|
| 1544 |
+
}
|
| 1545 |
+
}
|
| 1546 |
+
|
| 1547 |
+
// إضافة إشعار جديد
|
| 1548 |
+
function addNotification(notificationData) {
|
| 1549 |
+
const newNotification = {
|
| 1550 |
+
id: appData.notifications.length + 1,
|
| 1551 |
+
read: false,
|
| 1552 |
+
...notificationData
|
| 1553 |
+
};
|
| 1554 |
+
|
| 1555 |
+
appData.notifications.unshift(newNotification);
|
| 1556 |
|
| 1557 |
+
// عرض إشعار عاجل إذا لم تكن نافذة الإشعارات مفتوحة
|
| 1558 |
+
if (notificationsModal.style.display !== 'block') {
|
| 1559 |
+
showPushNotification(newNotification);
|
| 1560 |
+
}
|
| 1561 |
|
| 1562 |
+
updateNotificationBadge();
|
| 1563 |
+
}
|
| 1564 |
+
|
| 1565 |
+
// عرض إشعار عاجل
|
| 1566 |
+
function showPushNotification(notification) {
|
| 1567 |
+
pushNotificationAvatar.src = notification.user.avatar;
|
| 1568 |
+
|
| 1569 |
+
let notificationText = '';
|
| 1570 |
+
if (notification.type === "like") {
|
| 1571 |
+
notificationText = `${notification.user.name} أعجب بمنشورك`;
|
| 1572 |
+
} else if (notification.type === "comment") {
|
| 1573 |
+
notificationText = `${notification.user.name} علق على منشورك`;
|
| 1574 |
+
} else if (notification.type === "friend_request") {
|
| 1575 |
+
notificationText = `${notification.user.name} أرسل لك طلب صداقة`;
|
| 1576 |
+
} else if (notification.type === "friend_accepted") {
|
| 1577 |
+
notificationText = `${notification.user.name} قبل طلب صداقتك`;
|
| 1578 |
+
} else if (notification.type === "message") {
|
| 1579 |
+
notificationText = `${notification.user.name} أرسل لك رسالة`;
|
| 1580 |
+
} else if (notification.type === "follow") {
|
| 1581 |
+
notificationText = `${notification.user.name} بدأ متابعتك`;
|
| 1582 |
+
}
|
| 1583 |
+
|
| 1584 |
+
pushNotificationText.textContent = notificationText;
|
| 1585 |
+
pushNotification.classList.add('show');
|
| 1586 |
+
|
| 1587 |
+
// إخفاء الإشعار تلقائيًا بعد 5 ثواني
|
| 1588 |
setTimeout(() => {
|
| 1589 |
+
pushNotification.classList.remove('show');
|
| 1590 |
+
}, 5000);
|
| 1591 |
+
}
|
| 1592 |
+
|
| 1593 |
+
// عرض إشعار عاجل عشوائي (محاكاة عند الخروج من التطبيق)
|
| 1594 |
+
function showRandomPushNotification() {
|
| 1595 |
+
const types = ["like", "comment", "friend_request", "message", "follow"];
|
| 1596 |
+
const randomType = types[Math.floor(Math.random() * types.length)];
|
| 1597 |
+
const randomUser = appData.suggestedFriends[Math.floor(Math.random() * appData.suggestedFriends.length)];
|
| 1598 |
+
|
| 1599 |
+
if (randomUser) {
|
| 1600 |
+
const notification = {
|
| 1601 |
+
id: appData.notifications.length + 1,
|
| 1602 |
+
type: randomType,
|
| 1603 |
+
user: randomUser,
|
| 1604 |
+
time: "الآن",
|
| 1605 |
+
read: false
|
| 1606 |
+
};
|
| 1607 |
+
|
| 1608 |
+
if (randomType === "like" || randomType === "comment") {
|
| 1609 |
+
notification.post = {
|
| 1610 |
+
id: Math.floor(Math.random() * 1000),
|
| 1611 |
+
thumbnail: `https://picsum.photos/id/${Math.floor(Math.random() * 1000)}/300/300`
|
| 1612 |
+
};
|
| 1613 |
+
}
|
| 1614 |
+
|
| 1615 |
+
addNotification(notification);
|
| 1616 |
+
}
|
| 1617 |
}
|
| 1618 |
|
| 1619 |
+
//
|
|
|
|
|
|
|
|
|
|
| 1620 |
</html>
|