-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathen.html
More file actions
1539 lines (1454 loc) · 72.3 KB
/
Copy pathen.html
File metadata and controls
1539 lines (1454 loc) · 72.3 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>GazeWheel — test version (gaze control)</title>
<style>
:root{
--bg:#0f1420;
--panel:#1a2233;
--panel2:#232e46;
--text:#f2f6ff;
--dim:#8fa0bf;
--accent:#4da3ff;
--green:#59c96b;
--amber:#ffd166;
--red:#ff7b7b;
--wedge:#26324c;
--wedge2:#1d2740;
--hub:#2c3a5c;
--rest:#151c2c;
}
/* paletas — mesma lógica do logo: um acento forte + um secundário */
body[data-theme="red"] { --accent:#ff6b6b; --green:#ffa96b; }
body[data-theme="green"] { --accent:#5ad48a; --green:#7fd8ff; }
body[data-theme="purple"]{ --accent:#b18cff; --green:#6bd6ff; }
body[data-theme="amber"] { --accent:#ffc247; --green:#ff9f6b; }
/* fundo claro — luz ambiente forte, ou quem simplesmente enxerga melhor assim */
body.light{
--bg:#dfebfa; --panel:#ffffff; --panel2:#d3e4f8; --text:#111827; --dim:#4d5d7a;
--accent:#0a63c9; --green:#0f7a35; --amber:#8a5a00; --red:#c0392b;
--wedge:#c8dcf5; --wedge2:#eaf2fd; --hub:#b4cdee; --rest:#ffffff;
}
body.light[data-theme="red"] { --accent:#c62828; --green:#b25a00; }
body.light[data-theme="green"] { --accent:#0f7a35; --green:#0b6ba8; }
body.light[data-theme="purple"]{ --accent:#6a3fc0; --green:#0b6ba8; }
body.light[data-theme="amber"] { --accent:#9a6400; --green:#b25a00; }
body.light #tail .prev{color:#55658a;}
body.light #tail.empty::before{color:#a7b3c9;}
body.light .wedge:hover{fill:#b2ccf0;}
body.light .quad:hover{fill:#a3c0e8;}
body.light .quad.danger{fill:#f7d3da;}
body.light .quad.danger:hover{fill:#eeb0bd;}
body.light .outerLbl{fill:#33445f;}
body.light .sub{fill:#3b4d70;}
body.light .restTxt{fill:#97a3ba;}
body.light .tgt.flash{color:#fff !important;}
body.light .word:hover{background:#c9dcf6;}
body.light #btnFix.ativo{color:#fff;}
body.light.fix #out .w:hover{color:#fff;}
body.light button.ctrl:hover{background:#c6d8f2;}
body.light button.ctrl.big{background:#d3e4fb; border-color:#a7c4ea;}
body.light button.ctrl.big:hover{background:#c0d8f8;}
body.light button.ctrl.att{background:#fdf0cd;}
body.light button.ctrl.att:hover{background:#f8e2a8;}
body.light #talkOverlay{background:#fff;}
body.light #talkText.vazio{color:#a7b3c9;}
body.light .modal{background:rgba(15,20,32,.45);}
body.light .row{border-bottom-color:#cfdcef;}
body.light .mini:hover{background:#c6d8f2;}
body.light .mini.on{color:#fff;}
body.light #cmdBox{border-color:#b9cbe6;}
body.light #topWords span{color:#35486a;}
body.hc{
--bg:#000; --panel:#0a0a0a; --panel2:#141414; --text:#fff; --dim:#c8c8c8;
--wedge:#333; --wedge2:#1c1c1c; --hub:#3a3a3a; --rest:#000; --accent:#ffe600; --green:#00e676;
}
*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%;}
body{
background:var(--bg); color:var(--text);
font-family:"Segoe UI", Roboto, Arial, sans-serif;
display:flex; flex-direction:column; overflow:hidden; user-select:none;
}
body.locked #wheel{opacity:.45;}
body.paused #stage{opacity:.35;}
#app{flex:1; display:flex; gap:10px; padding:8px 10px 10px; min-height:0;}
/* ---------- palco: texto + sugestões + roda ---------- */
#stage{flex:0 0 auto; display:flex; flex-direction:column; align-items:center; gap:4px; min-width:0; transition:opacity .2s;}
#tail{
min-height:56px; max-width:100%; display:flex; align-items:center; justify-content:flex-end;
overflow:hidden; font-size:calc(38px * var(--fs,1)); font-weight:700; white-space:pre; letter-spacing:.5px;
}
#tail .prev{color:#b7c5e0; font-weight:600;}
#tail .cur{color:var(--amber);}
#tail .caret{display:inline-block; width:5px; height:.95em; margin-left:3px; background:var(--accent); animation:blink 1.1s step-end infinite;}
#tail.empty::before{content:"write…"; color:#3d4a66; font-weight:600;}
@keyframes blink{50%{opacity:0;}}
#sugRow{display:flex; gap:14px; min-height:66px; align-items:center; justify-content:center; flex-wrap:nowrap;}
#wheelWrap{flex:0 0 auto; display:flex; align-items:center; justify-content:center;}
svg{display:block;}
/* ---------- alvos SVG ---------- */
.wedge{fill:var(--wedge); stroke:var(--bg); stroke-width:5; cursor:pointer;}
.outer .wedge{fill:var(--wedge2);}
.wedge:hover{fill:#3a5583;}
.wedge.dwelling{fill:var(--accent);}
.wedge.flash{fill:var(--accent);}
/* layout tradicional (QWERTY) — mesma engine, só a disposição muda */
.key{fill:var(--wedge); stroke:var(--bg); stroke-width:4; cursor:pointer;}
.key:hover{fill:#3a5583;}
.key.dwelling,.key.flash{fill:var(--accent);}
.key.fnkey{fill:var(--hub);}
.key.danger{fill:#4a2b38;}
.key.danger:hover{fill:#6d3a4c;}
body.light .key:hover{fill:#b2ccf0;}
body.light .key.danger{fill:#f7d3da;}
body.light .key.danger:hover{fill:#eeb0bd;}
.quad{fill:var(--hub); stroke:var(--bg); stroke-width:5; cursor:pointer;}
.quad:hover{fill:#3d5080;}
.quad.dwelling,.quad.flash{fill:var(--accent);}
.quad.danger{fill:#4a2b38;}
.quad.danger:hover{fill:#6d3a4c;}
.lbl{fill:var(--text); text-anchor:middle; dominant-baseline:central; pointer-events:none; font-weight:700;}
.outerLbl{fill:#c9d6ee; font-weight:600;}
.sub{fill:#cfd9ee; font-weight:600; opacity:.85;}
/* o centro repete o miolo do logo: anel de acento em volta da zona de descanso */
#restZone{fill:var(--rest); stroke:var(--accent); stroke-opacity:.5; stroke-width:4; pointer-events:none;}
#restDot{fill:var(--accent); opacity:.16; pointer-events:none;}
.pageArc{fill:none; stroke:var(--accent); stroke-width:9; stroke-linecap:round; pointer-events:none; opacity:.85;}
.restTxt{fill:#46557a; text-anchor:middle; dominant-baseline:central; pointer-events:none; font-weight:700;}
/* ---------- botões HTML ---------- */
.tgt{position:relative; overflow:hidden; border:none; cursor:pointer; color:var(--text); font-family:inherit;}
.tgt .fill{position:absolute; left:0; top:0; bottom:0; width:0; background:rgba(77,163,255,.38); pointer-events:none;}
.tgt.dwelling .fill{width:100%;}
.tgt.flash{background:var(--accent) !important; color:#0f1420 !important;}
.word{
background:var(--panel2); border:3px solid transparent; border-radius:999px; color:var(--green);
font-size:calc(30px * var(--fs,1)); font-weight:600; padding:12px 26px; white-space:nowrap; min-height:62px;
}
.word:hover{border-color:var(--green); background:#2a3a56;}
.word b{color:var(--text); font-weight:700;}
.word .fill{background:rgba(89,201,107,.30);}
/* ---------- lado direito ---------- */
#side{flex:0 0 clamp(240px, 30%, 460px); display:flex; flex-direction:column; gap:8px;}
#out{
background:var(--panel); border-radius:14px; padding:14px 18px;
font-size:calc(27px * var(--fs,1)); line-height:1.35; flex:1; overflow-y:auto; word-wrap:break-word;
}
#out .caret{display:inline-block; width:3px; height:1em; background:var(--accent); vertical-align:text-bottom; animation:blink 1.1s step-end infinite;}
/* modo "copie este trecho" — chega pela página Classics, em ?copy= */
#copyBar{display:none; background:var(--panel); border:2px solid var(--accent); border-radius:14px; padding:12px 14px;}
#copyBar.on{display:block;}
#copyTxt{font-size:calc(19px * var(--fs,1)); line-height:1.35; margin-bottom:7px;}
#copyTxt .done{color:var(--green); font-weight:700;}
#copyTxt .todo{color:var(--dim);}
#copyStat{font-size:15px; color:var(--accent); font-weight:700;}
#copyReset{height:42px; font-size:16px; width:100%; margin-top:9px; background:var(--panel2); border-radius:10px; font-weight:600;}
#navRow{display:grid; grid-template-columns:66px 1fr 66px; gap:8px;}
#btnFix.ativo{background:var(--accent); color:#0f1420;}
/* modo corrigir: as palavras do texto viram alvos para reposicionar o cursor */
body.fix #out{border:2px solid var(--accent);}
body.fix #out .w{cursor:pointer; border-radius:6px; padding:0 2px; background:rgba(77,163,255,.10);}
body.fix #out .w:hover{background:var(--accent); color:#0f1420;}
#btns{display:grid; grid-template-columns:1fr 1fr; gap:8px;}
button.ctrl{background:var(--panel2); border-radius:12px; font-size:18px; font-weight:600; height:52px; padding:0 6px;}
button.ctrl:hover{background:#33436a;}
button.ctrl.wide{grid-column:1 / -1;}
button.ctrl.big{height:70px; font-size:24px; background:#1f3352; color:var(--amber); border:2px solid #35507d;}
button.ctrl.big:hover{background:#2a4370;}
button.ctrl.att{height:60px; font-size:19px; background:#3a2f18; color:var(--amber);}
button.ctrl.att:hover{background:#50401f;}
/* saída do teclado sem depender da barra do navegador — quem usa rastreador
costuma estar em tela cheia e não alcança o "voltar" */
#btnBack{height:42px; font-size:15.5px; font-weight:600; background:transparent; color:var(--dim);
border:1px solid var(--line); border-radius:10px;}
#btnBack:hover{background:var(--panel2); color:var(--text);}
/* modo conversa: texto grande virado para o interlocutor ler */
#talkOverlay{position:fixed; inset:0; background:#0b0f18; display:none; flex-direction:column; z-index:60; padding:26px;}
#talkOverlay.on{display:flex;}
#talkText{flex:1; display:flex; align-items:center; justify-content:center; text-align:center;
font-size:min(8.5vw,86px); font-weight:700; line-height:1.25; overflow:auto; padding:10px;}
#talkText.vazio{color:#3d4a66; font-size:34px; font-weight:600;}
#talkOverlay .close{max-width:440px; margin:0 auto;}
#btnSpeak{color:var(--amber);} #btnClear{color:var(--red);} #btnPause{color:var(--accent);}
#status{font-size:15px; color:var(--dim); min-height:20px; text-align:center;}
/* ---------- janelas ---------- */
.modal{position:fixed; inset:0; background:rgba(6,9,16,.88); display:none; align-items:center; justify-content:center; padding:20px; z-index:50;}
.modal.on{display:flex;}
.box{background:var(--panel); border-radius:18px; padding:20px; width:min(900px,96vw); max-height:92vh; overflow:auto;}
.box h2{font-size:23px; margin-bottom:6px;}
.box p.hint{color:var(--dim); font-size:15px; margin-bottom:14px; line-height:1.45;}
.row{display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid #2a3550; flex-wrap:wrap;}
.row:last-child{border-bottom:none;}
.row label{font-size:18px; flex:1; min-width:190px;}
.row .val{color:var(--accent); font-weight:700; min-width:78px; text-align:right; font-size:18px;}
.mini{background:var(--panel2); border-radius:10px; height:46px; min-width:56px; font-size:19px; font-weight:700; padding:0 14px;}
.mini:hover{background:#33436a;}
.mini.on{background:var(--accent); color:#0f1420;}
#cmdRow{display:flex; gap:8px; margin-top:10px; flex-wrap:wrap;}
#cmdBox{flex:1; min-width:230px; background:var(--panel2); border:1px solid #33436a; color:var(--text);
border-radius:10px; padding:12px 14px; font-size:17px; font-family:inherit;}
#cmdOut{margin-top:9px; color:var(--dim); font-size:15px; line-height:1.4;}
#topWords{display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 4px;}
#topWords span{background:var(--panel2); border-radius:999px; padding:6px 14px; font-size:16px; color:#cddaf0;}
#topWords span b{color:var(--accent); font-weight:700; margin-left:6px; font-size:14px;}
#phraseGrid{display:grid; grid-template-columns:repeat(auto-fill,minmax(270px,1fr)); gap:10px; margin-bottom:14px;}
.phrase{background:var(--panel2); border-radius:14px; padding:16px 18px; font-size:20px; text-align:left; min-height:66px; line-height:1.3;}
.phrase:hover{background:#33436a;}
textarea{width:100%; height:190px; background:var(--panel2); color:var(--text); border:2px solid #2f3c5c; border-radius:12px; padding:12px; font-size:17px; font-family:inherit; resize:vertical;}
.modal .close{margin-top:16px; width:100%; height:60px; border-radius:12px; background:var(--panel2); font-size:20px; font-weight:700;}
.modal .close:hover{background:#33436a;}
.tagline{color:var(--dim); font-size:13px; text-align:center; padding:2px 0 0;}
</style>
</head>
<body>
<div id="app">
<section id="stage">
<div id="tail"></div>
<div id="sugRow"></div>
<div id="wheelWrap"><svg id="wheel" viewBox="0 0 850 850" aria-label="circular keyboard"></svg></div>
</section>
<aside id="side">
<div id="copyBar">
<div id="copyTxt"></div>
<div id="copyStat"></div>
<button class="ctrl tgt" id="copyReset"><span class="fill"></span>Start fresh</button>
</div>
<div id="out" aria-live="polite"></div>
<div id="navRow">
<button class="ctrl tgt" id="btnPrev"><span class="fill"></span>◀</button>
<button class="ctrl tgt" id="btnFix"><span class="fill"></span>✎ Fix</button>
<button class="ctrl tgt" id="btnNext"><span class="fill"></span>▶</button>
</div>
<div id="btns">
<button class="ctrl tgt wide big" id="btnSpeak"><span class="fill"></span>🔊 Speak</button>
<button class="ctrl tgt wide att" id="btnAtt"><span class="fill"></span>✋ Wait, I'm typing</button>
<button class="ctrl tgt" id="btnPhrases"><span class="fill"></span>💬 Phrases</button>
<button class="ctrl tgt" id="btnTalk"><span class="fill"></span>👁 Face to face</button>
<button class="ctrl tgt" id="btnMode"><span class="fill"></span>123 / ?!</button>
<button class="ctrl tgt" id="btnPause"><span class="fill"></span>⏸ Pause</button>
<button class="ctrl tgt" id="btnCfg"><span class="fill"></span>⚙ Settings</button>
<button class="ctrl tgt" id="btnLearn"><span class="fill"></span>🧠 Teach</button>
<button class="ctrl tgt wide" id="btnClear"><span class="fill"></span>🗑 Clear</button>
</div>
<div id="status"></div>
<button class="ctrl tgt" id="btnBack"><span class="fill"></span>← Leave the keyboard</button>
<div class="tagline">test version · your text and vocabulary are stored only on this computer</div>
</aside>
</div>
<!-- ============ MODO CONVERSA ============ -->
<div id="talkOverlay">
<div id="talkText"></div>
<button class="close tgt" id="talkClose"><span class="fill"></span>Back to writing</button>
</div>
<!-- ============ FRASES ============ -->
<div class="modal" id="mPhrases"><div class="box">
<h2>Saved phrases</h2>
<p class="hint">One selection instead of typing it all. Tap a phrase to insert it into the text.</p>
<div id="phraseGrid"></div>
<div class="row">
<button class="mini tgt" id="phSave"><span class="fill"></span>+ Save current text as a phrase</button>
<button class="mini tgt" id="phDel"><span class="fill"></span>🗑 Remove a phrase</button>
</div>
<button class="close tgt" data-close><span class="fill"></span>Close</button>
</div></div>
<!-- ============ ENSINAR ============ -->
<div class="modal" id="mLearn"><div class="box">
<h2>Teach the keyboard to write like you</h2>
<p class="hint">Paste texts you wrote yourself — articles, e-mails, posts — or load text files all at once
(useful if you already use another calibrated autocomplete: export your texts from there and bring them here).
The keyboard learns your words and, above all, <b>which words you tend to use after which</b>. It is the fastest
way to cut the number of selections per sentence. Nothing is sent to the internet: it stays in this browser only.</p>
<textarea id="learnTxt" placeholder="Paste one of your texts here…"></textarea>
<div class="row">
<button class="mini tgt" id="learnGo"><span class="fill"></span>Learn from this text</button>
<button class="mini tgt" id="learnFiles"><span class="fill"></span>📄 Learn from files</button>
</div>
<div class="row">
<button class="mini tgt" id="learnExp"><span class="fill"></span>⬇ Export learning</button>
<button class="mini tgt" id="learnImp"><span class="fill"></span>⬆ Import learning</button>
</div>
<div class="row"><label id="learnStats"></label></div>
<div class="row" style="display:block"><label>Your most used words</label>
<div id="topWords"></div></div>
<button class="close tgt" data-close><span class="fill"></span>Close</button>
</div></div>
<!-- ============ AJUSTES ============ -->
<div class="modal" id="mCfg"><div class="box">
<h2>Settings</h2>
<p class="hint">Made for people who control the cursor with their eyes. If your equipment already clicks by itself
(Tobii Windows Control, for example), keep dwell selection <b>off</b> so there are no two wait times stacked.</p>
<div class="row" style="display:block"><label>Ask in your own words</label>
<div id="cmdRow">
<input id="cmdBox" type="text" placeholder="make it red · bigger letters · speak slower">
<button class="mini tgt" id="cmdGo"><span class="fill"></span>Apply</button>
<button class="mini tgt" id="cmdFromText"><span class="fill"></span>Use what I typed</button>
</div>
<div id="cmdOut"></div>
</div>
<div class="row"><label>Select by pausing the cursor (dwell)</label>
<button class="mini tgt" id="cfgDwell"><span class="fill"></span>—</button></div>
<div class="row"><label>Dwell time</label>
<button class="mini tgt" id="dwellDown"><span class="fill"></span>−</button>
<span class="val" id="dwellVal"></span>
<button class="mini tgt" id="dwellUp"><span class="fill"></span>+</button></div>
<div class="row"><label>Wheel size</label>
<button class="mini tgt" id="szDown"><span class="fill"></span>−</button>
<span class="val" id="szVal"></span>
<button class="mini tgt" id="szUp"><span class="fill"></span>+</button></div>
<div class="row"><label>Text size</label>
<button class="mini tgt" id="fsDown"><span class="fill"></span>−</button>
<span class="val" id="fsVal"></span>
<button class="mini tgt" id="fsUp"><span class="fill"></span>+</button></div>
<div class="row"><label>Inner ring letter order</label>
<button class="mini tgt" id="cfgOrder"><span class="fill"></span>—</button></div>
<div class="row"><label>Letters in the inner ring</label>
<button class="mini tgt" id="cfgN"><span class="fill"></span>—</button></div>
<div class="row"><label>Show the full alphabet outside</label>
<button class="mini tgt" id="cfgOuter"><span class="fill"></span>—</button></div>
<div class="row"><label>Light background</label>
<button class="mini tgt" id="cfgLight"><span class="fill"></span>—</button></div>
<div class="row"><label>High contrast</label>
<button class="mini tgt" id="cfgHC"><span class="fill"></span>—</button></div>
<div class="row"><label>Speak automatically at end of sentence</label>
<button class="mini tgt" id="cfgAuto"><span class="fill"></span>—</button></div>
<div class="row"><label>Voice speed</label>
<button class="mini tgt" id="rateDown"><span class="fill"></span>−</button>
<span class="val" id="rateVal"></span>
<button class="mini tgt" id="rateUp"><span class="fill"></span>+</button></div>
<div class="row"><label>Voice</label>
<button class="mini tgt" id="cfgVoice"><span class="fill"></span>—</button></div>
<div class="row"><label>Layout<br><span style="font-size:14.5px;color:var(--dim)">the round wheel, or a traditional keyboard</span></label>
<button class="mini tgt" id="cfgLayout"><span class="fill"></span>—</button></div>
<div class="row"><label>Colors</label>
<button class="mini tgt" id="cfgTheme"><span class="fill"></span>—</button></div>
<div class="row"><label>Teach it your writing style<br><span style="font-size:14.5px;color:var(--dim)">paste your texts or load files — it learns your words</span></label>
<button class="mini tgt" id="cfgTeach"><span class="fill"></span>🧠 Open</button></div>
<button class="close tgt" data-close><span class="fill"></span>Close</button>
</div></div>
<script>
"use strict";
/* ================================================================
1. VOCABULARY
English frequency base + inflected forms of the most spoken verbs
+ daily care/health vocabulary
+ urban mobility, accessibility and journalism vocabulary.
================================================================ */
const BASE = [
"the","of","and","a","to","in","is","you","that","it","he","was","for","on","are","as","with","his","they","i",
"at","be","this","have","from","or","one","had","by","but","not","what","all","were","we","when","your","can","said","there",
"use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some",
"her","would","make","like","him","into","time","has","look","two","more","write","go","see","no","way","could","people","my","than",
"first","water","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part","over","new","take",
"only","little","know","place","year","me","back","give","most","very","after","thing","our","just","name","good","think","say","great","where",
"through","much","before","too","same","us","yes","please","thank","thanks","help","want","need","feel","pain","bathroom","toilet","food","hungry","thirsty",
"tired","sleep","sleepy","cold","hot","nurse","doctor","medicine","head","leg","arm","hand","foot","eye","eyes","mouth","nose","ear","neck","chest",
"stomach","heart","breath","cough","fever","itchy","position","pillow","blanket","turn","move","lift","lower","left","right","chair","bed","room","window","door",
"light","tv","television","music","phone","computer","internet","channel","volume","louder","quieter","morning","afternoon","evening","night","today","tomorrow","yesterday","week","month",
"hour","minute","family","wife","husband","mother","father","son","daughter","brother","sister","friend","love","miss","happy","sad","angry","scared","worried","calm",
"fine","bad","better","worse","big","small","old","home","house","work","school","book","movie","game","news","weather","rain","sun","wind","beach",
"trip","visit","church","party","birthday","gift","christmas","lunch","dinner","breakfast","coffee","snack","fruit","juice","milk","bread","rice","beans","meat","chicken",
"fish","soup","cake","chocolate","banana","apple","orange","hospital","appointment","exam","therapy","physiotherapy","caregiver","wheelchair","diaper","clean","scratch","adjust","slow","fast",
"careful","attention","important","urgent","emergency","ambulance","joke","secret","surprise","idea","plan","problem","solution","money","buy","pay","bill","bank","market","pharmacy",
"store","bakery","restaurant","bus","taxi","car","bike","plane","far","near","inside","outside","above","below","front","behind","beside","middle","during","always",
"never","early","soon","late","last","next","together","alone","maybe","sure","wrong","true","false","sorry","excuse","congratulations","kiss","hug","bye","hi",
"hello","something","nothing","everything","anything","someone","nobody","everyone","every","any","again","still","here","also","really","because","why","how's","let's","don't",
"can't","i'm","it's","that's","won't","didn't","doesn't","isn't","wasn't","couldn't","wouldn't","i'll","we'll","you're","i've","there's","what's"
];
/* inflected forms of the most spoken verbs — what people actually type */
const VERBOS = [
"am","being","been",
"has","had","having",
"does","did","doing","done",
"goes","went","going","gone",
"got","gotten","getting",
"makes","made","making",
"knows","knew","known","knowing",
"thinks","thought","thinking",
"takes","took","taken","taking",
"sees","saw","seen","seeing",
"comes","came","coming",
"wants","wanted","wanting",
"needs","needed","needing",
"feels","felt","feeling",
"gives","gave","given","giving",
"tells","told","telling",
"works","worked","working",
"calls","called","calling",
"tries","tried","trying",
"asks","asked","asking",
"leaves","leaving","puts","putting",
"means","meant","keeps","kept","lets","letting",
"begins","began","begun","seems","seemed",
"talks","talked","talking",
"turns","turned","turning",
"starts","started","starting","stops","stopped",
"shows","showed","shown","hears","heard","hearing",
"plays","played","playing","runs","ran","running",
"moves","moved","moving","likes","liked","lives","lived","living",
"believes","believed","holds","held","brings","brought","happens","happened",
"writes","wrote","written","writing","sits","sat","sitting",
"stands","stood","standing","loses","lost","pays","paid","meets","met",
"learns","learned","learning","changes","changed","changing",
"understands","understood","watches","watched","watching","follows","followed",
"speaks","spoke","spoken","speaking","reads","reading",
"spends","spent","grows","grew","opens","opened","opening","closes","closed","closing",
"walks","walked","walking","wins","won","offers","offered",
"remembers","remembered","remembering","forgets","forgot","forgotten",
"loves","loved","waits","waited","waiting","sends","sent","sending",
"builds","built","stays","stayed","staying","falls","fell","fallen",
"reaches","reached","remains","remained",
"eats","ate","eaten","eating","drinks","drank","drunk","drinking",
"sleeps","slept","sleeping","wakes","woke","woken","waking",
"helps","helped","helping","thanks","thanked","rests","rested","resting",
"breathes","breathed","breathing","washes","washed","dresses","dressed",
"lies","lay","lying","carries","carried","carrying",
"lifts","lifted","lifting","pushes","pushed","pulls","pulled",
"answers","answered","answering","replies","replied","replying",
"schedules","scheduled","scheduling","confirms","confirmed","reminds","reminded",
"explains","explained","explaining","listens","listened","listening"
];
/* urban mobility, accessibility, assistive technology, journalism */
const AREA = [
"accessibility","accessible","inaccessible","mobility","urban","city","sidewalk","sidewalks",
"ramp","ramps","tactile","paving","curb","crossing","crosswalk","pedestrian","pedestrians",
"traffic","parking","elevator","platform","step","steps","obstacle","obstacles",
"transport","transportation","public","transit","subway","train","terminal","station","route","fare",
"inclusion","inclusive","exclusion","barrier","barriers","adapted","adaptation",
"disability","disabilities","disabled","person","reduced","users",
"autonomy","independence","rights","law","laws","regulation","policy","policies",
"government","council","complaint","inspection","management",
"project","projects","construction","renovation","budget","deadline","timeline",
"reporting","article","articles","piece","interview","interviewed","source","sources",
"text","column","editorial","post","publication","newsroom","editing","editor","journalist","journalism",
"reader","readers","audience","reach","engagement","newsletter","site","portal","blog","link","links",
"company","partnership","partner","sponsorship","sponsor","proposal","contract","meeting","agenda",
"event","lecture","panel","debate","award","podcast","video","audio","caption","transcript",
"technology","assistive","communication","alternative","augmentative","equipment","software",
"tracker","tracking","gaze","keyboard","screen","cursor","click","blink","calibrate","calibration",
"voice","synthesized","synthesis","speech","typing","prediction","shortcut",
"sclerosis","lateral","amyotrophic","neurologist","physiotherapist","speech-language",
"therapist","occupational","nutritionist","diagnosis","treatment","progression","symptom",
"ventilator","ventilation","tracheostomy","suction","tube","gastrostomy","saturation","oxygen",
"research","study","association","institute","nonprofit","donation","donor","campaign","support","supporter",
"grateful","gratitude","regards","sincerely","cheers","congrats"
];
const WORDS = Array.from(new Set(
BASE.concat(VERBOS).concat(AREA)
.map(w => w.toLowerCase())
.filter(w => /^[a-z']+$/i.test(w))
));
const OUTER_ABC = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
const OUTER_SYM = ["0","1","2","3","4","5","6","7","8","9",".",",","?","!","-","'",":",";","(",")","@","/","+","=","%","\"","*"];
const SYM_PAGES = [["1","2","3","4","5","6"],["7","8","9","0",".",","],["?","!","-","'",":","%"],["@","/","(",")","\"",";"]];
/* Starter bigrams: what tends to come after what.
The user's own learning adds to this and gradually takes over. */
const SEED_NEXT = {
"«início»":{"i":8,"the":4,"can":4,"please":3,"yes":3,"no":3,"thank":3,"good":3,"my":2,"we":2,"it":2,"what":2,"call":2,"i'm":2,"let's":2,"hi":2},
"i":{"need":6,"want":6,"am":6,"have":4,"can":4,"feel":3,"think":3,"like":3,"will":2,"would":2,"can't":2,"don't":2},
"i'm":{"tired":4,"fine":3,"hungry":3,"thirsty":3,"in":3,"cold":2,"hot":2,"writing":2,"not":2},
"am":{"tired":4,"fine":3,"hungry":3,"thirsty":3,"in":3,"cold":2,"hot":2,"writing":2,"not":2},
"need":{"to":6,"help":4,"water":4,"the":3,"a":3,"rest":2},
"want":{"to":6,"water":3,"food":2,"the":2,"more":2},
"to":{"go":4,"eat":3,"sleep":3,"drink":3,"talk":3,"rest":2,"change":2,"write":2,"see":2,"the":2},
"can":{"you":6,"we":3,"i":3},
"can't":{"feel":2,"move":2,"sleep":2,"breathe":2},
"you":{"help":4,"please":3,"bring":3,"call":3,"come":2,"turn":2},
"thank":{"you":8},
"good":{"morning":6,"night":5,"afternoon":4,"idea":2},
"help":{"me":6,"please":4},
"call":{"the":5,"my":3,"a":2},
"the":{"nurse":4,"bathroom":3,"doctor":3,"pain":2,"light":2,"tv":2,"article":2,"city":2},
"in":{"pain":5,"bed":3,"the":3,"my":2},
"my":{"head":3,"back":3,"leg":3,"arm":2,"wife":2,"family":2,"eyes":2},
"change":{"position":5,"the":3,"channel":2},
"turn":{"on":4,"off":4,"the":3,"me":3},
"wait":{"a":4,"please":3},
"a":{"little":4,"lot":3,"bit":3,"moment":3},
"let":{"me":6},
"let's":{"talk":3,"go":3,"schedule":2},
"me":{"know":3,"up":2,"see":2,"water":2},
"it":{"is":5,"hurts":4},
"it's":{"good":2,"cold":2,"hot":2,"time":2},
"is":{"the":3,"not":3,"good":2},
"not":{"now":3,"yet":2,"good":2},
"assistive":{"technology":7},
"eye":{"tracking":5,"tracker":4},
"urban":{"mobility":6},
"public":{"transport":5,"transportation":4,"policy":3},
"lateral":{"sclerosis":7},
"amyotrophic":{"lateral":7},
"reduced":{"mobility":6},
"tactile":{"paving":6},
"we":{"can":3,"need":3,"talk":2,"schedule":2},
"what":{"do":3,"is":3,"about":2,"time":2}
};
/* Letter chaining — used only when the prefix matches no known word
(proper names, slang, acronyms). */
const CHAR_NEXT = {
a:"ntlrsdcmbgvpiykuwf", b:"eoalruiy", c:"oahektiruly", d:"eioaursy", e:"rsndaltcemvpxfiy",
f:"oiraeul", g:"ehoairlun", h:"eaiotursy", i:"ntsclomdvregfapk", j:"ouaei", k:"einsly", l:"eialoyudst",
m:"eaoiupsby", n:"gdteoicasuk", o:"nurftmwlopsdvicek", p:"eroalihu", q:"u", r:"eoaistdunmykcl",
s:"tehoiaupcmklnwy", t:"hoeiarustlywc", u:"rntslecpgmdbai", v:"eiao", w:"aihoenrs", x:"ptcaie",
y:"osetiam", z:"eaoi"
};
/* ================================================================
2. MEMÓRIA — vocabulário aprendido + encadeamento de palavras
================================================================ */
const K = {cfg:"tr2.cfg", learn:"tr2.learn", next:"tr2.next", text:"tr2.text", phr:"tr2.phr"};
const load = (k,d) => { try{ const v=JSON.parse(localStorage.getItem(k)); return v==null?d:v; }catch(e){ return d; } };
const save = (k,v) => { try{ localStorage.setItem(k, JSON.stringify(v)); }catch(e){} };
const today = () => Math.floor(Date.now()/86400000);
const strip = s => s.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/'/g,"").toLowerCase();
const HALF_LIFE = 75; /* dias: uma palavra sem uso perde metade do peso */
let LEARN = load(K.learn, {});
let NEXT = load(K.next, {});
/* migração do formato antigo (número puro) para {n, d} */
for(const w in LEARN){ if(typeof LEARN[w] === "number") LEARN[w] = {n:LEARN[w], d:today(), pin:0}; }
const BASE_SET = new Set(WORDS.map(strip));
let ALL = [], ALL_N = [], IDX = {};
function rebuild(){
const extra = Object.keys(LEARN).filter(w => !BASE_SET.has(strip(w)));
ALL = WORDS.concat(extra);
ALL_N = ALL.map(strip);
IDX = {}; ALL.forEach((w,i) => IDX[w] = i);
}
rebuild();
function used(w){
const e = LEARN[w];
if(!e) return 0;
return e.n * Math.pow(0.5, (today() - e.d) / HALF_LIFE);
}
/* peso final de uma palavra = frequência geral + o quanto ESTA pessoa usa */
function wWeight(i){
const base = i < WORDS.length ? 1/(i + 15) : 0.004;
return base + 0.05 * Math.min(used(ALL[i]), 40);
}
function okWord(w){ return /^(?:[ai]|[a-z][a-z']+)$/i.test(w); }
function learnWord(w){
w = (w||"").trim().toLowerCase().replace(/^[^a-z']+|[^a-z']+$/gi,"");
if(!okWord(w)) return null;
const e = LEARN[w] || {n:0, d:today(), pin:0};
e.n = e.n + 1; e.d = today();
LEARN[w] = e;
prune();
save(K.learn, LEARN);
if(!BASE_SET.has(strip(w)) && IDX[w] === undefined) rebuild();
return w;
}
function learnPair(prev, w){
if(!w) return;
const key = prev || "«início»";
const m = NEXT[key] || (NEXT[key] = {});
m[w] = (m[w] || 0) + 1;
/* mantém no máximo 24 continuações por palavra */
const ks = Object.keys(m);
if(ks.length > 24){ ks.sort((a,b)=>m[a]-m[b]); delete m[ks[0]]; }
save(K.next, NEXT);
}
/* poda pelo peso já com esquecimento, nunca apaga palavra fixada */
function prune(){
const ks = Object.keys(LEARN);
if(ks.length <= 3000) return;
ks.sort((a,b) => (LEARN[a].pin?9e9:used(a)) - (LEARN[b].pin?9e9:used(b)));
for(const k of ks.slice(0, 300)) delete LEARN[k];
rebuild();
}
/* ================================================================
3. ESTADO E PREDIÇÃO
================================================================ */
const DEF_CFG = {dwell:false, dwellMs:900, scale:0.92, fs:1, order:"alpha", innerN:0,
outer:true, hc:false, light:false, rate:0.95, voice:"", autoSpeak:true, theme:"blue",
layout:"wheel"};
const THEMES = ["blue","red","green","purple","amber"];
let cfg = Object.assign({}, DEF_CFG, load(K.cfg, {}));
let text = load(K.text, "") || "";
let caret = text.length; /* posição de escrita — dá para voltar e corrigir no meio */
let page = 0, mode = "abc", paused = false, fixMode = false;
/* roda ou grade tradicional — a URL manda (para a comparação), senão o ajuste salvo */
let LAYOUT = (function(){
try{ const p = new URLSearchParams(location.search).get("layout");
if(p === "qwerty" || p === "wheel") return p; }catch(e){}
return cfg.layout || "wheel";
})();
/* modo "copie este trecho": a página Classics abre o teclado com ?copy=... */
const TARGET = (function(){ try{ return new URLSearchParams(location.search).get("copy") || ""; }
catch(e){ return ""; } })();
let copyT0 = 0, copySel = 0, copyDone = false;
const undoStack = [];
function pushUndo(){ undoStack.push({t:text, c:caret}); if(undoStack.length > 60) undoStack.shift(); }
function prefix(){ const m = text.slice(0, caret).match(/[^\s]+$/); return m ? m[0] : ""; }
function prevWord(){
const before = text.slice(0, caret - prefix().length);
const m = before.match(/([^\s]+)\s+$/);
if(!m) return "«início»";
const raw = m[1];
if(/[.!?…]$/.test(raw)) return "«início»";
const w = raw.toLowerCase().replace(/^[^a-z']+|[^a-z']+$/gi,"");
return w || "«início»";
}
function nextMap(){
const k = prevWord();
const seed = SEED_NEXT[k] || {}, learned = NEXT[k] || {};
const m = {};
for(const w in seed) m[w] = seed[w] * 0.6;
for(const w in learned) m[w] = (m[w] || 0) + learned[w] * 1.6; /* o aprendido pesa mais */
return m;
}
/* --- candidatas a palavra --- */
function suggestions(limit){
const p = strip(prefix()), nx = nextMap(), out = [];
const cand = [];
for(let i = 0; i < ALL_N.length; i++){
const w = ALL_N[i];
if(p){ if(!(w.startsWith(p) && w.length > p.length)) continue; }
let s = wWeight(i);
const b = nx[ALL[i]] || 0;
if(b) s += 0.22 * Math.min(b, 25);
else if(!p) s *= 0.30; /* sem prefixo, quem manda é o encadeamento */
cand.push([ALL[i], s]);
}
cand.sort((a,b) => b[1] - a[1]);
const seen = new Set();
for(const [w] of cand){
if(seen.has(strip(w))) continue;
seen.add(strip(w)); out.push(w);
if(out.length >= limit) break;
}
return out;
}
/* --- critério das letras do anel interno --- */
function letterScores(){
const p = strip(prefix()), nx = nextMap(), score = {};
for(let i = 0; i < ALL_N.length; i++){
const w = ALL_N[i];
if(w.length <= p.length || !w.startsWith(p)) continue;
let s = wWeight(i);
const b = nx[ALL[i]] || 0;
if(b) s += 0.22 * Math.min(b, 25);
const c = w[p.length];
score[c] = (score[c] || 0) + s;
}
return score;
}
function charFallback(){
const p = strip(prefix());
const last = p ? p[p.length-1] : "";
const seq = (CHAR_NEXT[last] || "etaoinsrhldcumfpgwybvkxjqz").split("");
const seen = new Set(), out = [];
for(const c of seq.concat("etaoinsrhldcumfpgwybvkxjqz".split(""))){
if(!seen.has(c) && OUTER_ABC.includes(c)){ seen.add(c); out.push(c); }
}
return out;
}
function autoN(sc, ranked){
const tot = ranked.reduce((s,l) => s + sc[l], 0) || 1;
let acc = 0, n = 0;
for(const l of ranked){ acc += sc[l]; n++; if(acc/tot >= 0.92) break; }
return Math.max(4, Math.min(8, n));
}
const cmpAlpha = (a,b) => a.localeCompare(b, "en");
function pages(){
if(mode === "sym") return SYM_PAGES;
const sc = letterScores();
let ranked = Object.keys(sc).sort((a,b) => sc[b] - sc[a]);
let fallback = false;
if(!ranked.length){ ranked = charFallback(); fallback = true; }
const n = cfg.innerN || (fallback ? 6 : autoN(sc, ranked));
let first = ranked.slice(0, n);
const chosen = new Set(first);
/* garante ao menos uma vogal na primeira página */
if(!first.some(c => "aeiou".includes(c))){
const v = ranked.find(c => "aeiou".includes(c)) || "a";
first[first.length-1] = v; chosen.clear(); first.forEach(c => chosen.add(c));
}
if(cfg.order === "alpha") first = first.slice().sort(cmpAlpha);
/* páginas seguintes: o que sobrou, em ordem alfabética — previsível */
const rest = OUTER_ABC.filter(c => !chosen.has(c));
const ps = [first];
for(let i = 0; i < rest.length; i += n) ps.push(rest.slice(i, i + n));
return ps;
}
/* ================================================================
4. SELEÇÃO: clique, permanência (dwell) e trava anti-repique
================================================================ */
const COOLDOWN = 450;
let lockedUntil = 0, dwellTimer = null, dwellEl = null, justFired = null;
let mx = -1, my = -1;
addEventListener("mousemove", e => { mx = e.clientX; my = e.clientY; }, {passive:true});
function paint(el, on){
const f = el.querySelector && el.querySelector(".fill");
if(f){
f.style.transition = on ? ("width " + cfg.dwellMs + "ms linear") : "none";
if(!on) f.style.width = "";
}else{
el.style.transition = on ? ("fill " + cfg.dwellMs + "ms linear") : "";
}
el.classList.toggle("dwelling", !!on);
}
function stopDwell(){
if(dwellTimer){ clearTimeout(dwellTimer); dwellTimer = null; }
if(dwellEl){ paint(dwellEl, false); dwellEl = null; }
}
function startDwell(el){
if(!cfg.dwell || paused || !el.__fn) return;
if(el === justFired) return;
if(performance.now() < lockedUntil) return;
stopDwell();
dwellEl = el; paint(el, true);
dwellTimer = setTimeout(() => { dwellTimer = null; fire(el); }, cfg.dwellMs);
}
function flash(el){
el.style.transition = "none";
el.classList.add("flash");
setTimeout(() => el.classList.remove("flash"), 150);
}
function fire(el){
const now = performance.now();
if(now < lockedUntil || paused) return;
lockedUntil = now + COOLDOWN;
if(TARGET && !copyDone){ if(!copyT0) copyT0 = now; copySel++; }
justFired = el;
stopDwell();
flash(el);
document.body.classList.add("locked");
setTimeout(() => { document.body.classList.remove("locked"); rearm(); }, COOLDOWN);
el.__fn();
}
/* depois de redesenhar a roda o elemento sob o cursor é outro:
rearma a permanência sozinho, senão o dwell "trava" */
function rearm(){
if(!cfg.dwell || paused || mx < 0) return;
const el = document.elementFromPoint(mx, my);
const t = el && el.closest ? (el.__fn ? el : el.closest("[data-tgt]")) : null;
const target = (el && el.__fn) ? el : (t && t.__fn ? t : null);
justFired = null;
if(target) startDwell(target);
}
function bind(el, fn){
el.__fn = fn;
el.setAttribute("data-tgt","1");
el.addEventListener("click", e => { e.preventDefault(); fire(el); });
el.addEventListener("mouseenter", () => startDwell(el));
el.addEventListener("mouseleave", () => { if(justFired === el) justFired = null; stopDwell(); });
return el;
}
/* ================================================================
5. DESENHO DA RODA
centro 425,425
0..88 zona de descanso — não faz nada, pode olhar à vontade
104..196 funções (espaço, falar, trocar, apagar, desfazer)
208..302 letras prováveis
314..408 alfabeto completo
================================================================ */
const svg = document.getElementById("wheel");
const CX = 425, CY = 425, REST = 88;
const H0 = 104, H1 = 196, I0 = 208, I1 = 302, O0 = 314, O1 = 408;
function polar(r, a){ const t = (a - 90) * Math.PI/180; return [CX + r*Math.cos(t), CY + r*Math.sin(t)]; }
function ring(r0, r1, a0, a1){
const big = (a1 - a0) > 180 ? 1 : 0;
const [x0,y0] = polar(r1,a0), [x1,y1] = polar(r1,a1), [x2,y2] = polar(r0,a1), [x3,y3] = polar(r0,a0);
return `M${x0},${y0} A${r1},${r1} 0 ${big} 1 ${x1},${y1} L${x2},${y2} A${r0},${r0} 0 ${big} 0 ${x3},${y3} Z`;
}
function E(tag, at){ const e = document.createElementNS("http://www.w3.org/2000/svg", tag); for(const k in at) e.setAttribute(k, at[k]); return e; }
/* ---- layout tradicional: as mesmas teclas, na grade de sempre ----
Existe para comparação: mesma predição, mesma voz, mesmo tudo — muda só
a distância que o cursor precisa percorrer. */
const GRID_ABC = [
["q","w","e","r","t","y","u","i","o","p"],
["a","s","d","f","g","h","j","k","l"],
["z","x","c","v","b","n","m",",","."]
];
const GRID_SYM = [
["1","2","3","4","5","6","7","8","9","0"],
[".",",","?","!","-","'","\"",":",";"],
["(",")","@","/","+","=","%","*","…"]
];
function drawGrid(){
const rows = (mode === "abc") ? GRID_ABC : GRID_SYM;
const GAP = 8, kw = (1000 - 40 - 9*GAP) / 10, kh = 118, rowGap = 10;
let y = (560 - (4*kh + 3*rowGap)) / 2;
const key = (x, w, ch, fn, cls, sub, gw) => {
const r = E("rect", {x:x, y:y, width:w, height:kh, rx:14, class:"key" + (cls || "")});
if(gw) r.setAttribute("data-gw", gw);
bind(r, fn);
svg.appendChild(r);
if(sub){
const t1 = E("text", {x:x + w/2, y:y + kh/2 - 12, class:"lbl", "font-size":"34"}); t1.textContent = ch;
const t2 = E("text", {x:x + w/2, y:y + kh/2 + 20, class:"lbl sub", "font-size":"19"}); t2.textContent = sub;
svg.appendChild(t1); svg.appendChild(t2);
}else{
const t = E("text", {x:x + w/2, y:y + kh/2, class:"lbl", "font-size":"46"});
t.textContent = (mode === "abc") ? ch.toUpperCase() : ch;
svg.appendChild(t);
}
};
rows.forEach(r => {
let x = (1000 - (r.length*kw + (r.length-1)*GAP)) / 2;
r.forEach(ch => { key(x, kw, ch, () => typeChar(ch), "", "", ch); x += kw + GAP; });
y += kh + rowGap;
});
const FN = [
{ic:"", lb:"space", fn:doSpace, span:4, gw:" "},
{ic:"⌫", lb:"letter", fn:doBack, span:2, danger:1},
{ic:"⌫⌫", lb:"word", fn:doBackWord, span:2, danger:1},
{ic:"⤺", lb:"undo", fn:doUndo, span:1},
{ic:"🔊", lb:"speak", fn:doSpeak, span:1}
];
let x = 20;
FN.forEach(q => {
const w = q.span*kw + (q.span - 1)*GAP;
key(x, w, q.ic || q.lb, q.fn, " fnkey" + (q.danger ? " danger" : ""), q.ic ? q.lb : "", q.gw);
x += w + GAP;
});
}
function drawWheel(){
svg.innerHTML = "";
if(LAYOUT === "qwerty"){ drawGrid(); return; }
const ps = pages();
if(page >= ps.length) page = 0;
const letters = ps[page] || [];
/* anel externo — alfabeto inteiro, posição fixa para sempre */
if(cfg.outer){
const chars = (mode === "abc") ? OUTER_ABC : OUTER_SYM;
const g = E("g", {class:"outer"});
const step = 360 / chars.length;
chars.forEach((ch,i) => {
const a0 = i*step - step/2;
const p = E("path", {d: ring(O0, O1, a0, a0+step), class:"wedge", "data-gw": ch});
bind(p, () => typeChar(ch));
g.appendChild(p);
const [tx,ty] = polar((O0+O1)/2, a0 + step/2);
const t = E("text", {x:tx, y:ty, class:"lbl outerLbl", "font-size":"42"});
t.textContent = (mode === "abc") ? ch.toUpperCase() : ch;
g.appendChild(t);
});
svg.appendChild(g);
}
/* anel interno — letras prováveis, quantidade adaptativa */
const n = Math.max(1, letters.length);
const step = 360 / n;
letters.forEach((ch,i) => {
const a0 = i*step - step/2;
const p = E("path", {d: ring(I0, I1, a0, a0+step), class:"wedge", "data-gw": ch});
bind(p, () => typeChar(ch));
svg.appendChild(p);
const [tx,ty] = polar((I0+I1)/2, a0 + step/2);
const t = E("text", {x:tx, y:ty, class:"lbl", "font-size":"66"});
t.textContent = (mode === "abc") ? ch.toUpperCase() : ch;
svg.appendChild(t);
});
/* anel de funções — 6 setores, os dois de apagar longe do espaço */
const FN = [
{ic:"", lb:"space", fn:doSpace, gw:" "},
{ic:"🔊", lb:"speak", fn:doSpeak},
{ic:"↻", lb:"more", fn:doSwap},
{ic:"⌫", lb:"letter", fn:doBack, danger:1},
{ic:"⌫⌫", lb:"word", fn:doBackWord, danger:1},
{ic:"⤺", lb:"undo", fn:doUndo}
];
FN.forEach((q,i) => {
const a0 = i*60 - 30;
const p = E("path", {d: ring(H0, H1, a0, a0+60), class:"quad" + (q.danger ? " danger" : "")});
if(q.gw) p.setAttribute("data-gw", q.gw);
bind(p, q.fn);
svg.appendChild(p);
const [ix,iy] = polar((H0+H1)/2, a0 + 30);
if(q.ic){
const t1 = E("text", {x:ix, y:iy-13, class:"lbl", "font-size":"34"}); t1.textContent = q.ic;
const t2 = E("text", {x:ix, y:iy+21, class:"lbl sub", "font-size":"19"}); t2.textContent = q.lb;
svg.appendChild(t1); svg.appendChild(t2);
}else{
const t = E("text", {x:ix, y:iy, class:"lbl", "font-size":"27"}); t.textContent = q.lb;
svg.appendChild(t);
}
});
/* arco do logo: também diz em que página o anel interno está */
if(ps.length > 1){
const R = (cfg.outer ? O1 : I1) + 12;
const span = 360/ps.length, aa = page*span + 3, ab = aa + span - 6;
const [ax0,ay0] = polar(R, aa), [ax1,ay1] = polar(R, ab);
const big = (span - 6) > 180 ? 1 : 0;
svg.appendChild(E("path", {d:`M${ax0},${ay0} A${R},${R} 0 ${big} 1 ${ax1},${ay1}`, class:"pageArc"}));
}
/* zona de descanso — inerte de propósito, com o miolo do logo */
svg.appendChild(E("circle", {cx:CX, cy:CY, r:REST, id:"restZone"}));
svg.appendChild(E("circle", {cx:CX, cy:CY, r:REST*0.62, id:"restDot"}));
const r1 = E("text", {x:CX, y:CY-16, class:"restTxt", "font-size":"22"});
r1.textContent = "rest";
const r2 = E("text", {x:CX, y:CY+16, class:"restTxt", "font-size":"26"});
r2.textContent = ps.length > 1 ? (page+1) + "/" + ps.length : "•";
svg.appendChild(r1); svg.appendChild(r2);
}
/* ================================================================
6. AÇÕES
================================================================ */
const out = document.getElementById("out");
const sugRow = document.getElementById("sugRow");
const statusEl = document.getElementById("status");
function say(msg, ms){ statusEl.textContent = msg; clearTimeout(say._t); say._t = setTimeout(() => statusEl.textContent = "", ms || 3500); }
function ins(s){ text = text.slice(0, caret) + s + text.slice(caret); caret += s.length; }
function typeChar(ch){
pushUndo(); ins(ch); page = 0; render();
/* numa conversa, esperar a mensagem inteira mata a troca:
ao fechar a frase, ela já sai falada */
if(cfg.autoSpeak && /[.!?…]/.test(ch)) speak(lastSentence());
}
function lastSentence(){
const b = text.slice(0, caret);
const m = b.match(/[^.!?…]*[.!?…]\s*$/);
return (m ? m[0] : b).trim();
}
function moveWord(dir){
if(dir < 0){
const m = text.slice(0, caret).match(/\S*\s*$/);
caret = Math.max(0, caret - Math.max(1, m ? m[0].length : 1));
}else{
const m = text.slice(caret).match(/^\s*\S*/);
caret = Math.min(text.length, caret + Math.max(1, m ? m[0].length : 1));
}
page = 0; render();
}
/* chamador de atenção: dois toques curtos e um aviso falado.
Sem isso o interlocutor desiste e vai embora antes da frase sair. */
function attention(){
try{
const AC = window.AudioContext || window.webkitAudioContext;
const ctx = new AC(), t0 = ctx.currentTime;
[880, 1245].forEach((f,i) => {
const o = ctx.createOscillator(), g = ctx.createGain(), t = t0 + i*0.24;
o.type = "sine"; o.frequency.value = f;
g.gain.setValueAtTime(0.0001, t);
g.gain.exponentialRampToValueAtTime(0.30, t + 0.03);
g.gain.exponentialRampToValueAtTime(0.0001, t + 0.22);
o.connect(g); g.connect(ctx.destination);
o.start(t); o.stop(t + 0.26);
});
}catch(e){}
setTimeout(() => speak("Wait — I'm typing."), 700);
say("calling attention…");
}
/* modo conversa: o texto grande, para quem está do outro lado ler */
function openTalk(){
const t = document.getElementById("talkText");
const v = text.trim();
t.textContent = v || "what you write shows up here, large, for the other person to read";
t.classList.toggle("vazio", !v);
document.getElementById("talkOverlay").classList.add("on");
if(v) speak(v);
}
function acceptWord(w){
pushUndo();
const p = prefix(), prev = prevWord();
text = text.slice(0, caret - p.length) + w + " " + text.slice(caret);
caret = caret - p.length + w.length + 1;
learnWord(w); learnPair(prev, w.toLowerCase());