-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1999 lines (1921 loc) · 75 KB
/
index.html
File metadata and controls
1999 lines (1921 loc) · 75 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" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MIE286 Study - Direction Matching Game</title>
<style>
:root {
--bg: #0f172a;
--card: #111827;
--muted: #94a3b8;
--text: #e5e7eb;
--accent: #38bdf8;
--accent2: #22c55e;
--accent2-soft: #86efac;
--border: #1f2937;
--warn: #fbbf24;
--ok: #86efac;
--danger: #ef4444;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
overflow: hidden;
}
body {
margin: 0;
font-family: Inter, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
color: var(--text);
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: stretch;
padding: 12px;
}
.app {
width: min(100vw - 24px, 1700px);
height: calc(100vh - 24px);
background: rgba(17, 24, 39, 0.97);
border: 1px solid var(--border);
border-radius: 24px;
padding: 22px 26px 26px;
box-shadow: 0 20px 60px rgba(0,0,0,0.35);
overflow: hidden;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 2.2rem; margin-bottom: 8px; }
h2 { font-size: 2rem; margin-bottom: 12px; }
.muted { color: var(--muted); }
.card {
border: 1px solid var(--border);
border-radius: 18px;
padding: 18px;
background: rgba(255,255,255,0.02);
margin-top: 16px;
}
.confetti-layer {
position: absolute;
inset: 0;
pointer-events: none;
overflow: hidden;
z-index: 40;
}
.confetti-piece {
position: absolute;
width: 10px;
height: 16px;
top: 14%;
border-radius: 3px;
opacity: 0.95;
animation: confettiDrop 1200ms cubic-bezier(0.18, 0.72, 0.3, 1) forwards;
will-change: transform, opacity;
}
@keyframes confettiDrop {
0% {
transform: translate3d(0, -12px, 0) rotate(0deg);
opacity: 0;
}
10% {
opacity: 1;
}
100% {
transform: translate3d(var(--drift-x, 0px), var(--drop-y, 220px), 0) rotate(var(--spin, 360deg));
opacity: 0;
}
}
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(220px, 1fr));
gap: 14px;
margin: 0;
}
.stat {
border: 1px solid var(--border);
border-radius: 18px;
padding: 18px;
background: rgba(255,255,255,0.03);
min-height: 108px;
display: flex;
flex-direction: column;
justify-content: center;
}
.stat-label { color: var(--muted); font-size: 1rem; }
.stat-value { font-size: 2.1rem; font-weight: 800; margin-top: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.topbar {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
margin-bottom: 18px;
flex-wrap: wrap;
}
.language-switch { margin-left: auto; }
.card ul { line-height: 1.6; }
button {
appearance: none;
border: none;
background: linear-gradient(90deg, var(--accent), #60a5fa);
color: #08111f;
font-weight: 700;
padding: 12px 18px;
border-radius: 12px;
cursor: pointer;
font-size: 1rem;
}
button.secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
button.ghost {
background: rgba(255,255,255,0.04);
color: var(--text);
border: 1px solid var(--border);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="text"] {
width: 280px;
max-width: 100%;
padding: 12px 14px;
border-radius: 12px;
border: 1px solid var(--border);
background: rgba(255,255,255,0.04);
color: var(--text);
font-size: 1rem;
}
.main-layout {
display: flex;
flex-direction: column;
gap: 16px;
min-height: 0;
height: calc(100vh - 180px);
}
.fullscreen-flow {
min-height: 0;
height: calc(100vh - 120px);
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.intro-panel {
max-height: calc(100vh - 168px);
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
padding-right: 8px;
}
.transition-screen {
min-height: 0;
height: calc(100vh - 160px);
display: flex;
align-items: center;
justify-content: center;
padding: 8px 0 0;
}
.transition-panel {
width: 100%;
min-height: min(72vh, 760px);
border: 1px solid var(--border);
border-radius: 26px;
background: linear-gradient(180deg, rgba(255,255,255,0.035) 0%, rgba(255,255,255,0.02) 100%);
padding: clamp(28px, 4vw, 56px);
display: flex;
flex-direction: column;
justify-content: center;
gap: 28px;
box-shadow: 0 18px 48px rgba(0,0,0,0.24);
}
.transition-copy {
max-width: 1100px;
}
.transition-kicker {
color: var(--muted);
font-size: 1.05rem;
margin-bottom: 10px;
}
.transition-title {
font-size: clamp(2.4rem, 5vw, 4.6rem);
line-height: 1.06;
font-weight: 900;
letter-spacing: -0.03em;
margin: 0;
}
.transition-lead {
font-size: clamp(1.05rem, 1.8vw, 1.35rem);
color: #dbe4f0;
margin: 0;
line-height: 1.65;
max-width: 920px;
}
.transition-info {
border: 1px solid rgba(148, 163, 184, 0.18);
border-radius: 22px;
background: rgba(255,255,255,0.035);
padding: clamp(20px, 2.4vw, 30px);
max-width: 1120px;
}
.transition-info p {
margin: 0;
font-size: clamp(1rem, 1.5vw, 1.25rem);
line-height: 1.7;
}
.transition-actions {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 14px;
margin-top: 4px;
}
.transition-actions button {
min-width: 220px;
min-height: 68px;
font-size: 1.25rem;
border-radius: 18px;
}
.feedback-panel {
width: 100%;
border: 1px solid rgba(56, 189, 248, 0.32);
border-radius: 20px;
padding: 20px 24px;
background: rgba(255,255,255,0.03);
box-shadow: 0 10px 28px rgba(0,0,0,0.16);
min-height: 120px;
display: flex;
flex-direction: column;
justify-content: center;
}
.feedback-label {
color: #dbeafe;
font-size: 1.15rem;
font-weight: 700;
margin-bottom: 10px;
}
.completed-big {
font-size: min(6vw, 4rem);
line-height: 1.1;
font-weight: 900;
color: #f8fafc;
display: flex;
justify-content: space-between;
gap: 12px;
align-items: baseline;
}
.completed-answer-top {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6px;
margin: 10px auto 6px;
min-height: 112px;
width: 100%;
text-align: center;
}
.completed-answer-top .done-number {
font-size: min(10vw, 5.6rem);
line-height: 0.95;
font-weight: 900;
color: var(--accent2-soft);
text-shadow: 0 0 18px rgba(34, 197, 94, 0.18);
}
.completed-answer-top .total-number {
font-size: min(2.8vw, 1.35rem);
line-height: 1.1;
font-weight: 700;
color: var(--muted);
text-align: center;
}
.progress-shell {
width: 100%;
height: 48px;
border-radius: 999px;
border: 1px solid var(--border);
background: rgba(255,255,255,0.05);
overflow: hidden;
}
.progress-fill {
height: 100%;
width: 0%;
background: linear-gradient(90deg, var(--accent2), var(--accent2-soft));
transition: width 0.08s linear, background 0.12s linear;
}
.bar-timer {
margin-top: 10px;
font-size: 1.9rem;
font-weight: 900;
letter-spacing: 0.04em;
}
.stimulus-inner {
width: 100%;
min-height: inherit;
display: flex;
justify-content: center;
align-items: center;
padding: 22px 24px 30px;
}
.trial-counter {
position: absolute;
top: 22px;
left: 24px;
right: 24px;
text-align: center;
color: #dbe4f0;
font-size: 1.45rem;
font-weight: 800;
letter-spacing: 0.02em;
}
.stimulus-track {
display: flex;
align-items: center;
justify-content: center;
gap: clamp(14px, 2vw, 26px);
width: 100%;
padding-top: 42px;
}
.current-arrow-wrap {
width: min(28vw, 16rem);
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
}
.stage-progress-wrap {
margin-top: 6px;
}
.stage-progress-track {
display: flex;
gap: 8px;
width: 100%;
align-items: stretch;
}
.stage-progress-segment {
position: relative;
height: 14px;
border-radius: 999px;
background: rgba(255,255,255,0.06);
border: 1px solid rgba(148, 163, 184, 0.18);
overflow: visible;
}
.stage-progress-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0%;
border-radius: inherit;
transition: width 0.08s linear;
}
.stage-progress-flag {
position: absolute;
left: 0%;
top: 50%;
width: 18px;
height: 28px;
transform: translate(-50%, -56%);
pointer-events: none;
z-index: 2;
transition: left 0.08s linear;
}
.stage-progress-flag::before {
content: '';
position: absolute;
left: 3px;
top: 1px;
width: 2px;
height: 24px;
border-radius: 999px;
background: rgba(248, 250, 252, 0.95);
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18);
}
.stage-progress-flag::after {
content: '';
position: absolute;
left: 5px;
top: 2px;
width: 10px;
height: 8px;
background: linear-gradient(180deg, #fb7185, #dc2626);
clip-path: polygon(0 0, 100% 18%, 72% 50%, 100% 82%, 0 100%);
box-shadow: 0 1px 4px rgba(220, 38, 38, 0.35);
border-radius: 1px;
}
.stage-progress-fill.practice { background: linear-gradient(90deg, #22c55e, #4ade80); }
.stage-progress-fill.block0 { background: linear-gradient(90deg, #22c55e, #86efac); }
.stage-progress-fill.block1 { background: linear-gradient(90deg, #38bdf8, #60a5fa); }
.stage-progress-labels {
display: flex;
gap: 8px;
margin-top: 8px;
color: var(--muted);
font-size: 0.96rem;
font-weight: 600;
text-align: center;
}
.stage-progress-label {
min-width: 0;
}
.arrow.thick-arrow {
font-weight: 900;
text-shadow: 1.1px 0 0 currentColor, -1.1px 0 0 currentColor, 0 1.1px 0 currentColor, 0 -1.1px 0 currentColor;
}
.preview-arrows {
display: flex;
gap: 12px;
justify-content: center;
align-items: center;
}
.preview-arrow-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
opacity: 0.5;
width: min(9vw, 4.5rem);
flex: 0 0 auto;
}
.preview-arrow-item .arrow {
font-size: min(8vw, 3.5rem);
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.preview-arrow-item .preview-label {
font-size: 0.7rem;
color: var(--muted);
font-weight: 600;
letter-spacing: 0.04em;
}
.stimulus {
position: relative;
display: flex;
justify-content: center;
align-items: center;
flex: 1 1 auto;
width: min(100%, 980px);
max-height: min(42vh, 460px);
min-height: 0;
border: 1px dashed #334155;
border-radius: 24px;
background: rgba(255,255,255,0.02);
margin: 0 auto;
overflow: hidden;
}
.arrow {
font-size: min(18vw, 10rem);
line-height: 1;
user-select: none;
}
.success { color: var(--ok); }
.warning { color: var(--warn); }
.upload-emphasis { color: #ff5a5a; font-weight: 900; letter-spacing: 0.01em; text-transform: uppercase; }
.leaderboard-panel {
display: flex;
flex-direction: column;
gap: 12px;
}
.leaderboard-table {
width: 100%;
border-collapse: collapse;
margin-top: 4px;
}
.leaderboard-table th,
.leaderboard-table td {
border-bottom: 1px solid var(--border);
padding: 12px 8px;
text-align: left;
font-size: 0.95rem;
vertical-align: middle;
}
.leaderboard-table th { color: var(--muted); font-weight: 600; }
.leaderboard-table tr.current-row {
background: rgba(56, 189, 248, 0.08);
}
.leaderboard-rank-cell {
width: 82px;
white-space: nowrap;
font-weight: 800;
}
.rank-badge {
display: inline-flex;
align-items: center;
gap: 6px;
font-weight: 800;
}
.crown { font-size: 1rem; }
.crown.gold { color: #fbbf24; }
.crown.silver { color: #cbd5e1; }
.crown.bronze { color: #d97706; }
.leaderboard-self-tag {
display: inline-block;
margin-left: 6px;
padding: 2px 8px;
border-radius: 999px;
font-size: 0.78rem;
font-weight: 700;
color: #dbeafe;
background: rgba(56, 189, 248, 0.14);
border: 1px solid rgba(56, 189, 248, 0.24);
}
.leaderboard-ellipsis td {
text-align: center;
color: var(--muted);
font-weight: 800;
letter-spacing: 0.22em;
}
.leaderboard-rule {
color: #cbd5e1;
font-size: 0.94rem;
line-height: 1.6;
margin: 0;
}
.pill {
display: inline-block;
font-size: 0.85rem;
padding: 5px 10px;
border-radius: 999px;
border: 1px solid var(--border);
color: var(--muted);
}
.touchpad-wrap {
display: flex;
justify-content: center;
margin-top: 8px;
}
.touchpad {
display: grid;
grid-template-columns: 88px 88px 88px;
grid-template-rows: 88px 88px;
gap: 8px;
align-items: center;
justify-items: center;
user-select: none;
touch-action: manipulation;
}
.touchpad-empty {
width: 88px;
height: 88px;
}
.mobile-stats {
display: none;
}
.trial-copy {
display: flex;
flex-direction: column;
gap: 8px;
}
.trial-copy p {
margin-bottom: 0;
}
.mobile-touchdock {
display: contents;
}
.touch-btn {
width: 88px;
height: 88px;
border-radius: 14px;
border: 1px solid #cfd4db;
background: linear-gradient(180deg, #fafafa 0%, #dfe3e8 100%);
box-shadow: inset 0 2px 0 rgba(255,255,255,0.95), inset 0 -2px 6px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.18);
color: #1f2937;
font-size: 2rem;
font-weight: 700;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.touch-btn:active {
transform: translateY(1px) scale(0.99);
box-shadow: inset 0 2px 6px rgba(0,0,0,0.12), 0 3px 8px rgba(0,0,0,0.16);
}
@media (max-width: 900px) {
.grid { grid-template-columns: 1fr; }
.app { width: calc(100vw - 16px); height: calc(100vh - 16px); padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); }
.topbar { margin-bottom: 6px; align-items: center; gap: 8px; }
.topbar h2 { font-size: 1.35rem; margin-bottom: 0; }
.topbar .muted { font-size: 0.92rem; }
.main-layout { gap: 6px; height: calc(100vh - 132px); }
.intro-panel { max-height: calc(100vh - 144px); padding-right: 2px; }
.stat { min-height: 92px; }
.stat-value { font-size: 1.8rem; }
.feedback-panel { min-height: 64px; padding: 10px 12px; border-radius: 16px; }
.feedback-label { font-size: 0.92rem; margin-bottom: 4px; }
.completed-answer-top .done-number { font-size: 3.65rem; }
.completed-answer-top .total-number { font-size: 0.92rem; }
.stimulus {
width: min(100%, 100%);
max-height: min(34vh, 280px);
min-height: 0;
border-radius: 20px;
}
.arrow { font-size: min(22vw, 6rem); }
.mobile-stats {
display: flex;
gap: 6px;
overflow-x: auto;
padding-bottom: 2px;
-webkit-overflow-scrolling: touch;
}
.mobile-stats .pill {
white-space: nowrap;
font-size: 0.8rem;
padding: 4px 8px;
color: var(--text);
border-color: rgba(148, 163, 184, 0.25);
background: rgba(255,255,255,0.04);
}
.touch-layout .grid { display: none; }
.touch-layout .trial-copy { display: none; }
.mobile-touchdock {
display: block;
position: sticky;
bottom: 0;
margin-top: auto;
padding: 8px 0 calc(6px + env(safe-area-inset-bottom));
background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.92) 18%, rgba(15, 23, 42, 1) 100%);
}
.touchpad-wrap { margin-top: 0; }
.touchpad {
width: min(100%, 338px);
grid-template-columns: repeat(3, minmax(84px, 1fr));
grid-template-rows: 88px 88px;
gap: 8px;
}
.touch-btn,
.touchpad-empty {
width: 100%;
height: 88px;
}
.transition-screen { height: calc(100vh - 150px); padding-top: 4px; }
.transition-panel { min-height: calc(100vh - 210px); border-radius: 22px; padding: 24px 20px; }
.transition-actions { justify-content: stretch; }
.transition-actions button { width: 100%; min-width: 0; min-height: 60px; font-size: 1.1rem; }
.stage-progress-segment { height: 10px; }
.stage-progress-labels { font-size: 0.8rem; margin-top: 6px; }
.stage-progress-wrap { margin-top: 2px; }
.trial-counter {
top: 14px;
left: 16px;
right: 16px;
font-size: 1.18rem;
}
.stimulus-inner { padding: 14px 16px 18px; }
.stimulus-track {
gap: 10px;
padding-top: 32px;
}
.current-arrow-wrap {
width: min(24vw, 6.5rem);
}
.preview-arrows {
gap: 6px;
}
.preview-arrow-item {
width: min(11vw, 3.4rem);
}
.preview-arrow-item .arrow {
font-size: min(6vw, 2.5rem);
}
.preview-arrow-item .preview-label {
font-size: 0.6rem;
}
}
</style>
</head>
<body>
<div class="app">
<div id="screen"></div>
</div>
<script>
const CONFIG = {
practiceTrials: 10,
blockTrials: 100,
practiceDurationMs: 12000,
blockDurationMs: 60000,
interTrialMs: 100,
countdownSeconds: 3,
googleScriptUrl: 'https://script.google.com/macros/s/AKfycbxiZsPR_PRYtP09s1ASSd18FgbgayLFLlT1JePsV4knRJHoDZVPfPAK6cr5ONFOiUdB/exec',
enableUpload: true,
previewArrowCount: 2,
stageUploadIntervalMs: 10000,
stimuli: [
{ key: 'ArrowUp', symbol: '↑', correct: 'ArrowDown', type: 'vertical' },
{ key: 'ArrowDown', symbol: '↓', correct: 'ArrowUp', type: 'vertical' },
{ key: 'ArrowLeft', symbol: '←', correct: 'ArrowRight', type: 'horizontal' },
{ key: 'ArrowRight', symbol: '→', correct: 'ArrowLeft', type: 'horizontal' }
]
};
const I18N = {
en: {
study: 'MIE286 Study',
title: 'Direction Matching Game',
introLead: 'How many correct responses can you make in 60 seconds?',
readBefore: 'Before you begin',
bullets: [
'In laboratory finger-tapping tests, healthy adults in their 20s and 30s average about 300 simple taps per minute with the dominant index finger. But this challenge is harder.',
'Here, every arrow must be answered with the opposite direction. That means this is not just about speed — it is also about attention, judgment, and consistency.',
'You will complete two 60-second rounds. The task stays the same, but the countdown is displayed differently in each round.',
'We want to explore one question: Can the way time is shown affect how fast and how accurately you perform?',
'How many can you finish? How accurate can you stay? This time, the record will be written by you.'
],
consent: 'I agree to participate anonymously for the MIE286 course project. (Required to start)',
soundConsent: 'Enable optional sound effects to make the task feel more interactive.',
leaderboardConsent: 'I agree to join the optional leaderboard. Optional: if unchecked, you will not join the leaderboard and will not see leaderboard results.',
soundHint: 'If enabled, each response uses a soft key-tap sound, and a warning beep repeats during the last 15 seconds.',
nicknameLabel: 'Nickname (optional)',
nicknamePlaceholder: 'Enter a nickname or leave blank',
participantLabel: 'Participant ID (optional)',
participantPlaceholder: 'Leave blank to auto-generate an ID',
continue: 'Continue to Practice →',
warmup: 'Warm-up Round',
practiceFirst: 'Practice first',
practiceDesc: 'You will have 10 practice opportunities before the two 60-second rounds. Practice does not count toward the final score.',
rule: 'Rule:',
ruleText: 'if you see ↑, press ↓. If you see ←, press →, and so on.',
cogLoad: 'This opposite-response rule adds cognitive load so the task is not too easy.',
startPractice: 'Start Practice →',
practiceRound: 'Practice Round',
block: 'Block',
of: 'of',
getReady: 'Get Ready',
feedback: 'Feedback',
numeric: 'Numeric Countdown',
bar: 'Countdown Bar',
numericDisplay: 'Time Remaining',
barDisplay: 'Time Remaining',
accuracy: 'Accuracy',
meanRT: 'Mean RT',
elapsed: 'Elapsed',
pressOpposite: 'Press the opposite arrow key.',
practiceComplete: 'Practice complete. Next, you will start the first experimental block.',
orderText: 'Your main task order is',
startBlock1: 'Start Block 1 →',
block1Complete: 'Block 1 complete. Take a short break, then continue to Block 2.',
startBlock2: 'Start Block 2 →',
thankYou: 'Thank you for participating',
complete: 'Test Complete',
yourResults: 'Your personal results',
uploaded: 'Upload status',
uploadStatusReady: 'Upload is not connected yet. Add your Google Apps Script URL to enable automatic saving.',
uploadStatusSuccess: 'Your results were uploaded successfully.',
uploadStatusUploading: 'Uploading in progress. Please do not leave this page. This may take one minute and thank you for your patience.',
uploadStatusLeaderboard: 'Your results were uploaded. Please wait while the leaderboard refreshes.',
uploadStatusFail: 'Upload failed. Your on-screen summary is still available.',
restart: 'Restart Demo',
noOthers: 'This page does not expose any other participant data.',
language: '中文 / EN',
leaderboardTitle: 'Optional Leaderboard',
leaderboardDesc: 'Only participants who opted in are shown below.',
noLeaderboard: 'No leaderboard entries available yet.',
leaderboardLoading: 'Please wait while the leaderboard refreshes.',
leaderboardCurrent: 'You',
leaderboardRuleTitle: 'Scoring rule',
leaderboardRule: 'Leaderboard rank uses your better single main block, not a combined two-block score. Score = Completed × Accuracy². Because feedback order is randomized, this may correspond to Trial 1 or Trial 2 depending on the assigned order.',
rank: 'Rank',
name: 'Name',
score: 'Score',
accShort: 'Acc.',
rtShort: 'RT',
device: 'Device',
input: 'Input',
touchHint: 'Touch controls are enabled below for touchscreen devices.'
},
zh: {
study: 'MIE286 实验',
title: '方向匹配任务',
introLead: '60 秒内,你能完成多少次正确反应?',
readBefore: '开始之前',
bullets: [
'在实验室的单指快速敲击测试中,健康成年人的优势手平均约可达到每分钟 300 次简单敲击。但在这里,事情没那么简单。',
'你看到的每一个箭头,都要求你按下相反方向的按键。这意味着你面对的不只是手速挑战,还有注意力、判断与稳定性的考验。',
'你将完成两个阶段的挑战,每个阶段 60 秒。两轮规则相同,但倒计时的呈现方式不同。',
'我们想研究的是:时间反馈的表达方式,会不会影响你的速度与准确率?',
'你能完成多少题?你的正确率能保持多高?这一次,记录将由你亲手写下。'
],
consent: '我同意以匿名方式参加 MIE286 课程项目实验。(必选,否则无法开始)',
soundConsent: '开启可选音效,让任务更有互动感。',
leaderboardConsent: '我同意加入可选积分榜。可选;如果不勾选,则不会加入积分榜,也看不到他人成绩。',
soundHint: '如果开启,每次作答都会播放温和的“键盘敲击”音效;最后 15 秒会持续滴滴提示。',
nicknameLabel: '昵称(可选)',
nicknamePlaceholder: '可输入昵称,也可留空',
participantLabel: '参与者编号(可选)',
participantPlaceholder: '可留空,系统将自动分配编号',
continue: '继续到练习 →',
warmup: '热身练习',
practiceFirst: '先进行练习',
practiceDesc: '正式挑战前你有 10 次练习机会,然后进入两个 60 秒的正式阶段。练习不计入最终得分。',
rule: '规则:',
ruleText: '如果看到 ↑,就按 ↓;如果看到 ←,就按 →,其余同理。',
cogLoad: '“按相反方向”的规则会增加一定认知负担,避免任务过于简单。',
startPractice: '开始练习 →',
practiceRound: '练习环节',
block: '模块',
of: '/',
getReady: '准备开始',
feedback: '反馈方式',
numeric: '数字倒计时',
bar: '倒计时进度条',
numericDisplay: '剩余时间',
barDisplay: '剩余时间',
accuracy: '正确率',
meanRT: '平均反应时间',
elapsed: '用时',
pressOpposite: '请按相反方向键。',
practiceComplete: '练习结束。接下来开始第一个正式实验模块。',
orderText: '你的正式实验顺序是',
startBlock1: '开始模块 1 →',
block1Complete: '模块 1 已结束。短暂休息后继续模块 2。',
startBlock2: '开始模块 2 →',
thankYou: '感谢你的参与',
complete: '实验完成',
yourResults: '你的个人结果',
uploaded: '上传状态',
uploadStatusReady: '上传功能尚未连接。填入 Google Apps Script 链接后即可自动保存。',
uploadStatusSuccess: '你的结果已成功上传。',
uploadStatusUploading: '正在上传,请勿退出。这可能需要一分钟,感谢你的耐心等待。',
uploadStatusLeaderboard: '你的结果已上传,请稍等积分榜刷新。',
uploadStatusFail: '上传失败,但你的页面结果仍可查看。',
restart: '重新开始演示',
noOthers: '此页面不会暴露其他参与者的数据。',
language: '中文 / EN',
leaderboardTitle: '可选积分榜',
leaderboardDesc: '下面只显示同意加入积分榜的参与者。',
noLeaderboard: '目前还没有可显示的积分榜记录。',
leaderboardLoading: '请稍等,积分榜正在刷新。',
leaderboardCurrent: '你',
leaderboardRuleTitle: '积分规则',
leaderboardRule: '排行榜按两个正式模块中得分更高的那一个模块排序,不是两块合并成绩。积分 = 完成题数 × 正确率²。由于反馈顺序随机,这个成绩可能对应试验一,也可能对应试验二。',
rank: '排名',
name: '昵称',
score: '得分',
accShort: '正确率',
rtShort: '反应时',
device: '设备',
input: '输入方式',
touchHint: '触屏设备可使用下方方向键按钮。'
}
};
const state = {
lang: 'en',
phase: 'intro',
participantId: '',
nickname: '',
joinLeaderboard: false,
conditionOrder: Math.random() < 0.5 ? ['numeric', 'bar'] : ['bar', 'numeric'],
blockIndex: 0,
trialIndex: 0,
currentStimulus: null,
upcomingStimuli: [],
waitingForResponse: false,
trialStart: null,
blockStartTime: null,
results: [],
uploadedTrialCount: 0,
stageUploadMarkers: { practice: 0, block0: 0, block1: 0 },
uploadQueue: Promise.resolve(),
inPractice: false,
feedbackMode: null,
uploadStatus: 'idle',
leaderboard: [],
leaderboardLoading: false,
lastStimuli: [],
sessionId: `S-${Math.random().toString(36).slice(2, 10).toUpperCase()}`,
deviceType: /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ? 'mobile' : 'desktop',
inputMode: ('ontouchstart' in window || navigator.maxTouchPoints > 0) ? 'touch' : 'keyboard',
soundEnabled: false,
audioCtx: null,
audioReady: false,
masterGain: null,
lastAudioTime: 0,
betweenAfterPractice: true,
stageDeadline: null,
timerInterval: null,
warningSecondPlayed: null,
blockEnding: false,
bufferedResponse: null,
lastRenderedSecond: null,
liveTimerEls: null,
nextStageUploadAt: null,
finalizingUploads: false
};
const screen = document.getElementById('screen');
const t = (key) => I18N[state.lang][key];
function setScrollMode(enabled) {
document.documentElement.style.overflowY = enabled ? 'auto' : 'hidden';
document.body.style.overflowY = enabled ? 'auto' : 'hidden';
document.body.style.overflowX = 'hidden';
const app = document.querySelector('.app');
if (app) app.style.overflowY = enabled ? 'auto' : 'hidden';
}
async function initAudio() {
if (!state.audioCtx) {
const Ctx = window.AudioContext || window.webkitAudioContext;
if (Ctx) state.audioCtx = new Ctx({ latencyHint: 'interactive' });
}
if (!state.audioCtx) return false;
if (state.audioCtx.state === 'suspended') {
try {
await state.audioCtx.resume();
} catch (e) {
}
}
if (!state.masterGain) {
state.masterGain = state.audioCtx.createGain();
state.masterGain.gain.value = 1;
state.masterGain.connect(state.audioCtx.destination);
}
if (!state.audioReady) {
const now = state.audioCtx.currentTime;
const osc = state.audioCtx.createOscillator();
const gain = state.audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(880, now);
gain.gain.setValueAtTime(0.00001, now);
gain.gain.exponentialRampToValueAtTime(0.00002, now + 0.01);
gain.gain.exponentialRampToValueAtTime(0.00001, now + 0.03);
osc.connect(gain);
gain.connect(state.masterGain);
osc.start(now);
osc.stop(now + 0.04);
state.audioReady = true;
}
return true;
}
function playTapSound() {
if (!state.soundEnabled || !state.audioReady || !state.audioCtx) return;
if (state.audioCtx.state === 'suspended') return;
const now = Math.max(state.audioCtx.currentTime + 0.001, state.lastAudioTime + 0.002);
state.lastAudioTime = now;
const osc1 = state.audioCtx.createOscillator();
const osc2 = state.audioCtx.createOscillator();
const gain = state.audioCtx.createGain();
const filter = state.audioCtx.createBiquadFilter();
filter.type = 'highshelf';
filter.frequency.value = 2200;
filter.gain.value = -4;
osc1.type = 'triangle';
osc2.type = 'square';
osc1.frequency.setValueAtTime(790, now);
osc2.frequency.setValueAtTime(1210, now);
gain.gain.setValueAtTime(0.0001, now);
gain.gain.exponentialRampToValueAtTime(0.017, now + 0.003);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.028);
osc1.connect(filter);
osc2.connect(filter);
filter.connect(gain);
gain.connect(state.masterGain || state.audioCtx.destination);
osc1.start(now);
osc2.start(now);
osc1.stop(now + 0.04);
osc2.stop(now + 0.04);
}
function generateParticipantId() {
return `P-${Math.random().toString(36).slice(2, 8).toUpperCase()}`;
}
function formatElapsed(ms) {
const totalSec = Math.floor(ms / 1000);
const min = String(Math.floor(totalSec / 60)).padStart(2, '0');
const sec = String(totalSec % 60).padStart(2, '0');
return `${min}:${sec}`;
}
function formatRemaining(ms) {
const totalSec = Math.max(0, Math.ceil(ms / 1000));
const min = String(Math.floor(totalSec / 60)).padStart(2, '0');
const sec = String(totalSec % 60).padStart(2, '0');
return `${min}:${sec}`;