-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin-event-log.html
More file actions
919 lines (847 loc) · 35.6 KB
/
Copy pathadmin-event-log.html
File metadata and controls
919 lines (847 loc) · 35.6 KB
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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
<!DOCTYPE html>
<html lang="en">
<head>
<!-- TikTok Pixel Code Start -->
<script>
!function (w, d, t) {
w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(
var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};n=document.createElement("script")
;n.type="text/javascript",n.async=!0,n.src=r+"?sdkid="+e+"&lib="+t;e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)};
ttq.load('DABS2BBC77U98E0UJH30');
ttq.page();
}(window, document, 'ttq');
</script>
<!-- TikTok Pixel Code End -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TFS Admin Event Log</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-SKL8XQ51ZH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-SKL8XQ51ZH');
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--void: #0a0a0f;
--deep: #12121a;
--surface: #1a1a26;
--border: #2a2a3a;
--gold: #ffd700;
--amber: #ffaa00;
--purple: #8b5cf6;
--cyan: #06b6d4;
--rose: #f472b6;
--green: #22c55e;
--red: #ef4444;
--blue: #3b82f6;
--orange: #f97316;
--text: #e4e4f0;
--text-dim: #6b7280;
--text-muted: #4b5563;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--void);
color: var(--text);
min-height: 100vh;
overflow-x: hidden;
}
/* ── Background ── */
.bg-canvas {
position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
#starCanvas { width: 100%; height: 100%; display: block; }
/* ── Layout ── */
.app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 0 20px 80px; }
/* ── Header ── */
header {
padding: 32px 0 24px;
display: flex; align-items: center; justify-content: space-between;
border-bottom: 1px solid var(--border);
margin-bottom: 32px;
}
.header-left h1 {
font-family: 'Cinzel', serif;
font-size: 1.6rem;
color: var(--gold);
letter-spacing: 2px;
}
.header-left p {
font-size: 0.8rem;
color: var(--text-dim);
margin-top: 4px;
letter-spacing: 1px;
}
.header-right { display: flex; gap: 10px; align-items: center; }
.btn {
padding: 9px 18px;
border-radius: 8px;
border: none;
font-family: 'Space Grotesk', sans-serif;
font-size: 0.82rem;
font-weight: 600;
cursor: pointer;
letter-spacing: 0.5px;
transition: all 0.2s;
}
.btn-gold { background: var(--gold); color: #000; }
.btn-gold:hover { background: var(--amber); }
.btn-ghost {
background: transparent;
border: 1px solid var(--border);
color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
/* ── Stats Bar ── */
.stats-bar {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 12px;
margin-bottom: 28px;
}
.stat-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 14px 16px;
}
.stat-label { font-size: 0.7rem; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
/* ── Controls ── */
.controls {
display: flex; gap: 10px; flex-wrap: wrap;
margin-bottom: 24px; align-items: center;
}
.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap input {
width: 100%;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 9px 14px 9px 36px;
color: var(--text);
font-family: 'Space Grotesk', sans-serif;
font-size: 0.85rem;
}
.search-wrap input:focus { outline: none; border-color: var(--cyan); }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 0.85rem; }
select {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 9px 14px;
color: var(--text);
font-family: 'Space Grotesk', sans-serif;
font-size: 0.82rem;
cursor: pointer;
}
select:focus { outline: none; border-color: var(--cyan); }
select option { background: var(--deep); }
/* ── Timeline ── */
.timeline { position: relative; }
.timeline::before {
content: '';
position: absolute;
left: 18px;
top: 0; bottom: 0;
width: 1px;
background: linear-gradient(to bottom, var(--gold), var(--purple), transparent);
}
.event-group-label {
font-size: 0.7rem;
color: var(--text-dim);
letter-spacing: 2px;
text-transform: uppercase;
margin: 24px 0 10px 50px;
}
.event-group-label:first-child { margin-top: 0; }
.event-card {
display: flex;
gap: 16px;
margin-bottom: 12px;
position: relative;
}
.event-dot {
width: 36px;
height: 36px;
border-radius: 50%;
border: 2px solid;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.9rem;
flex-shrink: 0;
background: var(--void);
position: relative;
z-index: 1;
}
.event-body {
flex: 1;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 14px 16px;
transition: border-color 0.2s;
}
.event-body:hover { border-color: rgba(255,215,0,0.3); }
.event-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.event-title {
font-weight: 600;
font-size: 0.95rem;
color: var(--text);
flex: 1;
}
.event-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.2s; }
.event-card:hover .event-actions { opacity: 1; }
.event-meta {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: center;
margin-top: 6px;
}
.tag {
font-size: 0.68rem;
padding: 2px 9px;
border-radius: 20px;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
}
.meta-time { font-size: 0.75rem; color: var(--text-dim); }
.meta-author { font-size: 0.75rem; color: var(--text-dim); }
.meta-author span { color: var(--cyan); }
.event-desc {
margin-top: 8px;
font-size: 0.83rem;
color: #b0b0c0;
line-height: 1.6;
white-space: pre-wrap;
}
.event-pinned {
border-color: rgba(255,215,0,0.4) !important;
}
.pin-badge {
font-size: 0.65rem;
color: var(--gold);
letter-spacing: 1px;
}
/* Category colors */
.cat-milestone { --cat: var(--gold); }
.cat-decision { --cat: var(--purple); }
.cat-launch { --cat: var(--cyan); }
.cat-meeting { --cat: var(--blue); }
.cat-issue { --cat: var(--red); }
.cat-partnership{ --cat: var(--green); }
.cat-note { --cat: var(--text-dim); }
.cat-release { --cat: var(--orange); }
.event-dot { border-color: var(--cat, var(--text-dim)); color: var(--cat, var(--text-dim)); }
.tag { background: color-mix(in srgb, var(--cat, #888) 20%, transparent); color: var(--cat, #888); }
/* ── Empty State ── */
.empty-state {
text-align: center;
padding: 60px 20px;
color: var(--text-dim);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; margin-top: 6px; }
/* ── Modal Overlay ── */
.overlay {
position: fixed; inset: 0;
background: rgba(0,0,0,0.75);
backdrop-filter: blur(4px);
z-index: 100;
display: flex; align-items: center; justify-content: center;
padding: 20px;
}
.overlay.hidden { display: none; }
.modal {
background: var(--deep);
border: 1px solid var(--border);
border-radius: 16px;
padding: 30px;
width: 100%;
max-width: 560px;
max-height: 90vh;
overflow-y: auto;
}
.modal h2 {
font-family: 'Cinzel', serif;
font-size: 1.1rem;
color: var(--gold);
margin-bottom: 22px;
letter-spacing: 1px;
}
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.78rem; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.5px; text-transform: uppercase; }
input[type="text"], input[type="datetime-local"], textarea {
width: 100%;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 14px;
color: var(--text);
font-family: 'Space Grotesk', sans-serif;
font-size: 0.88rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--cyan); }
textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
/* ── PIN Gate ── */
.pin-gate {
min-height: 100vh;
display: flex; align-items: center; justify-content: center;
flex-direction: column;
gap: 20px;
position: relative; z-index: 1;
}
.pin-gate h1 {
font-family: 'Cinzel', serif;
font-size: 1.4rem;
color: var(--gold);
letter-spacing: 3px;
}
.pin-gate p { color: var(--text-dim); font-size: 0.85rem; }
.pin-input-wrap { display: flex; gap: 10px; }
.pin-input-wrap input {
width: 220px;
text-align: center;
font-size: 1.5rem;
letter-spacing: 8px;
padding: 12px;
}
.pin-error { color: var(--red); font-size: 0.8rem; min-height: 18px; }
/* ── Export/Import row ── */
.toolbar-row {
display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
/* ── Notification ── */
.notif {
position: fixed; bottom: 24px; right: 24px;
background: var(--green);
color: #000;
padding: 10px 18px;
border-radius: 8px;
font-weight: 600;
font-size: 0.82rem;
z-index: 200;
transform: translateY(80px);
transition: transform 0.3s;
}
.notif.show { transform: translateY(0); }
.notif.err { background: var(--red); color: #fff; }
/* ── Responsive ── */
@media (max-width: 600px) {
header { flex-direction: column; align-items: flex-start; gap: 14px; }
.form-row { grid-template-columns: 1fr; }
.timeline::before { left: 14px; }
.event-dot { width: 28px; height: 28px; font-size: 0.75rem; }
}
</style>
<script>!function(w,d,s,u,n,a,b){if(w[n])return;a=w[n]={q:[],t:+new Date,s:[],o:u,track:function(){a.q.push([+new Date].concat([].slice.call(arguments)))},setScope:function(){a.s=[].slice.call(arguments).filter(function(x){return typeof x==="string"});a.q.push([+new Date,"setScope"].concat(a.s))},scope:function(){var c=[].slice.call(arguments);return{track:function(){a.q.push([+new Date].concat([].slice.call(arguments)).concat([{__scope:c}]))}}}};b=d.createElement(s);b.async=1;b.src=u+"/s.js";d.getElementsByTagName(s)[0].parentNode.insertBefore(b,d.getElementsByTagName(s)[0])}(window,document,"script","https://t.whop.tw","whop");whop.setScope("biz_0xcayhWXVnKO9y");whop.track("page");</script>
</head>
<body>
<!-- Starfield -->
<div class="bg-canvas"><canvas id="starCanvas"></canvas></div>
<!-- PIN Gate -->
<div id="pinGate" class="pin-gate">
<h1>TFS ADMIN LOG</h1>
<p id="pinGateMsg">Enter admin PIN to access the event log</p>
<div class="pin-input-wrap" id="pinLoginWrap">
<input type="password" id="pinInput" maxlength="6" placeholder="••••••" autocomplete="off">
<button class="btn btn-gold" onclick="checkPin()">Enter</button>
</div>
<div class="pin-input-wrap" id="pinSetupWrap" style="display:none;flex-direction:column;gap:8px;">
<input type="password" id="pinSetup1" maxlength="6" placeholder="Create PIN (4–6 digits)" autocomplete="off">
<input type="password" id="pinSetup2" maxlength="6" placeholder="Confirm PIN" autocomplete="off">
<button class="btn btn-gold" onclick="createPin()">Set PIN</button>
</div>
<div class="pin-error" id="pinError"></div>
</div>
<!-- Main App -->
<div id="mainApp" style="display:none;">
<div class="app">
<header>
<div class="header-left">
<h1>TFS EVENT LOG</h1>
<p>THE FIRST SPARK — ADMIN TIMELINE</p>
</div>
<div class="header-right">
<button class="btn btn-ghost" onclick="openSettings()">⚙ Settings</button>
<button class="btn btn-gold" onclick="openAddModal()">+ Log Event</button>
</div>
</header>
<!-- Stats -->
<div class="stats-bar" id="statsBar"></div>
<!-- Toolbar -->
<div class="toolbar-row">
<button class="btn btn-ghost btn-sm" onclick="exportCSV()">↓ Export CSV</button>
<button class="btn btn-ghost btn-sm" onclick="exportJSON()">↓ Export JSON</button>
<label class="btn btn-ghost btn-sm" style="cursor:pointer;">
↑ Import JSON <input type="file" accept=".json" onchange="importJSON(event)" style="display:none;">
</label>
</div>
<!-- Controls -->
<div class="controls">
<div class="search-wrap">
<span class="icon">⌕</span>
<input type="text" id="searchInput" placeholder="Search events..." oninput="render()">
</div>
<select id="filterCat" onchange="render()">
<option value="">All Categories</option>
<option value="milestone">Milestone</option>
<option value="decision">Decision</option>
<option value="launch">Launch</option>
<option value="meeting">Meeting</option>
<option value="issue">Issue</option>
<option value="partnership">Partnership</option>
<option value="release">Release</option>
<option value="note">Note</option>
</select>
<select id="filterAuthor" onchange="render()">
<option value="">All Admins</option>
</select>
<select id="sortOrder" onchange="render()">
<option value="newest">Newest First</option>
<option value="oldest">Oldest First</option>
</select>
</div>
<!-- Timeline -->
<div class="timeline" id="timeline"></div>
</div>
</div>
<!-- Add/Edit Modal -->
<div class="overlay hidden" id="eventModal">
<div class="modal">
<h2 id="modalTitle">LOG NEW EVENT</h2>
<input type="hidden" id="editId">
<div class="form-row">
<div class="form-group">
<label>Event Title *</label>
<input type="text" id="fTitle" placeholder="e.g. Signed first investor">
</div>
<div class="form-group">
<label>Category *</label>
<select id="fCategory" style="width:100%;padding:10px 14px;">
<option value="milestone">🏆 Milestone</option>
<option value="decision">⚡ Decision</option>
<option value="launch">🚀 Launch</option>
<option value="meeting">📅 Meeting</option>
<option value="issue">🔥 Issue</option>
<option value="partnership">🤝 Partnership</option>
<option value="release">📦 Release</option>
<option value="note">📝 Note</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Date & Time *</label>
<input type="datetime-local" id="fDate">
</div>
<div class="form-group">
<label>Logged By *</label>
<input type="text" id="fAuthor" placeholder="Your name">
</div>
</div>
<div class="form-group">
<label>Description</label>
<textarea id="fDesc" placeholder="What happened? Include context, outcomes, links..."></textarea>
</div>
<div class="form-group">
<label>
<input type="checkbox" id="fPinned" style="width:auto;margin-right:6px;">
Pin this event (highlight as important)
</label>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal()">Cancel</button>
<button class="btn btn-gold" onclick="saveEvent()">Save Event</button>
</div>
</div>
</div>
<!-- Settings Modal -->
<div class="overlay hidden" id="settingsModal">
<div class="modal">
<h2>SETTINGS</h2>
<div class="form-group">
<label>Change Admin PIN (4–6 digits)</label>
<input type="password" id="newPin" maxlength="6" placeholder="New PIN">
</div>
<div class="form-group">
<label>Confirm New PIN</label>
<input type="password" id="confirmPin" maxlength="6" placeholder="Confirm PIN">
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeSettings()">Cancel</button>
<button class="btn btn-gold" onclick="savePin()">Update PIN</button>
</div>
<hr style="border-color:var(--border);margin:20px 0;">
<p style="font-size:0.8rem;color:var(--text-dim);margin-bottom:12px;">Danger Zone</p>
<button class="btn btn-danger btn-sm" onclick="clearAllData()">Delete ALL Events</button>
</div>
</div>
<!-- Confirm Delete Modal -->
<div class="overlay hidden" id="confirmModal">
<div class="modal" style="max-width:380px;text-align:center;">
<h2>CONFIRM DELETE</h2>
<p style="color:var(--text-dim);font-size:0.88rem;margin:12px 0 24px;">This event will be permanently removed.</p>
<div style="display:flex;gap:10px;justify-content:center;">
<button class="btn btn-ghost" onclick="closeConfirm()">Cancel</button>
<button class="btn btn-danger" onclick="confirmDelete()">Delete</button>
</div>
</div>
</div>
<!-- Notification -->
<div class="notif" id="notif"></div>
<script>
// ── Storage Keys ──
const EVENTS_KEY = 'tfs_admin_events';
const PIN_KEY = 'tfs_admin_pin';
// ── State ──
let events = [];
let deleteTargetId = null;
// ── Init ──
function init() {
events = JSON.parse(localStorage.getItem(EVENTS_KEY) || '[]');
setupStars();
document.getElementById('fDate').value = localDateTimeValue();
if (!localStorage.getItem(PIN_KEY)) {
document.getElementById('pinGateMsg').textContent = 'Create an admin PIN to secure this page';
document.getElementById('pinLoginWrap').style.display = 'none';
document.getElementById('pinSetupWrap').style.display = 'flex';
}
}
function localDateTimeValue(d = new Date()) {
const pad = n => String(n).padStart(2,'0');
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
}
// ── PIN ──
function getPin() { return localStorage.getItem(PIN_KEY); }
function createPin() {
const p1 = document.getElementById('pinSetup1').value;
const p2 = document.getElementById('pinSetup2').value;
if (!p1 || p1.length < 4) { document.getElementById('pinError').textContent = 'PIN must be 4–6 digits.'; return; }
if (p1 !== p2) { document.getElementById('pinError').textContent = 'PINs do not match.'; return; }
localStorage.setItem(PIN_KEY, p1);
document.getElementById('pinGate').style.display = 'none';
document.getElementById('mainApp').style.display = 'block';
render();
}
function checkPin() {
const entered = document.getElementById('pinInput').value;
if (entered === getPin()) {
document.getElementById('pinGate').style.display = 'none';
document.getElementById('mainApp').style.display = 'block';
render();
} else {
document.getElementById('pinError').textContent = 'Incorrect PIN. Try again.';
document.getElementById('pinInput').value = '';
}
}
document.getElementById('pinInput').addEventListener('keydown', e => {
if (e.key === 'Enter') checkPin();
});
// ── Render ──
const CAT_META = {
milestone: { icon: '🏆', label: 'Milestone' },
decision: { icon: '⚡', label: 'Decision' },
launch: { icon: '🚀', label: 'Launch' },
meeting: { icon: '📅', label: 'Meeting' },
issue: { icon: '🔥', label: 'Issue' },
partnership: { icon: '🤝', label: 'Partnership' },
release: { icon: '📦', label: 'Release' },
note: { icon: '📝', label: 'Note' },
};
function render() {
const q = document.getElementById('searchInput').value.toLowerCase();
const cat = document.getElementById('filterCat').value;
const author = document.getElementById('filterAuthor').value;
const sort = document.getElementById('sortOrder').value;
// Update author dropdown
const authors = [...new Set(events.map(e => e.author).filter(Boolean))].sort();
const authorSel = document.getElementById('filterAuthor');
const savedAuthor = authorSel.value;
authorSel.innerHTML = '<option value="">All Admins</option>' +
authors.map(a => `<option value="${a}" ${a===savedAuthor?'selected':''}>${a}</option>`).join('');
// Filter
let filtered = events.filter(ev => {
const matchQ = !q || ev.title.toLowerCase().includes(q) || (ev.desc||'').toLowerCase().includes(q);
const matchCat = !cat || ev.category === cat;
const matchAuthor = !author || ev.author === author;
return matchQ && matchCat && matchAuthor;
});
// Sort
filtered.sort((a,b) => {
const d = new Date(a.date) - new Date(b.date);
return sort === 'newest' ? -d : d;
});
// Stats
renderStats();
// Timeline
const tl = document.getElementById('timeline');
if (!filtered.length) {
tl.innerHTML = `<div class="empty-state"><div class="icon">📋</div><h3>No events found</h3><p>Log your first event using the button above.</p></div>`;
return;
}
// Group by month
const groups = {};
filtered.forEach(ev => {
const d = new Date(ev.date);
const key = d.toLocaleDateString('en-US', { month: 'long', year: 'numeric' });
if (!groups[key]) groups[key] = [];
groups[key].push(ev);
});
tl.innerHTML = Object.entries(groups).map(([month, evs]) => `
<div class="event-group-label">${month}</div>
${evs.map(ev => renderCard(ev)).join('')}
`).join('');
}
function renderCard(ev) {
const meta = CAT_META[ev.category] || { icon: '•', label: ev.category };
const d = new Date(ev.date);
const time = d.toLocaleString('en-US', { month:'short', day:'numeric', year:'numeric', hour:'numeric', minute:'2-digit' });
return `
<div class="event-card cat-${ev.category}">
<div class="event-dot">${meta.icon}</div>
<div class="event-body ${ev.pinned ? 'event-pinned' : ''}">
<div class="event-header">
<span class="event-title">${escHtml(ev.title)}${ev.pinned ? ' <span class="pin-badge">◈ PINNED</span>' : ''}</span>
<div class="event-actions">
<button class="btn btn-ghost btn-sm" onclick="editEvent('${ev.id}')">Edit</button>
<button class="btn btn-danger btn-sm" onclick="askDelete('${ev.id}')">✕</button>
</div>
</div>
<div class="event-meta">
<span class="tag">${meta.label}</span>
<span class="meta-time">${time}</span>
<span class="meta-author">by <span>${escHtml(ev.author)}</span></span>
</div>
${ev.desc ? `<div class="event-desc">${escHtml(ev.desc)}</div>` : ''}
</div>
</div>`;
}
function renderStats() {
const total = events.length;
const pinned = events.filter(e => e.pinned).length;
const catCounts = {};
events.forEach(e => { catCounts[e.category] = (catCounts[e.category]||0)+1; });
const topCat = Object.entries(catCounts).sort((a,b)=>b[1]-a[1])[0];
// Days since first event
let span = '—';
if (events.length > 1) {
const dates = events.map(e => new Date(e.date)).sort((a,b)=>a-b);
const days = Math.round((dates[dates.length-1]-dates[0])/(1000*60*60*24));
span = `${days}d`;
}
document.getElementById('statsBar').innerHTML = `
<div class="stat-card"><div class="stat-label">Total Events</div><div class="stat-value" style="color:var(--gold)">${total}</div></div>
<div class="stat-card"><div class="stat-label">Pinned</div><div class="stat-value" style="color:var(--cyan)">${pinned}</div></div>
<div class="stat-card"><div class="stat-label">Top Category</div><div class="stat-value" style="font-size:1.1rem;color:var(--purple)">${topCat ? CAT_META[topCat[0]].icon+' '+topCat[0] : '—'}</div></div>
<div class="stat-card"><div class="stat-label">Timeline Span</div><div class="stat-value" style="color:var(--rose)">${span}</div></div>
`;
}
// ── Modal ──
function openAddModal(prefill = null) {
document.getElementById('modalTitle').textContent = 'LOG NEW EVENT';
document.getElementById('editId').value = '';
document.getElementById('fTitle').value = '';
document.getElementById('fDate').value = localDateTimeValue();
document.getElementById('fCategory').value = 'milestone';
document.getElementById('fDesc').value = '';
document.getElementById('fPinned').checked = false;
// Restore last author
const lastAuthor = localStorage.getItem('tfs_last_author') || '';
document.getElementById('fAuthor').value = lastAuthor;
if (prefill) Object.assign({}, prefill); // future use
document.getElementById('eventModal').classList.remove('hidden');
setTimeout(() => document.getElementById('fTitle').focus(), 50);
}
function editEvent(id) {
const ev = events.find(e => e.id === id);
if (!ev) return;
document.getElementById('modalTitle').textContent = 'EDIT EVENT';
document.getElementById('editId').value = ev.id;
document.getElementById('fTitle').value = ev.title;
document.getElementById('fDate').value = ev.date;
document.getElementById('fCategory').value = ev.category;
document.getElementById('fAuthor').value = ev.author;
document.getElementById('fDesc').value = ev.desc || '';
document.getElementById('fPinned').checked = !!ev.pinned;
document.getElementById('eventModal').classList.remove('hidden');
}
function closeModal() { document.getElementById('eventModal').classList.add('hidden'); }
function saveEvent() {
const title = document.getElementById('fTitle').value.trim();
const date = document.getElementById('fDate').value;
const category = document.getElementById('fCategory').value;
const author = document.getElementById('fAuthor').value.trim();
const desc = document.getElementById('fDesc').value.trim();
const pinned = document.getElementById('fPinned').checked;
const editId = document.getElementById('editId').value;
if (!title) { notify('Event title is required.', true); return; }
if (!date) { notify('Date & time is required.', true); return; }
if (!author){ notify('Please enter who is logging this.', true); return; }
localStorage.setItem('tfs_last_author', author);
if (editId) {
const idx = events.findIndex(e => e.id === editId);
if (idx !== -1) events[idx] = { ...events[idx], title, date, category, author, desc, pinned };
} else {
events.push({ id: uid(), title, date, category, author, desc, pinned, created: new Date().toISOString() });
}
save();
closeModal();
render();
notify(editId ? 'Event updated.' : 'Event logged.');
}
// ── Delete ──
function askDelete(id) {
deleteTargetId = id;
document.getElementById('confirmModal').classList.remove('hidden');
}
function closeConfirm() { document.getElementById('confirmModal').classList.add('hidden'); deleteTargetId = null; }
function confirmDelete() {
if (!deleteTargetId) return;
events = events.filter(e => e.id !== deleteTargetId);
save(); render();
closeConfirm();
notify('Event deleted.');
}
// ── Settings ──
function openSettings() { document.getElementById('settingsModal').classList.remove('hidden'); }
function closeSettings() { document.getElementById('settingsModal').classList.add('hidden'); }
function savePin() {
const np = document.getElementById('newPin').value;
const cp = document.getElementById('confirmPin').value;
if (!np || np.length < 4) { notify('PIN must be 4–6 digits.', true); return; }
if (np !== cp) { notify('PINs do not match.', true); return; }
localStorage.setItem(PIN_KEY, np);
closeSettings();
notify('PIN updated.');
}
function clearAllData() {
if (!confirm('Delete ALL events permanently? This cannot be undone.')) return;
events = [];
save(); render();
closeSettings();
notify('All events cleared.');
}
// ── Export / Import ──
function exportCSV() {
if (!events.length) { notify('No events to export.', true); return; }
const cols = ['title','category','date','author','pinned','desc'];
const rows = [cols.join(','), ...events.map(e =>
cols.map(c => `"${String(e[c]||'').replace(/"/g,'""')}"`).join(',')
)];
downloadFile('tfs-events.csv', rows.join('\n'), 'text/csv');
}
function exportJSON() {
if (!events.length) { notify('No events to export.', true); return; }
downloadFile('tfs-events.json', JSON.stringify(events, null, 2), 'application/json');
}
function importJSON(e) {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = ev => {
try {
const imported = JSON.parse(ev.target.result);
if (!Array.isArray(imported)) throw new Error('Invalid format');
// Merge: skip duplicates by id
const existing = new Set(events.map(e=>e.id));
let added = 0;
imported.forEach(ev => {
if (!existing.has(ev.id)) { events.push(ev); added++; }
});
save(); render();
notify(`Imported ${added} event(s).`);
} catch {
notify('Invalid JSON file.', true);
}
e.target.value = '';
};
reader.readAsText(file);
}
function downloadFile(name, content, type) {
const a = document.createElement('a');
a.href = URL.createObjectURL(new Blob([content], { type }));
a.download = name; a.click();
}
// ── Utilities ──
function save() { localStorage.setItem(EVENTS_KEY, JSON.stringify(events)); }
function uid() { return Date.now().toString(36) + Math.random().toString(36).slice(2,7); }
function escHtml(s) {
return String(s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
}
// ── Notification ──
function notify(msg, err = false) {
const n = document.getElementById('notif');
n.textContent = msg;
n.className = 'notif' + (err ? ' err' : '');
requestAnimationFrame(() => n.classList.add('show'));
setTimeout(() => n.classList.remove('show'), 2500);
}
// ── Close modals on overlay click ──
['eventModal','settingsModal','confirmModal'].forEach(id => {
document.getElementById(id).addEventListener('click', e => {
if (e.target === e.currentTarget) {
e.currentTarget.classList.add('hidden');
}
});
});
// ── Keyboard shortcuts ──
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
['eventModal','settingsModal','confirmModal'].forEach(id =>
document.getElementById(id).classList.add('hidden'));
}
if ((e.ctrlKey || e.metaKey) && e.key === 'n' && document.getElementById('mainApp').style.display !== 'none') {
e.preventDefault();
openAddModal();
}
});
// ── Starfield ──
function setupStars() {
const canvas = document.getElementById('starCanvas');
const ctx = canvas.getContext('2d');
let W, H, stars = [];
function resize() {
W = canvas.width = window.innerWidth;
H = canvas.height = window.innerHeight;
}
function makeStars() {
stars = Array.from({length:120}, () => ({
x: Math.random()*W, y: Math.random()*H,
r: Math.random()*1.2+0.2,
a: Math.random(),
s: (Math.random()-0.5)*0.002
}));
}
function draw() {
ctx.clearRect(0,0,W,H);
stars.forEach(s => {
s.a = Math.max(0.05, Math.min(1, s.a+s.s));
if (s.a <= 0.05 || s.a >= 1) s.s *= -1;
ctx.beginPath();
ctx.arc(s.x, s.y, s.r, 0, Math.PI*2);
ctx.fillStyle = `rgba(255,255,255,${s.a})`;
ctx.fill();
});
requestAnimationFrame(draw);
}
resize(); makeStars(); draw();
window.addEventListener('resize', () => { resize(); makeStars(); });
}
// ── Boot ──
init();
</script>
</body>
</html>