prithivMLmods commited on
Commit
cf4d09c
Β·
verified Β·
1 Parent(s): 1c0ea38

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +776 -0
index.html ADDED
@@ -0,0 +1,776 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>who-liked</title>
7
+ <meta name="description" content="View detailed statistics and timeline of users who liked a HuggingFace model, dataset, or space.">
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
10
+ <style>
11
+ @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');
12
+
13
+ * { box-sizing: border-box; margin: 0; padding: 0; }
14
+
15
+ body {
16
+ font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
17
+ background: #000000;
18
+ color: #ffffff;
19
+ -webkit-font-smoothing: antialiased;
20
+ min-height: 100vh;
21
+ }
22
+
23
+ button, input, select { font-family: inherit; }
24
+ a { text-decoration: none; color: inherit; }
25
+
26
+ ::selection { background: #ffffff; color: #000000; }
27
+
28
+ ::-webkit-scrollbar { width: 6px; height: 6px; }
29
+ ::-webkit-scrollbar-thumb { background: #333333; border-radius: 3px; }
30
+ ::-webkit-scrollbar-thumb:hover { background: #555555; }
31
+ ::-webkit-scrollbar-track { background: #000000; }
32
+
33
+ .terminal-shell {
34
+ max-width: 1100px;
35
+ margin: 0 auto;
36
+ padding: 0;
37
+ min-height: 100vh;
38
+ display: flex;
39
+ flex-direction: column;
40
+ }
41
+
42
+ /* ── Title Bar ── */
43
+ .title-bar {
44
+ display: flex;
45
+ align-items: center;
46
+ padding: 14px 20px;
47
+ border-bottom: 1px solid #222222;
48
+ gap: 12px;
49
+ user-select: none;
50
+ position: sticky;
51
+ top: 0;
52
+ background: #000000;
53
+ z-index: 100;
54
+ }
55
+
56
+ .title-dot {
57
+ width: 10px;
58
+ height: 10px;
59
+ border-radius: 50%;
60
+ background: #ffffff;
61
+ flex-shrink: 0;
62
+ box-shadow: 0 0 6px rgba(255,255,255,0.4);
63
+ }
64
+
65
+ .title-text {
66
+ font-size: 0.85rem;
67
+ font-weight: 600;
68
+ color: #ffffff;
69
+ letter-spacing: 0.02em;
70
+ }
71
+
72
+ /* ── Main Content ── */
73
+ .term-body {
74
+ padding: 20px;
75
+ flex: 1;
76
+ display: flex;
77
+ flex-direction: column;
78
+ }
79
+
80
+ /* ── Input Line ── */
81
+ .input-line {
82
+ display: flex;
83
+ gap: 10px;
84
+ margin-bottom: 20px;
85
+ flex-wrap: wrap;
86
+ }
87
+
88
+ .prompt-group {
89
+ display: flex;
90
+ align-items: center;
91
+ background: #0a0a0a;
92
+ border: 1px solid #222222;
93
+ border-radius: 3px;
94
+ padding: 0 14px;
95
+ height: 40px;
96
+ flex: 1;
97
+ transition: border-color 0.15s;
98
+ }
99
+ .prompt-group:focus-within { border-color: #ffffff; }
100
+
101
+ .prompt-symbol {
102
+ color: #555555;
103
+ font-size: 0.82rem;
104
+ margin-right: 8px;
105
+ white-space: nowrap;
106
+ font-weight: 500;
107
+ }
108
+
109
+ .prompt-group input {
110
+ background: transparent;
111
+ border: none;
112
+ color: #ffffff;
113
+ width: 100%;
114
+ outline: none;
115
+ font-size: 0.82rem;
116
+ font-weight: 400;
117
+ }
118
+ .prompt-group input::placeholder { color: #444444; }
119
+
120
+ .exec-btn {
121
+ background: #ffffff;
122
+ color: #000000;
123
+ border: none;
124
+ padding: 0 24px;
125
+ border-radius: 3px;
126
+ font-weight: 700;
127
+ cursor: pointer;
128
+ height: 40px;
129
+ display: flex;
130
+ align-items: center;
131
+ gap: 8px;
132
+ font-size: 0.82rem;
133
+ transition: opacity 0.15s;
134
+ white-space: nowrap;
135
+ }
136
+ .exec-btn:hover { opacity: 0.85; }
137
+ .exec-btn:disabled { opacity: 0.4; cursor: wait; }
138
+
139
+ /* ── Status ── */
140
+ #statusMsg {
141
+ padding: 10px 14px;
142
+ margin-bottom: 14px;
143
+ font-size: 0.78rem;
144
+ border-radius: 3px;
145
+ display: none;
146
+ border: 1px solid #222222;
147
+ }
148
+ .error { color: #ffffff; background: #1a0000; border-color: #440000 !important; }
149
+ .loading { color: #ffffff; background: #0a0a0a; border-color: #333333 !important; }
150
+
151
+ /* ── Empty State ── */
152
+ .empty-state {
153
+ text-align: center;
154
+ padding-top: 40px;
155
+ }
156
+
157
+ .empty-title {
158
+ font-size: 1.1rem;
159
+ font-weight: 600;
160
+ color: #ffffff;
161
+ margin-bottom: 8px;
162
+ }
163
+
164
+ .empty-desc {
165
+ color: #666666;
166
+ font-size: 0.8rem;
167
+ margin-bottom: 32px;
168
+ line-height: 1.6;
169
+ max-width: 600px;
170
+ margin-left: auto;
171
+ margin-right: auto;
172
+ }
173
+
174
+ /* ── Profile Card ── */
175
+ .profile-block {
176
+ border: 1px solid #222222;
177
+ border-radius: 3px;
178
+ padding: 20px;
179
+ margin-bottom: 16px;
180
+ animation: termSlide 0.25s ease-out;
181
+ }
182
+
183
+ @keyframes termSlide {
184
+ from { opacity: 0; max-height: 0; }
185
+ to { opacity: 1; max-height: 500px; }
186
+ }
187
+ @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
188
+
189
+ .profile-top {
190
+ display: flex;
191
+ align-items: center;
192
+ gap: 16px;
193
+ }
194
+
195
+ .profile-info { flex: 1; }
196
+
197
+ .profile-name {
198
+ font-size: 1rem;
199
+ font-weight: 700;
200
+ color: #ffffff;
201
+ display: flex;
202
+ align-items: center;
203
+ gap: 10px;
204
+ flex-wrap: wrap;
205
+ }
206
+ .profile-name a { color: #ffffff; }
207
+ .profile-name a:hover { text-decoration: underline; }
208
+
209
+ .profile-fullname {
210
+ font-size: 0.78rem;
211
+ color: #666666;
212
+ margin-top: 2px;
213
+ }
214
+
215
+ /* ── Chart Section ── */
216
+ .chart-container {
217
+ border: 1px solid #222222;
218
+ border-radius: 3px;
219
+ padding: 20px;
220
+ margin-bottom: 16px;
221
+ background: #0a0a0a;
222
+ position: relative;
223
+ height: 400px;
224
+ }
225
+
226
+ /* ── Tree / List ── */
227
+ .tree-wrapper {
228
+ border: 1px solid #222222;
229
+ border-radius: 3px;
230
+ display: flex;
231
+ flex-direction: column;
232
+ background: #000000;
233
+ overflow: hidden;
234
+ }
235
+
236
+ .tree-header {
237
+ background: #0a0a0a;
238
+ padding: 10px 16px;
239
+ border-bottom: 1px solid #222222;
240
+ display: flex;
241
+ justify-content: space-between;
242
+ align-items: center;
243
+ flex-wrap: wrap;
244
+ gap: 8px;
245
+ }
246
+
247
+ .tree-title {
248
+ font-size: 0.78rem;
249
+ font-weight: 600;
250
+ color: #666666;
251
+ }
252
+
253
+ .terminal-window {
254
+ background: #000000;
255
+ display: flex;
256
+ overflow: auto;
257
+ font-size: 12.5px;
258
+ line-height: 1.7;
259
+ max-height: 60vh;
260
+ }
261
+
262
+ .line-col {
263
+ padding: 14px 10px;
264
+ text-align: right;
265
+ color: #333333;
266
+ border-right: 1px solid #1a1a1a;
267
+ min-width: 44px;
268
+ user-select: none;
269
+ font-size: 0.7rem;
270
+ font-weight: 500;
271
+ }
272
+ .line-col div {
273
+ height: 30px;
274
+ display: flex;
275
+ align-items: center;
276
+ justify-content: flex-end;
277
+ }
278
+
279
+ .code-col {
280
+ padding: 14px;
281
+ flex: 1;
282
+ white-space: pre;
283
+ min-width: 0;
284
+ }
285
+
286
+ .tree-line {
287
+ display: flex;
288
+ align-items: center;
289
+ height: 30px;
290
+ border-radius: 2px;
291
+ padding: 0 6px;
292
+ gap: 2px;
293
+ }
294
+ .tree-line:hover { background: #0d0d0d; }
295
+
296
+ .t-prefix {
297
+ color: #444444;
298
+ white-space: pre;
299
+ margin-right: 4px;
300
+ flex-shrink: 0;
301
+ }
302
+
303
+ .t-icon {
304
+ width: 20px;
305
+ text-align: center;
306
+ display: inline-flex;
307
+ align-items: center;
308
+ justify-content: center;
309
+ margin-right: 8px;
310
+ font-size: 0.78rem;
311
+ flex-shrink: 0;
312
+ color: #888888;
313
+ }
314
+ .t-icon img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
315
+
316
+ .t-name {
317
+ color: #ffffff;
318
+ font-weight: 600;
319
+ white-space: nowrap;
320
+ overflow: hidden;
321
+ text-overflow: ellipsis;
322
+ min-width: 0;
323
+ }
324
+ .t-name a { color: #ffffff; transition: color 0.1s; }
325
+ .t-name a:hover { color: #cccccc; text-decoration: underline; }
326
+
327
+ .t-meta {
328
+ margin-left: auto;
329
+ display: flex;
330
+ align-items: center;
331
+ gap: 12px;
332
+ flex-shrink: 0;
333
+ padding-left: 12px;
334
+ }
335
+
336
+ .t-stat {
337
+ font-size: 0.65rem;
338
+ color: #555555;
339
+ display: flex;
340
+ align-items: center;
341
+ gap: 4px;
342
+ font-weight: 500;
343
+ white-space: nowrap;
344
+ }
345
+
346
+ .no-data {
347
+ padding: 40px 20px;
348
+ text-align: center;
349
+ color: #555555;
350
+ font-size: 0.82rem;
351
+ }
352
+
353
+ /* ── Footer ── */
354
+ .footer {
355
+ padding: 30px 20px;
356
+ text-align: center;
357
+ font-size: 0.68rem;
358
+ color: #333333;
359
+ margin-top: auto;
360
+ border-top: 1px solid #111111;
361
+ }
362
+ .footer a { color: #888888; font-weight: 600; }
363
+ .footer a:hover { color: #ffffff; }
364
+
365
+ /* ── Spinner ── */
366
+ .spinner {
367
+ display: inline-block;
368
+ width: 12px;
369
+ height: 12px;
370
+ border: 2px solid #333333;
371
+ border-top-color: #ffffff;
372
+ border-radius: 50%;
373
+ animation: spin 0.6s linear infinite;
374
+ margin-right: 8px;
375
+ vertical-align: middle;
376
+ }
377
+
378
+ @keyframes spin { to { transform: rotate(360deg); } }
379
+
380
+ .hidden { display: none !important; }
381
+
382
+ /* ── Responsive ── */
383
+ @media (max-width: 640px) {
384
+ .input-line { flex-direction: column; }
385
+ .exec-btn { width: 100%; justify-content: center; }
386
+ .profile-top { flex-direction: column; text-align: center; }
387
+ .profile-name { justify-content: center; }
388
+ .tree-header { flex-direction: column; align-items: stretch; }
389
+ .title-bar { padding: 10px 14px; }
390
+ .term-body { padding: 14px; }
391
+ .chart-container { height: 300px; padding: 10px; }
392
+ }
393
+ </style>
394
+ </head>
395
+ <body>
396
+ <div class="terminal-shell">
397
+ <!-- Title Bar -->
398
+ <div class="title-bar">
399
+ <div class="title-dot"></div>
400
+ <span class="title-text">[who-liked]</span>
401
+ </div>
402
+
403
+ <!-- Main Body -->
404
+ <div class="term-body">
405
+ <!-- Input -->
406
+ <div class="input-line">
407
+ <div class="prompt-group">
408
+ <span class="prompt-symbol">~$&nbsp;fetch&nbsp;</span>
409
+ <input type="text" id="repoInput" placeholder="paste repo path (e.g. prithivMLmods/Minutus or spaces/user/space)" autocomplete="off">
410
+ </div>
411
+ <button id="fetchBtn" class="exec-btn">
412
+ <i class="fas fa-terminal"></i> execute
413
+ </button>
414
+ </div>
415
+
416
+ <div id="statusMsg"></div>
417
+
418
+ <!-- Empty State -->
419
+ <div id="emptyState" class="empty-state">
420
+ <div style="margin-bottom:32px;">
421
+ <div class="empty-title">who-liked</div>
422
+ <div class="empty-desc">
423
+ view the timeline and users who liked any huggingface model, dataset, or space.
424
+ graph displays the profile activity dates and follower counts of the likers.
425
+ </div>
426
+ </div>
427
+ </div>
428
+
429
+ <!-- Results -->
430
+ <div id="resultsSection" class="hidden">
431
+ <!-- Repo Profile -->
432
+ <div id="repoCard" class="profile-block">
433
+ <div class="profile-top">
434
+ <div class="profile-info">
435
+ <div class="profile-name">
436
+ <a id="repoLink" href="#" target="_blank" rel="noopener">
437
+ <span id="repoTitle"></span>
438
+ </a>
439
+ </div>
440
+ <div class="profile-fullname" id="repoType"></div>
441
+ </div>
442
+ </div>
443
+ </div>
444
+
445
+ <!-- Graph -->
446
+ <div class="chart-container">
447
+ <canvas id="likesChart"></canvas>
448
+ </div>
449
+
450
+ <!-- Tree -->
451
+ <div class="tree-wrapper">
452
+ <div class="tree-header">
453
+ <span class="tree-title" id="treeTitle">likers list</span>
454
+ </div>
455
+ <div class="terminal-window">
456
+ <div class="line-col" id="lineNumbers"></div>
457
+ <div class="code-col" id="treeContent"></div>
458
+ </div>
459
+ </div>
460
+ </div>
461
+
462
+ <div class="footer">
463
+ built using huggingface api & chart.js
464
+ </div>
465
+ </div>
466
+ </div>
467
+
468
+ <script>
469
+ const HF_API = 'https://huggingface.co/api';
470
+ const HF_BASE = 'https://huggingface.co';
471
+
472
+ let state = {
473
+ repoPath: '',
474
+ type: 'models',
475
+ likers: [],
476
+ chart: null
477
+ };
478
+
479
+ const $ = id => document.getElementById(id);
480
+
481
+ const els = {
482
+ repoInput: $('repoInput'),
483
+ fetchBtn: $('fetchBtn'),
484
+ statusMsg: $('statusMsg'),
485
+ emptyState: $('emptyState'),
486
+ resultsSection: $('resultsSection'),
487
+ repoLink: $('repoLink'),
488
+ repoTitle: $('repoTitle'),
489
+ repoType: $('repoType'),
490
+ treeTitle: $('treeTitle'),
491
+ lineNumbers: $('lineNumbers'),
492
+ treeContent: $('treeContent')
493
+ };
494
+
495
+ function escapeHtml(s) {
496
+ const d = document.createElement('div');
497
+ d.textContent = s;
498
+ return d.innerHTML;
499
+ }
500
+
501
+ function showMsg(text, type) {
502
+ els.statusMsg.style.display = text ? 'block' : 'none';
503
+ els.statusMsg.innerHTML = text;
504
+ els.statusMsg.className = type || '';
505
+ }
506
+
507
+ function formatNum(n) {
508
+ if (n == null) return 'β€”';
509
+ if (n >= 1e6) return (n / 1e6).toFixed(1) + 'M';
510
+ if (n >= 1e3) return (n / 1e3).toFixed(1) + 'K';
511
+ return n.toLocaleString();
512
+ }
513
+
514
+ function relativeTime(d) {
515
+ if (!d) return 'N/A';
516
+ const diff = Date.now() - new Date(d).getTime();
517
+ const m = Math.floor(diff / 60000);
518
+ if (m < 1) return 'just now';
519
+ if (m < 60) return m + 'm ago';
520
+ const h = Math.floor(m / 60);
521
+ if (h < 24) return h + 'h ago';
522
+ const dy = Math.floor(h / 24);
523
+ if (dy < 7) return dy + 'd ago';
524
+ const w = Math.floor(dy / 7);
525
+ if (w < 5) return w + 'w ago';
526
+ const mo = Math.floor(dy / 30);
527
+ if (mo < 12) return mo + 'mo ago';
528
+ return Math.floor(dy / 365) + 'y ago';
529
+ }
530
+
531
+ // Parse path like "models/user/repo", "spaces/user/repo", "datasets/user/repo" or just "user/repo"
532
+ function parsePath(rawPath) {
533
+ let path = rawPath.trim().replace(/^\/+|\/+$/g, '');
534
+
535
+ // Strip full URL if pasted
536
+ path = path.replace(/^https?:\/\/huggingface\.co\//, '');
537
+
538
+ let type = 'models'; // default
539
+
540
+ if (path.startsWith('datasets/')) {
541
+ type = 'datasets';
542
+ path = path.substring(9);
543
+ } else if (path.startsWith('spaces/')) {
544
+ type = 'spaces';
545
+ path = path.substring(7);
546
+ } else if (path.startsWith('models/')) {
547
+ type = 'models';
548
+ path = path.substring(7);
549
+ }
550
+
551
+ return { type, path };
552
+ }
553
+
554
+ async function fetchUserOverview(username) {
555
+ try {
556
+ const resp = await fetch(`${HF_API}/users/${encodeURIComponent(username)}/overview`);
557
+ if (resp.ok) return await resp.json();
558
+ } catch (e) {}
559
+ return null;
560
+ }
561
+
562
+ async function fetchLikers() {
563
+ const rawInput = els.repoInput.value.trim();
564
+ if (!rawInput) return showMsg("error: please enter a repo path.", "error");
565
+
566
+ const { type, path } = parsePath(rawInput);
567
+ if (!path || path.split('/').length < 2) {
568
+ return showMsg("error: invalid path. use format: user/repo or type/user/repo", "error");
569
+ }
570
+
571
+ state.repoPath = path;
572
+ state.type = type;
573
+
574
+ els.emptyState.classList.add('hidden');
575
+ els.resultsSection.classList.add('hidden');
576
+ els.fetchBtn.disabled = true;
577
+ showMsg(`<span class="spinner"></span> fetching likers for ${escapeHtml(path)}...`, 'loading');
578
+
579
+ try {
580
+ const resp = await fetch(`${HF_API}/${type}/${encodeURIComponent(path)}/likers`);
581
+ if (!resp.ok) throw new Error(`HTTP ${resp.status} - Repo not found or private`);
582
+
583
+ const likers = await resp.json();
584
+ state.likers = Array.isArray(likers) ? likers : [];
585
+
586
+ if (state.likers.length === 0) {
587
+ showMsg(`no likers found for ${escapeHtml(path)}.`, 'error');
588
+ els.emptyState.classList.remove('hidden');
589
+ return;
590
+ }
591
+
592
+ showMsg(`<span class="spinner"></span> fetching profile details for ${state.likers.length} users...`, 'loading');
593
+
594
+ // Fetch user details in batches to avoid rate limits
595
+ const batchSize = 10;
596
+ for (let i = 0; i < state.likers.length; i += batchSize) {
597
+ const batch = state.likers.slice(i, i + batchSize);
598
+ const results = await Promise.allSettled(
599
+ batch.map(u => fetchUserOverview(u.user))
600
+ );
601
+ results.forEach((r, j) => {
602
+ if (r.status === 'fulfilled' && r.value) {
603
+ state.likers[i + j].details = r.value;
604
+ } else {
605
+ state.likers[i + j].details = null;
606
+ }
607
+ });
608
+ }
609
+
610
+ showMsg('', '');
611
+ renderRepoCard();
612
+ renderChart();
613
+ renderTree();
614
+ els.resultsSection.classList.remove('hidden');
615
+
616
+ } catch (err) {
617
+ console.error(err);
618
+ showMsg(`error: ${err.message}`, 'error');
619
+ els.emptyState.classList.remove('hidden');
620
+ } finally {
621
+ els.fetchBtn.disabled = false;
622
+ }
623
+ }
624
+
625
+ function renderRepoCard() {
626
+ const title = state.repoPath.split('/').pop();
627
+ const user = state.repoPath.split('/')[0];
628
+ els.repoTitle.textContent = `${state.repoPath}`;
629
+ els.repoType.textContent = `${state.type.toUpperCase()} β€’ by ${user}`;
630
+ els.repoLink.href = `${HF_BASE}/${state.type}/${state.repoPath}`;
631
+ els.treeTitle.textContent = `likers (${state.likers.length})`;
632
+ }
633
+
634
+ function renderChart() {
635
+ const ctx = document.getElementById('likesChart').getContext('2d');
636
+
637
+ if (state.chart) {
638
+ state.chart.destroy();
639
+ }
640
+
641
+ const chartData = state.likers.map(u => {
642
+ const details = u.details || {};
643
+ const dateStr = details.createdAt || details.lastModified || u.lastModified;
644
+ const timestamp = dateStr ? new Date(dateStr).getTime() : 0;
645
+ const followers = details.numFollowers || 0;
646
+
647
+ return {
648
+ x: timestamp,
649
+ y: followers,
650
+ username: u.user,
651
+ date: dateStr ? new Date(dateStr).toLocaleDateString() : 'Unknown',
652
+ fullname: details.fullname || u.fullname || u.user
653
+ };
654
+ }).filter(d => d.x > 0); // only graph users where we have a date
655
+
656
+ state.chart = new Chart(ctx, {
657
+ type: 'scatter',
658
+ data: {
659
+ datasets: [{
660
+ label: 'Likers',
661
+ data: chartData,
662
+ backgroundColor: '#ffffff',
663
+ borderColor: '#333333',
664
+ pointRadius: 5,
665
+ pointHoverRadius: 8,
666
+ pointHoverBackgroundColor: '#000000',
667
+ pointHoverBorderColor: '#ffffff'
668
+ }]
669
+ },
670
+ options: {
671
+ responsive: true,
672
+ maintainAspectRatio: false,
673
+ plugins: {
674
+ legend: { display: false },
675
+ tooltip: {
676
+ backgroundColor: '#111111',
677
+ borderColor: '#333333',
678
+ borderWidth: 1,
679
+ titleColor: '#ffffff',
680
+ bodyColor: '#aaaaaa',
681
+ callbacks: {
682
+ label: function(context) {
683
+ const d = context.raw;
684
+ return [
685
+ `User: ${d.username}`,
686
+ `Followers: ${d.y}`,
687
+ `Activity Date: ${d.date}`
688
+ ];
689
+ }
690
+ }
691
+ }
692
+ },
693
+ scales: {
694
+ x: {
695
+ type: 'linear',
696
+ title: { display: true, text: 'User Activity / Join Date', color: '#888888', font: { size: 12 } },
697
+ ticks: {
698
+ color: '#555555',
699
+ callback: function(value, index, ticks) {
700
+ if (value > 0) return new Date(value).toLocaleDateString();
701
+ return '';
702
+ }
703
+ },
704
+ grid: { color: '#1a1a1a' }
705
+ },
706
+ y: {
707
+ title: { display: true, text: 'Follower Count', color: '#888888', font: { size: 12 } },
708
+ ticks: { color: '#555555' },
709
+ grid: { color: '#1a1a1a' },
710
+ beginAtZero: true
711
+ }
712
+ }
713
+ }
714
+ });
715
+ }
716
+
717
+ function renderTree() {
718
+ els.lineNumbers.innerHTML = '';
719
+ els.treeContent.innerHTML = '';
720
+
721
+ const fragL = document.createDocumentFragment();
722
+ const fragT = document.createDocumentFragment();
723
+
724
+ const rL = document.createElement('div'); rL.textContent = '1'; fragL.appendChild(rL);
725
+ const rR = document.createElement('div');
726
+ rR.className = 'tree-line'; rR.style.fontWeight = '700';
727
+ rR.innerHTML = `<span class="t-name" style="color:#ffffff;">${escapeHtml(state.repoPath)} β€” ${state.likers.length} likers</span>`;
728
+ fragT.appendChild(rR);
729
+
730
+ state.likers.forEach((liker, idx) => {
731
+ const lN = document.createElement('div'); lN.textContent = idx + 2; fragL.appendChild(lN);
732
+
733
+ const row = document.createElement('div');
734
+ row.className = 'tree-line';
735
+ row.style.animation = `fadeIn 0.12s forwards ${Math.min(idx * 6, 600)}ms`;
736
+ row.style.opacity = '0';
737
+
738
+ const isLast = idx === state.likers.length - 1;
739
+ const conn = isLast ? '└── ' : 'β”œβ”€β”€ ';
740
+
741
+ const username = liker.user;
742
+ const url = `${HF_BASE}/${username}`;
743
+
744
+ const details = liker.details || {};
745
+ const followers = details.numFollowers || 0;
746
+ const dateStr = details.createdAt || details.lastModified || liker.lastModified;
747
+ const avatarUrl = details.avatarUrl || liker.avatarUrl;
748
+
749
+ let iconHtml = avatarUrl
750
+ ? `<img src="${avatarUrl.startsWith('http') ? avatarUrl : HF_BASE + avatarUrl}" alt="${escapeHtml(username)}">`
751
+ : `<i class="fas fa-user"></i>`;
752
+
753
+ let meta = `<span class="t-stat" title="Followers"><i class="fas fa-users"></i> ${formatNum(followers)}</span>`;
754
+ if (dateStr) {
755
+ meta += `<span class="t-stat" title="Active: ${new Date(dateStr).toLocaleDateString()}"><i class="far fa-clock"></i> ${relativeTime(dateStr)}</span>`;
756
+ }
757
+
758
+ row.innerHTML = `
759
+ <span class="t-prefix">${conn}</span>
760
+ <span class="t-icon">${iconHtml}</span>
761
+ <span class="t-name"><a href="${url}" target="_blank" rel="noopener" title="${escapeHtml(username)}">${escapeHtml(username)}</a></span>
762
+ <span class="t-meta">${meta}</span>`;
763
+ fragT.appendChild(row);
764
+ });
765
+
766
+ els.lineNumbers.appendChild(fragL);
767
+ els.treeContent.appendChild(fragT);
768
+ }
769
+
770
+ document.addEventListener('DOMContentLoaded', () => {
771
+ els.fetchBtn.addEventListener('click', fetchLikers);
772
+ els.repoInput.addEventListener('keypress', e => { if (e.key === 'Enter') fetchLikers(); });
773
+ });
774
+ </script>
775
+ </body>
776
+ </html>