-
Notifications
You must be signed in to change notification settings - Fork 442
/
activity.js
80 lines (75 loc) · 2.49 KB
/
activity.js
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
const listItems = document.querySelectorAll('.activity-feed li');
listItems.forEach((item, index) => {
item.addEventListener('click', () => {
const detailElement = item.querySelector('.detail');
// If details are already open, close them
if (detailElement) {
detailElement.remove();
} else {
// Close any open details
const openDetails = document.querySelectorAll('.detail');
openDetails.forEach((detail) => {
detail.remove();
});
// Open the clicked item's details
const detailHtml = getDetailHtml(index);
const detailContainer = document.createElement('div');
detailContainer.className = 'detail';
detailContainer.innerHTML = detailHtml;
item.appendChild(detailContainer);
}
});
});
function getDetailHtml(index) {
let detailHtml = '';
switch (index) {
case 0:
detailHtml = `
<h3>Profile Update</h3>
<p>Update ID: #1001</p>
<p>Date: 2024-11-05</p>
<p>Time: 13:30</p>
<p>Details: <strong>Profile information updated successfully</strong></p>
`;
break;
case 1:
detailHtml = `
<h3>Friend Request</h3>
<p>Request ID: #1002</p>
<p>Date: 2024-11-05</p>
<p>Time: 11:00</p>
<p>From: <strong>Ritu</strong></p>
`;
break;
case 2:
detailHtml = `
<h3>New Game Alert</h3>
<p>Game ID: #1003</p>
<p>Date: 2024-11-04</p>
<p>Time: 16:00</p>
<p>Game: <strong>Mystery Island</strong></p>
`;
break;
case 3:
detailHtml = `
<h3>Message from Divya</h3>
<p>Message ID: #1004</p>
<p>Date: 2024-11-04</p>
<p>Time: 15:00</p>
<p>Message: "Are you joining the game tonight?"</p>
`;
break;
case 4:
detailHtml = `
<h3>Message from Support</h3>
<p>Message ID: #1005</p>
<p>Date: 2024-11-03</p>
<p>Time: 10:30</p>
<p>Message: "Your issue has been resolved"</p>
`;
break;
default:
detailHtml = '';
}
return detailHtml;
}