-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-engine.html
More file actions
1486 lines (1374 loc) · 59.5 KB
/
Copy pathcommit-engine.html
File metadata and controls
1486 lines (1374 loc) · 59.5 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
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Commit Engine</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700;800&display=swap');
:root {
--bg: #0a0a0a;
--panel: #121212;
--panel2: #181818;
--border: #2a2a2a;
--amber: #ffb000;
--amber-dim: #a06800;
--amber-bright: #ffd479;
--text: #d7d0c0;
--text-dim: #6b6558;
--green: #4caf50;
--red: #e05252;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: 'JetBrains Mono', monospace;
min-height: 100vh;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--amber-dim); }
::-webkit-scrollbar-track { background: var(--panel); }
.scanline {
pointer-events: none;
position: fixed; inset: 0;
background: repeating-linear-gradient(0deg, rgba(255,176,0,0.015) 0px, rgba(255,176,0,0.015) 1px, transparent 1px, transparent 3px);
z-index: 999;
}
header {
padding: 14px 24px;
border-bottom: 1px solid var(--border);
display: flex; justify-content: space-between; align-items: center;
background: var(--panel);
}
header h1 {
font-size: 18px; margin: 0; color: var(--amber); letter-spacing: 2px;
text-shadow: 0 0 8px rgba(255,176,0,0.4);
}
header h1::before { content: "> "; color: var(--amber-dim); }
.stats-bar { display: flex; gap: 24px; font-size: 13px; }
.stats-bar span b { color: var(--amber-bright); }
.layout {
display: grid;
grid-template-columns: 1.3fr 1fr;
gap: 16px;
padding: 16px;
max-width: 1200px;
margin: 0 auto;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 6px;
padding: 16px;
}
.panel h2 {
font-size: 13px; color: var(--amber-dim); text-transform: uppercase;
letter-spacing: 1.5px; margin: 0 0 12px 0; border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.commit-zone { text-align: center; padding: 30px 0; }
.commit-count { font-size: 46px; font-weight: 800; color: var(--amber); text-shadow: 0 0 14px rgba(255,176,0,0.35); }
.commit-sub { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.commit-btn {
margin-top: 20px;
background: linear-gradient(180deg, var(--amber) 0%, var(--amber-dim) 100%);
color: #0a0a0a; border: none; border-radius: 6px;
font-family: inherit; font-weight: 800; font-size: 15px;
padding: 16px 36px; cursor: pointer; letter-spacing: 1px;
box-shadow: 0 0 20px rgba(255,176,0,0.25);
transition: transform 0.08s ease;
}
.commit-btn:active { transform: scale(0.96); }
.float-commit {
position: absolute; color: var(--amber); font-size: 13px; font-weight: 700;
pointer-events: none; animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp { to { transform: translateY(-50px); opacity: 0; } }
.hire-row {
display: flex; justify-content: space-between; align-items: center;
padding: 10px 12px; margin-bottom: 8px;
background: var(--panel2); border: 1px solid var(--border); border-radius: 5px;
}
.hire-info { font-size: 12px; }
.hire-info .name { color: var(--amber-bright); font-weight: 700; }
.hire-info .desc { color: var(--text-dim); font-size: 11px; }
.hire-btn {
background: transparent; border: 1px solid var(--amber-dim); color: var(--amber);
border-radius: 4px; padding: 8px 12px; font-family: inherit; font-size: 11px;
cursor: pointer; white-space: nowrap;
}
.hire-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.hire-btn:not(:disabled):hover { background: var(--amber); color: #0a0a0a; }
.prestige-box {
text-align: center; padding: 10px; border: 1px dashed var(--amber-dim); border-radius: 6px; margin-top: 12px;
}
.prestige-btn {
background: transparent; border: 1px solid var(--amber); color: var(--amber-bright);
padding: 10px 20px; border-radius: 5px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 12px;
}
.prestige-btn:hover { background: var(--amber); color: #0a0a0a; }
.add-friend-row {
display: flex; gap: 8px; margin-bottom: 12px;
}
.add-friend-row input {
flex: 1; background: var(--panel2); border: 1px solid var(--border); border-radius: 4px;
color: var(--text); font-family: inherit; font-size: 12px; padding: 8px 10px;
}
.add-friend-row input:focus { outline: none; border-color: var(--amber-dim); }
.leader-empty {
font-size: 11px; color: var(--text-dim); line-height: 1.6; padding: 12px 4px; text-align: center;
}
.leader-row {
display: flex; justify-content: space-between; align-items: center;
padding: 9px 10px; margin-bottom: 6px; border-radius: 5px; cursor: pointer;
background: var(--panel2); border: 1px solid var(--border);
transition: border-color 0.15s;
}
.leader-row:hover { border-color: var(--amber-dim); }
.leader-left { display: flex; align-items: center; gap: 10px; }
.avatar {
width: 28px; height: 28px; border-radius: 50%; background: var(--amber-dim);
color: #0a0a0a; display: flex; align-items: center; justify-content: center;
font-weight: 800; font-size: 12px; flex-shrink: 0;
}
.leader-name { font-size: 12px; color: var(--text); }
.leader-name .rank { color: var(--text-dim); margin-right: 6px; }
.friend-badge {
font-size: 9px; background: var(--amber-dim); color: #0a0a0a; padding: 1px 6px;
border-radius: 8px; margin-left: 6px; font-weight: 700;
}
.leader-score { font-size: 12px; color: var(--amber); font-weight: 700; }
.modal-backdrop {
position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex;
align-items: center; justify-content: center; z-index: 1000;
}
.modal {
background: var(--panel); border: 1px solid var(--amber-dim); border-radius: 8px;
width: 320px; padding: 20px; box-shadow: 0 0 30px rgba(255,176,0,0.15);
}
.modal-close {
float: right; background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer;
}
.modal-avatar {
width: 64px; height: 64px; border-radius: 50%; background: var(--amber-dim); color: #0a0a0a;
display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 24px;
margin: 0 auto 12px;
}
.modal-name { text-align: center; font-size: 16px; color: var(--amber-bright); font-weight: 700; }
.modal-title { text-align: center; font-size: 11px; color: var(--text-dim); margin-bottom: 12px; }
.modal-bio { font-size: 11px; color: var(--text); text-align: center; margin-bottom: 14px; line-height: 1.5; }
.modal-stats { display: flex; justify-content: space-around; margin-bottom: 16px; font-size: 11px; }
.modal-stats div { text-align: center; }
.modal-stats b { display: block; color: var(--amber); font-size: 14px; }
.friend-btn {
width: 100%; padding: 10px; border-radius: 5px; border: 1px solid var(--amber);
background: transparent; color: var(--amber-bright); font-family: inherit; font-weight: 700;
font-size: 12px; cursor: pointer;
}
.friend-btn.friended { background: var(--amber-dim); color: #0a0a0a; border-color: var(--amber-dim); }
.friend-btn:hover { opacity: 0.85; }
.score-edit {
display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px;
}
.score-edit input {
width: 110px; text-align: center; background: var(--panel2); border: 1px solid var(--border);
border-radius: 4px; color: var(--amber-bright); font-family: inherit; font-size: 13px; padding: 6px;
}
.score-edit input:focus { outline: none; border-color: var(--amber-dim); }
.score-edit-label { font-size: 10px; color: var(--text-dim); text-align: center; margin-bottom: 6px; }
.remove-friend-btn {
width: 100%; margin-top: 8px; padding: 8px; border-radius: 5px; border: 1px solid var(--border);
background: transparent; color: var(--red); font-family: inherit; font-size: 11px; cursor: pointer;
}
.remove-friend-btn:hover { border-color: var(--red); }
.trial-popup {
position: fixed; bottom: 20px; right: 20px; width: 260px;
background: var(--panel); border: 1px solid var(--amber); border-radius: 8px;
padding: 16px; box-shadow: 0 0 24px rgba(255,176,0,0.2); z-index: 900;
}
.trial-popup h3 { margin: 0 0 8px; color: var(--amber-bright); font-size: 13px; }
.trial-popup p { font-size: 11px; color: var(--text-dim); margin: 0 0 12px; }
.trial-actions { display: flex; gap: 8px; }
.trial-actions button {
flex: 1; padding: 8px; border-radius: 4px; font-family: inherit; font-size: 11px; cursor: pointer;
}
.trial-yes { background: var(--amber); border: none; color: #0a0a0a; font-weight: 700; }
.trial-no { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.footer-note { text-align: center; color: var(--text-dim); font-size: 10px; padding: 20px; }
/* ---------- Auth screen ---------- */
.auth-screen {
position: fixed; inset: 0; background: var(--bg); z-index: 2000;
display: flex; align-items: center; justify-content: center;
}
.auth-box {
width: 300px; background: var(--panel); border: 1px solid var(--amber-dim);
border-radius: 8px; padding: 24px; box-shadow: 0 0 30px rgba(255,176,0,0.1);
}
.auth-box h1 { color: var(--amber); font-size: 16px; margin: 0 0 4px; text-align: center; }
.auth-box h1::before { content: "> "; color: var(--amber-dim); }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 11px; margin-bottom: 18px; }
.auth-box input {
width: 100%; background: var(--panel2); border: 1px solid var(--border); border-radius: 4px;
color: var(--text); font-family: inherit; font-size: 13px; padding: 10px; margin-bottom: 10px;
}
.auth-box input:focus { outline: none; border-color: var(--amber-dim); }
.auth-submit {
width: 100%; padding: 11px; border-radius: 5px; border: none;
background: linear-gradient(180deg, var(--amber) 0%, var(--amber-dim) 100%);
color: #0a0a0a; font-family: inherit; font-weight: 800; font-size: 13px; cursor: pointer;
}
.auth-toggle { text-align: center; margin-top: 12px; font-size: 11px; color: var(--text-dim); }
.auth-toggle a { color: var(--amber); cursor: pointer; text-decoration: underline; }
.auth-error { color: var(--red); font-size: 11px; text-align: center; margin-bottom: 8px; min-height: 14px; }
.user-chip {
display: flex; align-items: center; gap: 10px; font-size: 12px;
}
.logout-btn {
background: transparent; border: 1px solid var(--border); color: var(--text-dim);
font-family: inherit; font-size: 11px; padding: 5px 10px; border-radius: 4px; cursor: pointer;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }
/* ---------- Tabs ---------- */
.tab-row { display: flex; gap: 4px; margin-bottom: 12px; }
.tab-btn {
flex: 1; background: var(--panel2); border: 1px solid var(--border); color: var(--text-dim);
font-family: inherit; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
padding: 8px 4px; border-radius: 4px; cursor: pointer;
}
.tab-btn.active { background: var(--amber-dim); color: #0a0a0a; border-color: var(--amber-dim); font-weight: 700; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
/* ---------- Friend requests / search ---------- */
.request-row, .search-result-row {
display: flex; justify-content: space-between; align-items: center;
padding: 7px 10px; margin-bottom: 5px; border-radius: 5px;
background: var(--panel2); border: 1px solid var(--border); font-size: 12px;
}
.small-btn {
background: transparent; border: 1px solid var(--amber-dim); color: var(--amber);
border-radius: 4px; padding: 5px 9px; font-family: inherit; font-size: 10px; cursor: pointer;
}
.small-btn:hover { background: var(--amber); color: #0a0a0a; }
.small-btn.reject { border-color: var(--red); color: var(--red); }
.small-btn.reject:hover { background: var(--red); color: #fff; }
.section-label {
font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
margin: 12px 0 6px;
}
/* ---------- Messages ---------- */
.convo-row {
display: flex; justify-content: space-between; align-items: center; cursor: pointer;
padding: 8px 10px; margin-bottom: 5px; border-radius: 5px;
background: var(--panel2); border: 1px solid var(--border); font-size: 12px;
}
.convo-row:hover { border-color: var(--amber-dim); }
.convo-name { color: var(--amber-bright); font-weight: 700; }
.convo-preview { color: var(--text-dim); font-size: 11px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { background: var(--amber); color: #0a0a0a; font-size: 9px; font-weight: 800; border-radius: 8px; padding: 1px 6px; }
.thread-modal { width: 340px; display: flex; flex-direction: column; }
.thread-messages { max-height: 260px; overflow-y: auto; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.thread-msg { max-width: 80%; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; }
.thread-msg.mine { align-self: flex-end; background: var(--amber-dim); color: #0a0a0a; }
.thread-msg.theirs { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); }
.thread-input-row { display: flex; gap: 6px; }
.thread-input-row input {
flex: 1; background: var(--panel2); border: 1px solid var(--border); border-radius: 4px;
color: var(--text); font-family: inherit; font-size: 12px; padding: 8px;
}
/* ---------- Multiplayer ---------- */
.mp-card {
padding: 10px; margin-bottom: 8px; border-radius: 5px;
background: var(--panel2); border: 1px solid var(--border);
}
.mp-card-title { font-size: 12px; color: var(--amber-bright); font-weight: 700; margin-bottom: 4px; }
.mp-card-meta { font-size: 10px; color: var(--text-dim); margin-bottom: 6px; }
.progress-bar-track {
height: 6px; background: #000; border-radius: 3px; overflow: hidden; margin-bottom: 3px;
}
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); }
.progress-row { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.create-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.create-form input {
background: var(--panel2); border: 1px solid var(--border); border-radius: 4px;
color: var(--text); font-family: inherit; font-size: 12px; padding: 7px;
}
/* ---------- Scrollable long lists (163 tiers / achievements) ---------- */
#hireList { max-height: 320px; overflow-y: auto; padding-right: 4px; }
.hire-more-note {
text-align: center; color: var(--text-dim); font-size: 10px; padding: 6px 0 2px; font-style: italic;
}
#achievementsList { max-height: 280px; overflow-y: auto; padding-right: 4px; }
.achv-row {
display: flex; align-items: center; gap: 10px;
padding: 7px 8px; margin-bottom: 4px; border-radius: 5px;
background: var(--panel2); border: 1px solid var(--border); opacity: 0.55;
}
.achv-row.unlocked { opacity: 1; border-color: var(--amber-dim); }
.achv-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.achv-text { display: flex; flex-direction: column; gap: 1px; }
.achv-name { font-size: 11px; font-weight: 700; color: var(--text); }
.achv-row.unlocked .achv-name { color: var(--amber-bright); }
.achv-desc { font-size: 10px; color: var(--text-dim); }
/* ---------- Achievement unlock toast ---------- */
#achievementToastRoot {
position: fixed; top: 16px; right: 16px; z-index: 1500;
display: flex; flex-direction: column; gap: 8px;
}
.achv-toast {
background: var(--panel); border: 1px solid var(--amber); border-radius: 6px;
padding: 10px 16px; box-shadow: 0 0 20px rgba(255,176,0,0.25);
animation: toastIn 0.25s ease-out; transition: opacity 0.6s ease;
}
.achv-toast.fade-out { opacity: 0; }
.achv-toast-title { font-size: 9px; color: var(--amber-dim); text-transform: uppercase; letter-spacing: 1px; }
.achv-toast-name { font-size: 13px; color: var(--amber-bright); font-weight: 800; margin-top: 2px; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
</style>
</head>
<body>
<div class="scanline"></div>
<div class="auth-screen" id="authScreen">
<div class="auth-box">
<h1>commit_engine</h1>
<div class="auth-sub" id="authSub">sign in to sync your commits everywhere</div>
<div class="auth-error" id="authError"></div>
<input type="text" id="authUsername" placeholder="username" maxlength="20" autocomplete="username" />
<input type="password" id="authPassword" placeholder="password" autocomplete="current-password" />
<button class="auth-submit" id="authSubmitBtn">sign in</button>
<div class="auth-toggle">
<span id="authToggleText">no account? </span><a id="authToggleLink">register</a>
</div>
</div>
</div>
<header>
<h1>commit_engine</h1>
<div class="stats-bar">
<span>refactor_pts: <b id="rpDisplay">0</b></span>
<span>total_commits: <b id="totalDisplay">0</b></span>
<div class="user-chip">
<span id="userChipName"></span>
<button class="logout-btn" id="logoutBtn">sign out</button>
</div>
</div>
</header>
<div class="layout">
<div>
<div class="panel commit-zone" style="position:relative; overflow:hidden;">
<h2 style="text-align:left;">// main branch</h2>
<div class="commit-count" id="commitCount">0</div>
<div class="commit-sub">commits per second: <span id="cps">0</span></div>
<div style="position:relative;">
<button class="commit-btn" id="commitBtn">git commit -m "fix"</button>
</div>
</div>
<div class="panel" style="margin-top:16px;">
<h2>// hire team</h2>
<div id="hireList"></div>
<div class="prestige-box">
<div style="font-size:11px; color: var(--text-dim); margin-bottom:8px;">
Refactor resets commits & hires for permanent multiplier
</div>
<button class="prestige-btn" id="prestigeBtn">refactor()</button>
</div>
</div>
<div class="panel" style="margin-top:16px;">
<h2>// achievements <span id="achievementsProgress" style="float:right; color:var(--text-dim); font-size:10px; text-transform:none; letter-spacing:0;">0 / 163 unlocked</span></h2>
<div id="achievementsList"></div>
</div>
</div>
<div class="panel">
<h2>// social</h2>
<div class="tab-row">
<button class="tab-btn active" data-tab="friends">Friends</button>
<button class="tab-btn" data-tab="messages">Messages</button>
<button class="tab-btn" data-tab="races">Races</button>
<button class="tab-btn" data-tab="teams">Teams</button>
</div>
<div class="tab-pane active" id="tab-friends">
<div class="add-friend-row">
<input type="text" id="addFriendInput" placeholder="search username" maxlength="24" />
<button class="hire-btn" id="addFriendBtn">search</button>
</div>
<div id="searchResults"></div>
<div id="incomingRequestsWrap" style="display:none;">
<div class="section-label">incoming requests</div>
<div id="incomingRequests"></div>
</div>
<div class="section-label">leaderboard</div>
<div id="leaderList"></div>
<div id="leaderEmpty" class="leader-empty" style="display:none;">
No friends yet. Search a username above and send a request.
</div>
</div>
<div class="tab-pane" id="tab-messages">
<div id="convoList"></div>
<div id="convoEmpty" class="leader-empty" style="display:none;">
No conversations yet. Open a friend's profile and hit "message" to start one.
</div>
</div>
<div class="tab-pane" id="tab-races">
<div class="create-form">
<input type="text" id="raceName" placeholder="race name" maxlength="30" />
<input type="number" id="raceGoal" placeholder="commit goal (e.g. 5000)" min="1" />
<input type="number" id="raceDuration" placeholder="duration in minutes (e.g. 60)" min="1" />
<button class="hire-btn" id="createRaceBtn">start race</button>
</div>
<div id="raceList"></div>
</div>
<div class="tab-pane" id="tab-teams">
<div class="create-form">
<input type="text" id="teamName" placeholder="team name" maxlength="30" />
<button class="hire-btn" id="createTeamBtn">found team</button>
</div>
<div id="teamList"></div>
</div>
</div>
</div>
<div class="footer-note">commit_engine v1.1 — state autosaves to localStorage every 2s</div>
<div id="modalRoot"></div>
<div id="trialRoot"></div>
<div id="achievementToastRoot"></div>
<script>
(function () {
'use strict';
const SAVE_KEY = 'commitEngine.save.v2';
const LEGACY_KEYS = ['commitEngine.save', 'commit-engine-save', 'commitEngineSave'];
const TOKEN_KEY = 'commitEngine.authToken';
// ---------- Backend config ----------
// Set this to your deployed Render URL after deploying commit-engine-backend, e.g.
// 'https://commit-engine-backend.onrender.com'. Leave as-is for local testing against
// `npm start` on the backend (defaults to localhost:3000).
const API_BASE_URL = 'https://commit-engine-backend.onrender.com';
// Number formatter — defined this early because the shop/achievement
// generators just below run immediately at load and both call fmt().
const FMT_SUFFIXES = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc'];
function fmt(n) {
if (n < 1000) return Math.floor(n).toString();
const tier = Math.min(FMT_SUFFIXES.length - 1, Math.floor(Math.log10(n) / 3));
return (n / Math.pow(1000, tier)).toFixed(2) + FMT_SUFFIXES[tier];
}
// ---------- Hires config (163 tiers, generated) ----------
// Rather than hand-author 163 near-identical entries, generate them from a
// small pool of role/tier names with a smooth cost/cps growth curve — this
// keeps the progression balanced (each tier ~19% pricier, ~15% stronger)
// and avoids 150+ lines of copy-pasted, error-prone data.
const HIRE_ROLE_NAMES = [
'Intern', 'Junior Dev', 'Mid-level Dev', 'Senior Dev', 'Staff Eng',
'Principal Eng', 'Architect', 'DevOps Eng', 'QA Engineer', 'Data Engineer',
'ML Engineer', 'Security Eng', 'SRE', 'Tech Lead', 'Eng Manager',
'Director of Eng', 'VP of Eng', 'Consultant', 'Open Source Maintainer', 'Hackathon Champion'
];
const HIRE_TIER_LABELS = [
'Trainee', 'Junior', 'Associate', 'Mid', 'Senior',
'Staff', 'Principal', 'Distinguished', 'Legendary'
];
const HIRE_DEFS = (function generateHireDefs() {
const defs = [];
let idx = 0;
outer:
for (const tier of HIRE_TIER_LABELS) {
for (const role of HIRE_ROLE_NAMES) {
if (idx >= 163) break outer;
const baseCost = Math.ceil(15 * Math.pow(1.19, idx));
const cps = +(0.15 * Math.pow(1.155, idx)).toFixed(3);
defs.push({
id: 'hire_' + idx,
name: `${tier} ${role}`,
cps,
baseCost
});
idx++;
}
}
return defs;
})();
// ---------- Achievements (163, generated) ----------
// Same reasoning as above: generated from templates rather than hand-written,
// so the 163 conditions stay consistent and checkable in code instead of prose.
const ACHV_ADJECTIVES = [
'Tireless', 'Midnight', 'Caffeinated', 'Relentless', 'Silent', 'Legendary',
'Rogue', 'Diligent', 'Fearless', 'Methodical', 'Chaotic', 'Meticulous',
'Unstoppable', 'Nocturnal', 'Zealous'
];
const ACHV_NOUNS = [
'Committer', 'Refactorer', 'Builder', 'Shipper', 'Debugger', 'Architect',
'Maintainer', 'Contributor', 'Reviewer', 'Merger', 'Deployer', 'Coder'
];
function buildCommitMilestoneAchievements(count) {
const list = [];
let lastThreshold = 0;
for (let i = 0; i < count; i++) {
let threshold = Math.round(10 * Math.pow(1.28, i));
if (threshold <= lastThreshold) threshold = lastThreshold + 1;
lastThreshold = threshold;
const adj = ACHV_ADJECTIVES[i % ACHV_ADJECTIVES.length];
const noun = ACHV_NOUNS[(i * 7) % ACHV_NOUNS.length];
list.push({
id: 'commits_' + i,
name: `${adj} ${noun}`,
desc: `Reach ${fmt(threshold)} total commits.`,
check: (ctx) => ctx.state.totalCommits >= threshold
});
}
return list;
}
function buildHireMilestoneAchievements() {
const list = [];
for (let tierIdx = 0; tierIdx < 163; tierIdx += 10) {
const def = HIRE_DEFS[tierIdx];
if (!def) continue;
const target = 25;
list.push({
id: 'hire_milestone_' + tierIdx,
name: `${def.name} Wrangler`,
desc: `Hire ${target} ${def.name}s.`,
check: (ctx) => (ctx.state.hires[def.id] || 0) >= target
});
}
return list;
}
function buildPrestigeAchievements() {
return [1, 2, 5, 10, 25, 50, 100].map(n => ({
id: 'prestige_' + n,
name: n === 1 ? 'First Refactor' : `Refactored ${n} Times`,
desc: `Refactor ${n} time${n === 1 ? '' : 's'}.`,
check: (ctx) => ctx.state.prestigeCount >= n
}));
}
function buildClickAchievements() {
return [100, 1000, 10000].map(n => ({
id: 'clicks_' + n,
name: n === 100 ? 'Finger Warmup' : n === 1000 ? 'Carpal Tunnel Candidate' : 'Click Machine',
desc: `Manually click "git commit" ${fmt(n)} times.`,
check: (ctx) => ctx.state.manualClicks >= n
}));
}
function buildSocialAchievements() {
return [
{ id: 'friend_first', name: 'Made a Friend', desc: 'Add your first friend.',
check: (ctx) => ctx.friendsCache.friends.length >= 1 },
{ id: 'friend_5', name: 'Small Squad', desc: 'Have 5 friends.',
check: (ctx) => ctx.friendsCache.friends.length >= 5 },
{ id: 'friend_10', name: 'Networker', desc: 'Have 10 friends.',
check: (ctx) => ctx.friendsCache.friends.length >= 10 },
{ id: 'friend_25', name: 'Social Committer', desc: 'Have 25 friends.',
check: (ctx) => ctx.friendsCache.friends.length >= 25 },
{ id: 'msg_first', name: 'Breaking the Ice', desc: 'Send your first message.',
check: (ctx) => ctx.state.messagesSent >= 1 },
{ id: 'msg_10', name: 'Chatty', desc: 'Send 10 messages.',
check: (ctx) => ctx.state.messagesSent >= 10 },
{ id: 'msg_50', name: 'Never Stops Talking', desc: 'Send 50 messages.',
check: (ctx) => ctx.state.messagesSent >= 50 },
{ id: 'race_first', name: 'On Your Marks', desc: 'Join your first race.',
check: (ctx) => ctx.state.racesJoinedCount >= 1 },
{ id: 'race_3', name: 'Serial Racer', desc: 'Join 3 races.',
check: (ctx) => ctx.state.racesJoinedCount >= 3 },
{ id: 'team_first', name: 'Team Player', desc: 'Join your first team.',
check: (ctx) => ctx.state.teamsJoinedCount >= 1 },
{ id: 'team_contribute_1000', name: 'Pooling Resources', desc: 'Contribute 1,000 commits to a team pool.',
check: (ctx) => ctx.state.teamContributedTotal >= 1000 },
{ id: 'team_contribute_10000', name: 'All In', desc: 'Contribute 10,000 commits to a team pool.',
check: (ctx) => ctx.state.teamContributedTotal >= 10000 }
];
}
const ACHIEVEMENTS = (function generateAchievements() {
const hireMilestones = buildHireMilestoneAchievements(); // 17
const prestige = buildPrestigeAchievements(); // 7
const social = buildSocialAchievements(); // 12
const clicks = buildClickAchievements(); // 3
const fixedCount = hireMilestones.length + prestige.length + social.length + clicks.length;
const commitMilestones = buildCommitMilestoneAchievements(163 - fixedCount);
return [...commitMilestones, ...hireMilestones, ...prestige, ...social, ...clicks];
})();
// ---------- State ----------
let state = {
commits: 0,
totalCommits: 0,
refactorPoints: 0,
hires: {},
trialShown: false,
trialActive: false,
trialDeadline: 0,
manualClicks: 0,
prestigeCount: 0,
messagesSent: 0,
racesJoinedCount: 0,
teamsJoinedCount: 0,
teamContributedTotal: 0,
unlockedAchievements: {}
};
let currentUser = null; // { id, username, total_commits, refactor_points }
let authToken = localStorage.getItem(TOKEN_KEY) || null;
function defaultHires() {
const h = {};
HIRE_DEFS.forEach(d => h[d.id] = 0);
return h;
}
function loadState() {
let raw = localStorage.getItem(SAVE_KEY);
if (!raw) {
// attempt legacy migration so old players don't lose progress
for (const k of LEGACY_KEYS) {
const legacy = localStorage.getItem(k);
if (legacy) { raw = legacy; break; }
}
}
if (raw) {
try {
const parsed = JSON.parse(raw);
state = Object.assign({
commits: 0, totalCommits: 0, refactorPoints: 0,
hires: defaultHires(), trialShown: false,
trialActive: false, trialDeadline: 0,
manualClicks: 0, prestigeCount: 0, messagesSent: 0,
racesJoinedCount: 0, teamsJoinedCount: 0, teamContributedTotal: 0,
unlockedAchievements: {}
}, parsed);
if (!state.hires) state.hires = defaultHires();
if (!state.unlockedAchievements) state.unlockedAchievements = {};
// old local-only "friends" data is superseded by the real backend friend
// system; drop it from the save so it doesn't linger unused.
delete state.friends;
} catch (e) {
state.hires = defaultHires();
}
} else {
state.hires = defaultHires();
}
}
function saveState() {
try {
localStorage.setItem(SAVE_KEY, JSON.stringify(state));
} catch (e) { /* storage full or unavailable, ignore */ }
}
// Save on every meaningful mutation AND on an interval AND on unload,
// so a reload never rolls back progress (this fixes the reset-on-reload bug).
window.addEventListener('beforeunload', saveState);
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') saveState();
});
setInterval(saveState, 2000);
loadState();
// ---------- API client ----------
async function api(method, path, body, timeoutMs) {
const headers = { 'Content-Type': 'application/json' };
if (authToken) headers['Authorization'] = 'Bearer ' + authToken;
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), timeoutMs || 60000);
let res;
try {
res = await fetch(API_BASE_URL + path, {
method,
headers,
body: body !== undefined ? JSON.stringify(body) : undefined,
signal: controller.signal
});
} catch (e) {
if (e.name === 'AbortError') {
throw new Error('The server took too long to respond. If this is the first request in a while, it may still be waking up — try again in a moment.');
}
throw new Error('Could not reach the server. Check your connection and try again.');
} finally {
clearTimeout(timeout);
}
let data = null;
try { data = await res.json(); } catch (e) { /* empty body */ }
if (!res.ok) {
const err = new Error((data && data.error) || ('Request failed: ' + res.status));
err.status = res.status;
throw err;
}
return data;
}
// ---------- Derived values ----------
function hireCost(def) {
const owned = state.hires[def.id] || 0;
return Math.ceil(def.baseCost * Math.pow(1.15, owned));
}
function multiplier() {
return 1 + state.refactorPoints * 0.1;
}
function totalCps() {
let cps = 0;
HIRE_DEFS.forEach(d => { cps += (state.hires[d.id] || 0) * d.cps; });
return cps * multiplier();
}
// (fmt moved earlier in the file — see near SAVE_KEY constants — since the
// achievement/shop generators below need it and run immediately at load.)
// ---------- Rendering ----------
const commitCountEl = document.getElementById('commitCount');
const cpsEl = document.getElementById('cps');
const rpDisplay = document.getElementById('rpDisplay');
const totalDisplay = document.getElementById('totalDisplay');
const hireListEl = document.getElementById('hireList');
const leaderListEl = document.getElementById('leaderList');
const leaderEmptyEl = document.getElementById('leaderEmpty');
const modalRoot = document.getElementById('modalRoot');
const trialRoot = document.getElementById('trialRoot');
function renderTopStats() {
commitCountEl.textContent = fmt(state.commits);
cpsEl.textContent = totalCps().toFixed(1);
rpDisplay.textContent = fmt(state.refactorPoints);
totalDisplay.textContent = fmt(state.totalCommits);
}
function renderHires() {
hireListEl.innerHTML = '';
// With 163 tiers, only render owned ones plus a handful of upcoming ones —
// keeps the DOM small and avoids re-building 163 rows on every tick.
let highestOwnedIdx = -1;
HIRE_DEFS.forEach((def, i) => { if ((state.hires[def.id] || 0) > 0) highestOwnedIdx = i; });
const visibleCount = Math.min(HIRE_DEFS.length, Math.max(8, highestOwnedIdx + 6));
const visibleDefs = HIRE_DEFS.slice(0, visibleCount);
visibleDefs.forEach(def => {
const cost = hireCost(def);
const owned = state.hires[def.id] || 0;
const row = document.createElement('div');
row.className = 'hire-row';
row.innerHTML = `
<div class="hire-info">
<div class="name">${def.name} <span style="color:var(--text-dim); font-weight:400;">x${owned}</span></div>
<div class="desc">${fmt(def.cps)} commits/sec</div>
</div>
<button class="hire-btn" data-id="${def.id}" ${state.commits < cost ? 'disabled' : ''}>
hire — ${fmt(cost)}
</button>`;
hireListEl.appendChild(row);
});
if (visibleCount < HIRE_DEFS.length) {
const more = document.createElement('div');
more.className = 'hire-more-note';
more.textContent = `+ ${HIRE_DEFS.length - visibleCount} more roles unlock as your team grows`;
hireListEl.appendChild(more);
}
hireListEl.querySelectorAll('.hire-btn').forEach(btn => {
btn.addEventListener('click', () => {
const def = HIRE_DEFS.find(d => d.id === btn.dataset.id);
const cost = hireCost(def);
if (state.commits >= cost) {
state.commits -= cost;
state.hires[def.id] = (state.hires[def.id] || 0) + 1;
saveState();
renderAll();
checkAchievements();
}
});
});
}
function initials(name) {
return name.replace(/^you$/i, 'Y').split(/[\s_.]+/).filter(Boolean).map(p => p[0]).join('').slice(0, 2).toUpperCase() || '?';
}
// ---------- Friends / leaderboard (server-backed) ----------
let friendsCache = { friends: [], incomingRequests: [], outgoingRequests: [] };
async function refreshFriends() {
try {
friendsCache = await api('GET', '/friends');
} catch (e) { /* stay on stale cache if a poll fails */ }
renderLeaderboard();
renderIncomingRequests();
checkAchievements();
}
function renderLeaderboard() {
const entries = friendsCache.friends.map(f => ({
username: f.username, score: Number(f.total_commits) || 0
}));
entries.push({ username: 'you', score: Math.floor(state.totalCommits) });
entries.sort((a, b) => b.score - a.score);
leaderListEl.innerHTML = '';
leaderEmptyEl.style.display = friendsCache.friends.length === 0 ? 'block' : 'none';
entries.forEach((e, i) => {
const row = document.createElement('div');
row.className = 'leader-row';
row.innerHTML = `
<div class="leader-left">
<div class="avatar">${initials(e.username)}</div>
<div class="leader-name"><span class="rank">#${i + 1}</span>${e.username}${e.username !== 'you' ? '<span class="friend-badge">FRIEND</span>' : ''}</div>
</div>
<div class="leader-score">${fmt(e.score)}</div>
`;
if (e.username !== 'you') {
row.style.cursor = 'pointer';
row.addEventListener('click', () => openProfile(e.username));
}
leaderListEl.appendChild(row);
});
}
function renderIncomingRequests() {
const wrap = document.getElementById('incomingRequestsWrap');
const list = document.getElementById('incomingRequests');
if (friendsCache.incomingRequests.length === 0) {
wrap.style.display = 'none';
return;
}
wrap.style.display = 'block';
list.innerHTML = '';
friendsCache.incomingRequests.forEach(username => {
const row = document.createElement('div');
row.className = 'request-row';
row.innerHTML = `
<span>${username}</span>
<span>
<button class="small-btn" data-user="${username}" data-accept="1">accept</button>
<button class="small-btn reject" data-user="${username}" data-accept="0">decline</button>
</span>`;
list.appendChild(row);
});
list.querySelectorAll('.small-btn').forEach(btn => {
btn.addEventListener('click', async () => {
try {
await api('POST', '/friends/respond', {
requesterUsername: btn.dataset.user,
accept: btn.dataset.accept === '1'
});
await refreshFriends();
} catch (e) { alert(e.message); }
});
});
}
async function searchUsers(query) {
const resultsEl = document.getElementById('searchResults');
resultsEl.innerHTML = '';
if (!query || query.trim().length < 2) return;
let users = [];
try {
const data = await api('GET', '/friends/search?q=' + encodeURIComponent(query.trim()));
users = data.users || [];
} catch (e) { return; }
users.forEach(u => {
const alreadyFriend = friendsCache.friends.some(f => f.username === u.username);
const alreadyOutgoing = friendsCache.outgoingRequests.includes(u.username);
const row = document.createElement('div');
row.className = 'search-result-row';
let action;
if (alreadyFriend) action = `<span style="color:var(--text-dim); font-size:10px;">already friends</span>`;
else if (alreadyOutgoing) action = `<span style="color:var(--text-dim); font-size:10px;">request sent</span>`;
else action = `<button class="small-btn" data-user="${u.username}">+ request</button>`;
row.innerHTML = `<span>${u.username}</span><span>${action}</span>`;
resultsEl.appendChild(row);
});
resultsEl.querySelectorAll('.small-btn').forEach(btn => {
btn.addEventListener('click', async () => {
try {
await api('POST', '/friends/request', { username: btn.dataset.user });
await refreshFriends();
searchUsers(query);
} catch (e) { alert(e.message); }
});
});
}
async function openProfile(username) {
const friend = friendsCache.friends.find(f => f.username === username);
modalRoot.innerHTML = `
<div class="modal-backdrop" id="modalBackdrop">
<div class="modal">
<button class="modal-close" id="modalCloseBtn">×</button>
<div class="modal-avatar">${initials(username)}</div>
<div class="modal-name">${username}</div>
<div class="modal-title">Friend</div>
<div class="modal-stats">
<div><b>${fmt(friend ? friend.total_commits : 0)}</b>commits</div>
<div><b>${fmt(friend ? friend.refactor_points : 0)}</b>refactor pts</div>
</div>
<button class="friend-btn" id="messageFriendBtn">message</button>
<button class="remove-friend-btn" id="removeFriendBtn">remove friend</button>
</div>
</div>`;
document.getElementById('modalCloseBtn').addEventListener('click', closeProfile);
document.getElementById('modalBackdrop').addEventListener('click', (ev) => {
if (ev.target.id === 'modalBackdrop') closeProfile();
});
document.getElementById('messageFriendBtn').addEventListener('click', () => {
closeProfile();
switchTab('messages');
openThread(username);
});
document.getElementById('removeFriendBtn').addEventListener('click', async () => {
try {
await api('DELETE', '/friends/' + encodeURIComponent(username));
closeProfile();
await refreshFriends();
} catch (e) { alert(e.message); }
});
}
function closeProfile() {
modalRoot.innerHTML = '';
}
// ---------- Messages (server-backed DMs, friends only) ----------
async function refreshMessages() {
const listEl = document.getElementById('convoList');
const emptyEl = document.getElementById('convoEmpty');
let data;
try {
data = await api('GET', '/messages');
} catch (e) { return; }
const convos = data.conversations || [];
emptyEl.style.display = convos.length === 0 ? 'block' : 'none';
listEl.innerHTML = '';
convos.forEach(c => {
const row = document.createElement('div');
row.className = 'convo-row';
row.innerHTML = `
<span class="convo-name">${c.username}</span>
<span class="convo-preview">${c.sentByMe ? 'you: ' : ''}${(c.lastMessage || '').slice(0, 40)}</span>
${c.unreadCount > 0 ? `<span class="unread-dot">${c.unreadCount}</span>` : ''}
`;
row.addEventListener('click', () => openThread(c.username));
listEl.appendChild(row);
});
}