-
Notifications
You must be signed in to change notification settings - Fork 15
/
dm_stats.html
209 lines (186 loc) · 6.67 KB
/
dm_stats.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DM Stats</title>
<link rel="icon" href="https://pbs.twimg.com/profile_images/1692481211888025600/lUJUEO_p_400x400.jpg" type="image/png">
<style>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
margin: 0;
padding: 20px;
background-color: #f9e4bc;
color: #CF2D01;
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
text-align: center;
font-size: 2.5rem;
margin-bottom: 1rem;
}
#dmStats {
display: flex;
flex-wrap: wrap;
justify-content: center;
max-width: 1200px;
}
.conversation-wrapper {
width: 50vw;
margin: 10px;
}
.conversation {
background-color: #f9e4bc;
border: 1px solid #CF2D01;
padding: 25px;
margin: 5px;
display: flex;
align-items: center;
border-radius: 10px;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.conversation:hover {
transform: scale(1.02);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.conversation img {
border-radius: 50%;
margin-right: 10px;
}
.username {
font-weight:inherit;
font-size: 1.1rem;
}
.messageCount {
margin-left: auto;
font-size: 0.8rem;
color: #666;
}
.lastMessage {
font-size: 0.9em;
margin: 5px 0;
color: #CF2D01;
font-weight: inherit;
/* padding: 2px 5px; */
border-radius: 5px;
word-wrap: break-word;
}
#backButton {
position: absolute;
top: 3.5vh;
right: 2vw;
padding: 0.5vw 1vw;
font-size: large;
background-color: inherit;
color: #CF2D01;
font-family: Helvetica, Arial, sans-serif;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
}
#backButton:hover {
background-color: #ecb679;
}
.convo-container {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
gap: 20px;
font-weight: 600;
}
.convo-details {
display: flex;
flex-direction: column;
font-size: 1em;
}
.username, .lastMessage, .messageCount {
margin: 2px 0;
}
.messageCount {
font-size: 0.9em; /* Smaller text for less emphasis */
}
/* experimental */
.conversation:hover::after {
content: 'view conversation history graph';
position: absolute;
bottom: -2em;
left: 50%;
transform: translateX(-50%);
background-color: #ecb679; /* Soft Light Grey */
color: #a65336; /* Warm Deep Orange */
padding: 5px;
border-radius: 5px;
font-size: 0.8em;
white-space: nowrap;
border: 1px solid #d9a993; /* Soft Orange for the border */
}
.ranking {
margin-left: auto; /* Pushes the ranking to the right */
padding-right: 10px; /* Optional padding for aesthetic spacing */
font-weight: bold; /* Optional styling to make the ranking stand out */
}
@media (max-width: 768px) {
.conversation-wrapper {
width: 100%;
}
}
</style>
</head>
<body>
<button id="backButton">Back</button>
<h1>DM Stats</h1>
<div id="dmStats"></div>
<script>
document.getElementById('backButton').addEventListener('click', function() {
window.location.href = 'index.html';
});
document.addEventListener('DOMContentLoaded', function() {
fetch('dm_final_stats_with_chart.json')
.then(response => response.json())
.then(data => {
createDMStats(data);
})
.catch(error => console.error('Error loading the data:', error));
});
function createDMStats(conversations) {
const dmStats = document.getElementById('dmStats');
conversations.forEach((convo, index) => {
const convoWrapper = document.createElement('div');
convoWrapper.className = 'conversation-wrapper';
const convoElement = document.createElement('div');
convoElement.className = 'conversation';
const date = convo.lastMessageDate
convoElement.innerHTML = `
<div class="convo-container">
<img src="${convo.imageSrc}" alt="User Image" width="60" height="60">
<div class="convo-details">
<div class="username">@${convo.recipientUsername || 'Unknown'}</div>
<div class="lastMessage">${date.slice(0, 10)}: ${convo.lastMessage}</div>
<div class="messageCount">
Total: ${convo.totalMsgCount}
Sent: ${convo.messagesSent}
${convo.messagesReceived === 0 ? `Received: 0 <span style="color: red;">(Account deleted)</span>` : `Received: ${convo.messagesReceived}`}
</div>
</div>
<div class="ranking">#${index + 1}</div> <!-- Displaying the ranking here -->
</div>
`;
// convoElement.onclick = function() {
// window.open(`https://twitter.com/${convo.recipientUsername}`, '_blank');
// };
convoElement.onclick = function() {
window.location.href = `direct-messaging-stats/chart_draw.html?recipientId=${convo.recipientUserId}`; // Append the ID as a URL parameter
};
convoWrapper.appendChild(convoElement);
dmStats.appendChild(convoWrapper);
});
}
</script>
</body>
</html>