-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
892 lines (802 loc) · 34.9 KB
/
index.html
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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>タイピングゲーム</title>
<style>
.box {
vertical-align: middle;
width: 800px;
height: 600px;
background-color: white;
font-size: 4rem;
text-align: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
.box2 {
background-color:#c0c0c0;
font-size: 6rem;
color: rgb(121, 82, 82);
text-align: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
.box3{
width: 100px;
height: 50px;
position: absolute;
margin: auto;
right:0;
left:0;
bottom:80px;
}
#typed {
color: red;
}
#typed_Japanese{
color:red;
}
#botan {
width: 100px;
height: 50px;
}
#botan:hover{
background-color: #d0d0d0;
}
</style>
</head>
<body>
<div class="box2">
タイピングゲーム
<span id="count"></span>/30
</div>
<div class="box">
<span id="description1">1.次へを押し、表示される単語をタイピングする</span><br />
<span id="description2">2.全部で30問あります</span><br />
<span id= "typed_Japanese"></span><span id="JapaneseWord">3.次へを押したら始まる</span><br />
<span id="typed"></span><span id="untyped"></span><br />
</div>
<div class ="box3">
<input
name="company"
id="botan"
type="button"
value="次へ"
onclick="buttonClick()"
/>
</div>
<script>
description1 = "1.表示される単語をタイピングする";
description2 = "2.全部で30問あります";
JapaneseWord = "3.次へを押したら始まる";
var mondaibun;
var typeSTART; //タイマー
var typeEND;
var stage = 0; //画面表示
var correct = 0; //入力結果
var miss = 0;
var mCount=0; //不一致文字カウント
const word3 = [
"しけん","しらが","いやし","リンゴ","バナナ","きずな","ふじみ","あたま","きらら","すなお",
"のどか","むかし","ちこく","つがい","マニア","かいり","うずら","メジロ","カモメ","ひよこ",
"ポテト","ワイン","スズメ","ライム","メロン","セロリ","かつお","あなご","あわび","たかな",
"ざいす","ダイス","デフレ","カエル","ねずみ","みかん","カラス","たらこ","メダカ","ネット",
];
const word4 = [
"もてなす","ばけもの","いちねん","せんきょ","きんぎょ","ゆうせい","ふっかつ","ちゃわん","ふくしま","さかだち",
"たいふう","たいへん","オモチャ","しゃしん","シンボル","ロンドン","イタリア","りょこう","スパイス","コンドル",
"しまうま","すずむし","そろばん","ぜいきん","たけのこ","なわとび","くだもの","やきいも","みかづき","せいぶつ",
"にっこう","きまぐれ","ほろよい","にんじん","のんびり","まったり","へべれけ","ファイブ","ちゃんこ","しつもん",
];
const word5 = [
"おもてなし","こころざし","おにやんま","しょうかい","とうがらし","ひがんばな","バスケット","きつねそば","めくらまし","としょかん",
"かんなづき","おおさかふ","じどうしゃ","じてんしゃ","おちゃかい","ジャケット","カンニング","こいのぼり","しゅっさん","カブトムシ",
"カメレオン","エネルギー","オルゴール","きりぎりす","シャンプー","メロンパン","ランドセル","チャンネル","かんがるー","たからばこ",
"うでどけい","おとしだま","ラインがわ","コミックス","かじゅえん","ナトリウム","ホタテがい","ユニコーン","ソクラテス","バイキング",
];
const hira1 = [
"あ","い","う","え","お","か","き","く","け","こ","さ","し","す","せ","そ","た","ち","つ","て","と",
"な","に","ぬ","ね","の","は","ひ","ふ","へ","ほ","ま","み","む","め","も",
"や","ゆ","よ",
"ら","り","る","れ","ろ","わ","うぃ","うぇ","を","ん","ゔ",
"が","ぎ","ぐ","げ","ご","ざ","じ","ず","ぜ","ぞ","だ","ぢ","づ","で","ど","ば","び","ぶ","べ","ぼ",
"ぱ","ぴ","ぷ","ぺ","ぽ","ー","ぁ","ぃ","ぅ","ぇ","ぉ","ゃ","ゅ","ょ","っ",
];
const kana1=[
"ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ","タ","チ","ツ","テ","ト",
"ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ","ミ","ム","メ","モ",
"ヤ","ユ","ヨ",
"ラ","リ","ル","レ","ロ","ワ","ウィ","ウェ","ヲ","ン","ヴ",
"ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ",
"パ","ピ","プ","ペ","ポ","ー","ァ","ィ","ゥ","ェ","ォ","ャ","ュ","ョ","ッ",
];
const alphabet1 = [
"a","i","u","e","o","ka","ki","ku","ke","ko","sa","si","su","se","so","ta","ti","tu","te","to",
"na","ni","nu","ne","no","ha","hi","hu","he","ho","ma","mi","mu","me","mo",
"ya","yu","yo",
"ra","ri","ru","re","ro","wa","wi","we","wo","n","vu",
"ga","gi","gu","ge","go","za","zi","zu","ze","zo","da","di","du","de","do","ba","bi","bu","be","bo",
"pa","pi","pu","pe","po","-","la","li","lu","le","lo","lya","lyu","lyo","ltu",
];
const hira2 = [
"きゃ","きぃ","きゅ","きぇ","きょ","しゃ","しぃ","しゅ","しぇ","しょ",
"ちゃ","ちぃ","ちゅ","ちぇ","ちょ","にゃ","にぃ","にゅ","にぇ","にょ","ひゃ","ひぃ","ひゅ","ひぇ","ひょ",
"みゃ","みぃ","みゅ","みぇ","みょ","りゃ","りぃ","りゅ","りぇ","りょ","ふぁ","ふぃ","ふぇ","ふぉ",
"ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ","じゃ","じぃ","じゅ","じぇ","じょ",
"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ","びゃ","びぃ","びゅ","びぇ","びょ","ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ",
"ヴァ","ヴィ","ヴェ","ヴォ",
];
const kana2 = [
"キャ","キィ","キュ","キェ","キョ","シャ","シィ","シュ","シェ","ショ",
"チャ","チィ","チュ","チェ","チョ","ニャ","ニィ","ニュ","ニェ","ニョ","ヒャ","ヒィ","ヒュ","ヒェ","ヒョ",
"ミャ","ミィ","ミュ","ミェ","ミョ","リャ","リィ","リュ","リェ","リョ","ファ","フィ","フェ","フォ",
"ギャ","ギィ","ギュ","ギェ","ギョ","ジャ","ジィ","ジュ","ジェ","ジョ",
"ヂャ","ヂィ","ヂュ","ヂェ","ヂョ","ビャ","ビィ","ビュ","ビェ","ビョ","ピャ","ピィ","ピュ","ピェ","ピョ",
"ヴァ","ヴィ","ヴェ","ヴォ",
]
const alphabet2 = [
"kya","kyi","kyu","kye","kyo","sya","syi","syu","sye","syo",
"tya","tyi","tyu","tye","tyo","nya","nyi","nyu","nye","nyo","hya","hyi","hyu","hye","hyo",
"mya","myi","myu","mye","myo","rya","ryi","ryu","rye","ryo","fa","fi","fe","fo",
"gya","gyi","gyu","gye","gyo","zya","zyi","zyu","zye","zyo",
"dya","dyi","dyu","dye","dyo","bya","byi","byu","bye","byo","pya","pyi","pyu","pye","pyo",
];
const ReHira1=["あ","い","う","え","お","ー","ん",]; //日本語表記を赤くするための配列
const Rekana1=["ア","イ","ウ","エ","オ","ー","ン",];
const ReHira2=[
"か","き","く","け","こ","さ","し","す","せ","そ","た","ち","つ","て","と",
"な","に","ぬ","ね","の","は","ひ","ふ","へ","ほ","ま","み","む","め","も",
"や","ゆ","よ",
"ら","り","る","れ","ろ","わ","うぃ","うぇ","を","ゔ",
"が","ぎ","ぐ","げ","ご","ざ","じ","ず","ぜ","ぞ","だ","ぢ","づ","で","ど","ば","び","ぶ","べ","ぼ",
"ぱ","ぴ","ぷ","ぺ","ぽ","ぁ","ぃ","ぅ","ぇ","ぉ","ヴァ","ヴィ","ヴェ","ヴォ",
"ふぁ","ふぃ","ふぇ","ふぉ","ふ","ぁ","ぃ","ぅ","ぇ","ぉ","じ","か","し","く","せ","こ","じゃ","じゅ","じょ",];
const Rekana2=[
"カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ","タ","チ","ツ","テ","ト",
"ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ","ミ","ム","メ","モ",
"ヤ","ユ","ヨ",
"ラ","リ","ル","レ","ロ","ワ","ウィ","ウェ","ヲ","ヴ",
"ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ",
"パ","ピ","プ","ペ","ポ","ァ","ィ","ゥ","ェ","ォ","ヴァ","ヴィ","ヴェ","ヴォ",
"ファ","フィ","フェ","フォ","フ","ァ","ィ","ゥ","ェ","ォ","ジ","カ","シ","ク","セ","コ","ジャ","ジュ","ジョ",
];
const ReHira3=[
"ゃ","ゅ","ょ","っ",
"きゃ","きぃ","きゅ","きぇ","きょ","しゃ","しぃ","しゅ","しぇ","しょ",
"ちゃ","ちぃ","ちゅ","ちぇ","ちょ","にゃ","にぃ","にゅ","にぇ","にょ","ひゃ","ひぃ","ひゅ","ひぇ","ひょ",
"みゃ","みぃ","みゅ","みぇ","みょ","りゃ","りぃ","りゅ","りぇ","りょ",
"ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ","じゃ","じぃ","じゅ","じぇ","じょ",
"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ","びゃ","びぃ","びゅ","びぇ","びょ","ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ",
"ち","ゃ","ゅ","ょ","っ","っ","ちゃ","ちぃ","ちゅ","ちぇ","ちょ","つ","し",];
const Rekana3=[
"ャ","ュ","ョ","ッ",
"キャ","キィ","キュ","キェ","キョ","シャ","シィ","シュ","シェ","ショ",
"チャ","チィ","チュ","チェ","チョ","ニャ","ニィ","ニュ","ニェ","ニョ","ヒャ","ヒィ","ヒュ","ヒェ","ヒョ",
"ミャ","ミィ","ミュ","ミェ","ミョ","リャ","リィ","リュ","リェ","リョ",
"ギャ","ギィ","ギュ","ギェ","ギョ","ジャ","ジィ","ジュ","ジェ","ジョ",
"ヂャ","ヂィ","ヂュ","ヂェ","ヂョ","ビャ","ビィ","ビュ","ビェ","ビョ","ピャ","ピィ","ピュ","ピェ","ピョ",
"チ","ャ","ュ","ョ","ッ","ッ","チャ","チィ","チュ","チェ","チョ","ツ","シ",
];
const reAlphabet1=["a","i","u","e","o","-","n",];
const reAlphabet2=[
"ka","ki","ku","ke","ko","sa","si","su","se","so","ta","ti","tu","te","to",
"na","ni","nu","ne","no","ha","hi","hu","he","ho","ma","mi","mu","me","mo",
"ya","yu","yo",
"ra","ri","ru","re","ro","wa","wi","we","wo","vu",
"ga","gi","gu","ge","go","za","zi","zu","ze","zo","da","di","du","de","do","ba","bi","bu","be","bo",
"pa","pi","pu","pe","po","la","li","lu","le","lo","va","vi","ve","vo",
"fa","fi","fe","fo","fu","xa","xi","xu","xe","xo","ji","ca","ci","cu","ce","co","ja","ju","jo",
]
const reAlphabet3=[
"lya","lyu","lyo","ltu",
"kya","kyi","kyu","kye","kyo","sya","syi","syu","sye","syo",
"tya","tyi","tyu","tye","tyo","nya","nyi","nyu","nye","nyo","hya","hyi","hyu","hye","hyo",
"mya","myi","myu","mye","myo","rya","ryi","ryu","rye","ryo",
"gya","gyi","gyu","gye","gyo","zya","zyi","zyu","zye","zyo",
"dya","dyi","dyu","dye","dyo","bya","byi","byu","bye","byo","pya","pyi","pyu","pye","pyo",
"chi","xya","xyu","xyo","xtu","xtu","cya","cyi","cyu","cye","cyo","tsu","shi",
];
const simple2 =["ti","hu","la","li","lu","le","lo","zi","ka","si","ku","se","ko",]; //左 1文字で変わる二文字
const another2=["chi","fu","xa","xi","xu","xe","xo","ji","ca","ci","cu","ce","co",];
const simple3 =["lya","lyu","lyo","ltu","zya","zyu","zyo","ltu","tya","tyi","tyu","tye","tyo",]; //左 1文字で変わる三文字
const another3=["xya","xyu","xyo","xtu","ja","ju","jo","xtu","cya","cyi","cyu","cye","cyo",];
const vowel=["k","s","t","n","h","m","r","g","z","d","b","p",];//母音
const consonant=["a","i","u","e","o",]; //子音
const change= ["ya","yi","yu","ye","yo",];
const SmallYLine=["lya","li","lyu","le","lyo",]; //小さい や行
const overlap=[];
var music = new Audio('type-sound.mp3');
const typedField = document.getElementById("typed");
const untypedField = document.getElementById("untyped");
const wordField = document.getElementById("JapaneseWord");
const countField = document.getElementById("count");
const description1Field = document.getElementById("description1");
const description2Field = document.getElementById("description2");
const typed_JapaneseField = document.getElementById("typed_Japanese");
typed = "";
untyped = "";
JapaneseWord = "";
var count = "";
var muzukashii=3;
var Rcount=0;
//画面表示の変更
function buttonClick() {
if (stage === 0) { //stage0
stage = 1;
reset();
next();
updateTextField();
typeSTART = new Date();
} else if (stage === 1) { //stage1
finish();
updateTextField();
} else if (stage === 2) { //stage2
count="";
description1 = "1.次へを押し、表示される単語をタイピングする";
description2 = "2.全部で30問あります";
typed_Japanese="";
JapaneseWord = "3.次へを押したら始まる";
untyped = "";
stage = 0;
updateTextField();
}
}
function sleep(waitMsec) {
var startMsec = new Date(); //指定ミリ秒間だけループさせる(CPUは常にビジー状態)
while (new Date() - startMsec < waitMsec);
}
function reset(){
overlap.length=0;
description1 = "";
description2 = "";
count = 1;
correct = 0;
miss = 0;
total = 0;
average=0;
MissAnswerRate=0;
CorrectAnswerRate=0;
}
//終わった時
function finish() {
typed_Japanese="";
typeEND = new Date();
var keika = typeEND - typeSTART; //タイムの計算
var sec = Math.floor(keika / 1000);
var msec = keika % 1000;
sec2=sec; //sec2いったん置いとく
var min = Math.floor(sec / 60);
sec = sec % 60;
var total = miss+correct; //確率の計算に必要
if(correct==0){
CorrectAnswerRate=0;
avarege = 0; //平均キータイプ数
}else if(miss==0){
CorrectAnswerRate=100;
average=Math.round(correct/sec2*10)/10; //平均キータイプ数
}else{
MissAnswerRate = Math.round(miss/total*10000)/10000; //正タイプ率
CorrectAnswerRate =Math.round((1 - MissAnswerRate)*10000)/10000;
CorrectAnswerRate =CorrectAnswerRate*100;
CorrectAnswerRate = Math.round(CorrectAnswerRate*100)/100;
average=Math.round(correct/sec2*10)/10; //平均キータイプ数
}
var AverageDot = String(average);
if(AverageDot.substring(1,2)!=="."){
AverageDot +=".0"
}
description1 = "結果発表";
description2 = "正タイプ率:" + CorrectAnswerRate+ " %";
JapaneseWord = "平均キータイプ数:" + AverageDot + "回/秒";
typed = " ";
untyped = "タイム:" + min + "分" + sec + "秒" + msec;
stage = 2;
}
//乱数
function randomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
//画面の表示
function updateTextField() {
typedField.textContent = typed;
untypedField.textContent = untyped;
wordField.textContent = JapaneseWord;
countField.textContent = count;
description1Field.textContent = description1;
description2Field.textContent = description2;
typed_JapaneseField.textContent = typed_Japanese;
}
//次の問題を決める
function next() {
for(;;){
var idx=randomInt(word3.length);
if (10 >= count) {
JapaneseWord = word3[idx]; //3文字の単語
} else if (20 >= count) {
JapaneseWord = word4[idx]; //4文字の単語
} else if (30 >= count) {
JapaneseWord = word5[idx]; //5文字の単語
}
for(i=0;i<overlap.length;i++){ //一回でた文字を出さないようにする
if(JapaneseWord!==overlap[i]){
mCount +=1;
}
}
if(mCount===overlap.length){
overlap.push(JapaneseWord);
seisei();
mCount=0;
return;
}
mCount=0;
}
}
function seisei(){ //文字をローマ字の文字列に変化
mondaibun=JapaneseWord;
if(mondaibun===JapaneseWord){
}
var stopsan=untyped;
for(var j = 0; j < 5; j++){ //最大5文字
stopsan=untyped;
if(mondaibun!==""){
if("っ"===mondaibun.substring(0,1)){ //1文字目が「"っ"+hira2」だった時の処理
for(var i = 0; i < hira2.length; i++){
if(hira2[i]===mondaibun.substring(1, 3)){
untyped += alphabet2[i].substring(0,1)+alphabet2[i];
mondaibun = mondaibun.substring(3);
i= 200;
}
}
if(stopsan===untyped){
for(var i = 0; i < hira1.length; i++){ //1文字目が「っ」 +hira1」だった時の処理
if(hira1[i]===mondaibun.substring(1, 2)){
untyped += alphabet1[i].substring(0,1)+alphabet1[i];
mondaibun = mondaibun.substring(2);
i= 200;
}
}
}
}
if(stopsan===untyped){
for(var i = 0; i < hira2.length; i++){ //「きゃ」などの2文字
if(hira2[i]===mondaibun.substring(0, 2)){
untyped += alphabet2[i];
mondaibun = mondaibun.substring(2);
i= 200;
}
}
}
if(stopsan===untyped){
for(var i = 0; i < hira1.length; i++){
if(hira1[i]===mondaibun.substring(0, 1)){ //1文字
untyped += alphabet1[i];
mondaibun = mondaibun.substring(1);
i= 200;
}
}
}
if("ッ"===mondaibun.substring(0,1)){ //1文字目が「"っ"+hira2」だった時の処理
if(stopsan===untyped){
for(var i = 0; i < kana2.length; i++){
if(kana2[i]===mondaibun.substring(1, 3)){
untyped += alphabet2[i].substring(0,1)+alphabet2[i];
mondaibun = mondaibun.substring(3);
i= 200;
}
}
}
if(stopsan===untyped){
for(var i = 0; i < kana1.length; i++){ //1文字目が「っ」または「ッ」 +hira1」だった時の処理
if(kana1[i]===mondaibun.substring(1, 2)){
untyped += alphabet1[i].substring(0,1)+alphabet1[i];
mondaibun = mondaibun.substring(2);
i= 200;
}
}
}
}
if(stopsan===untyped){
for(var i = 0; i < kana2.length; i++){ //「きゃ」などの2文字
if(kana2[i]===mondaibun.substring(0, 2)){
untyped += alphabet2[i];
mondaibun = mondaibun.substring(2);
i= 200;
}
}
}
if(stopsan===untyped){
for(var i = 0; i < kana1.length; i++){
if(kana1[i]===mondaibun.substring(0, 1)){ //1文字
untyped += alphabet1[i];
mondaibun = mondaibun.substring(1);
i= 200;
}
}
}
}
}
group_back2="";
group_back3="";
group_back4="";
typed_Japanese="";
typed = "";
updateTextField();
}
function ReMondaibun(){
Rcount=0;
var back = typed.slice(-1);
var back2 = typed.slice(-2,-1);
var back3 = typed.slice(-3,-2);
var back4 = typed.slice(-4,-3);
var group_back3=back3+back2+back;
var group_back2=back2+back;
if(back==="a"||back==="i"||back==="u"||back==="e"||back==="o"||back==="n"){
if(back2===back3||back3===back4&&back2!==""&&back3!==""){
if(Rcount===0){
for(i=0;i<reAlphabet3.length;i++){ //アルファベット3文字で日本語が赤くなる(ひら
if(reAlphabet3[i]===group_back3){
if(JapaneseWord.substring(1,2)===ReHira3[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}else if(JapaneseWord.substring(1,3)===ReHira3[i]){
typed_Japanese+=JapaneseWord.substring(0,3);
JapaneseWord= JapaneseWord.substring(3);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet2.length;i++){ //アルファベット2文字で日本語が赤くなる(ひら
if(reAlphabet2[i]===group_back2){
if(JapaneseWord.substring(1,2)===ReHira2[i]){
typed_Japanese += JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}else if(JapaneseWord.substring(1,3)===ReHira2[i]){
typed_Japanese+=JapaneseWord.substring(0,3);
JapaneseWord= JapaneseWord.substring(3);
Rcount=1;
}
}
}
}
if(Rcount===0){
if(group_back3!=="n"){
for(i=0;i<reAlphabet1.length;i++){ //アルファベット1文字で日本語が赤くなる(ひら
if(reAlphabet1[i]===back);
if(JapaneseWord.substring(1,2)===ReHira1[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}
}
}
}
if(back2===back3||back3===back4&&back2!==""&&back3!==""){
if(Rcount===0){
for(i=0;i<reAlphabet3.length;i++){ //アルファベット3文字で日本語が赤くなる(カタ
if(reAlphabet3[i]===group_back3){
if(JapaneseWord.substring(1,2)===Rekana3[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}else if(JapaneseWord.substring(1,3)===Rekana3[i]){
typed_Japanese+=JapaneseWord.substring(0,3);
JapaneseWord= JapaneseWord.substring(3);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet2.length;i++){ //アルファベット2文字で日本語が赤くなる(カタ
if(reAlphabet2[i]===group_back2){
if(JapaneseWord.substring(1,2)===Rekana2[i]){
typed_Japanese += JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}else if(JapaneseWord.substring(1,3)===Rekana2[i]){
typed_Japanese+=JapaneseWord.substring(0,3);
JapaneseWord= JapaneseWord.substring(3);
Rcount=1;
}
}
}
}
if(Rcount===0){
if(group_back3!=="n"){
for(i=0;i<reAlphabet1.length;i++){ //アルファベット1文字で日本語が赤くなる
if(reAlphabet1[i]===back){
if(JapaneseWord.substring(1,2)===Rekana1[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}
}
}
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet3.length;i++){ //アルファベット3文字で日本語が赤くなる
if(reAlphabet3[i]===group_back3){
if(JapaneseWord.substring(0,1)===ReHira3[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}else if(JapaneseWord.substring(0,2)===ReHira3[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet2.length;i++){ //アルファベット2文字で日本語が赤くなる
if(reAlphabet2[i]===group_back2){
if(JapaneseWord.substring(0,1)===ReHira2[i]){
typed_Japanese += JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}else if(JapaneseWord.substring(0,2)===ReHira2[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet1.length;i++){ //アルファベット1文字で日本語が赤くなる
if(reAlphabet1[i]===back){
if(JapaneseWord.substring(0,1)===ReHira1[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet3.length;i++){ //アルファベット3文字で日本語が赤くなる(カタ)
if(reAlphabet3[i]===group_back3){
if(JapaneseWord.substring(0,1)===Rekana3[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}else if(JapaneseWord.substring(0,2)===Rekana3[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet2.length;i++){ //アルファベット2文字で日本語が赤くなる(カタ)
if(reAlphabet2[i]===group_back2){
if(JapaneseWord.substring(0,1)===Rekana2[i]){
typed_Japanese += JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}else if(JapaneseWord.substring(0,2)===Rekana2[i]){
typed_Japanese+=JapaneseWord.substring(0,2);
JapaneseWord= JapaneseWord.substring(2);
Rcount=1;
}
}
}
}
if(Rcount===0){
for(i=0;i<reAlphabet1.length;i++){ //アルファベット1文字で日本語が赤くなる(カタ)
if(reAlphabet1[i]===back){
if(JapaneseWord.substring(0,1)===Rekana1[i]){
typed_Japanese+=JapaneseWord.substring(0,1);
JapaneseWord= JapaneseWord.substring(1);
Rcount=1;
}
}
}
}
}
//タイピングゲームの処理
document.addEventListener('keydown',function(e){
if(stage===1){ //タイピングの画面の時だけ反応
var first=untyped.substring(0,1);
var second=untyped.substring(1,2);
var chenge2=untyped.substring(0,2);
var chenge3=untyped.substring(0,3);
var back = typed.slice(-1);
var back2 = typed.slice(-2,-1);
var back3 = typed.slice(-3,-2);
if(e.key==="n"){
if(back==="n"){ // 「n + 子音」で"n"を増やさない処理
if(back2!=="n"){
if(untyped.substring(0,1)==="a"||untyped.substring(0,1)==="i"
||untyped.substring(0,1)==="u"||untyped.substring(0,1)==="e"||untyped.substring(0,1)==="o"){
if(e.key==="n"){
miss+=1;
return;
}
}
if(untyped.substring(0,1)!=="a" && untyped.substring(0,1)!=="i" // 「n + 母音」で"n"を増やす処理
&& untyped.substring(0,1)!=="u" && untyped.substring(0,1)!=="e" && untyped.substring(0,1)!=="o"){
if(e.key==="n"){
if(untyped.substring(0,1)==="n"){
typed+=untyped.substring(0,1);
untyped=untyped.substring(1);
saccess();
}
else if(untyped.substring(0,1)!=="n"){
typed+="n";
saccess();
}
}
}
}
if(back2==="n"){ // 「ん+な行」の時の処理
if(back3!=="n"){
if(untyped.substring(0,1)==="a"||untyped.substring(0,1)==="i"
||untyped.substring(0,1)==="u"||untyped.substring(0,1)==="e"||untyped.substring(0,1)==="o"){
if(e.key==="n"){
typed+="n";
saccess();
}
}
}
}
}
}
for(var i = 0; i < another3.length; i++){ //もともと3文字の別の打ち方
if(simple3[i]===chenge3){
if(e.key === another3[i].substring(0, 1)){
untyped= untyped.slice(3);
untyped=another3[i] + untyped;
typed += untyped.substring(0, 1); //正しくタイピングしたとき
untyped = untyped.substring(1);
saccess();
}
}
}
for(var i = 0; i < another2.length; i++){ //元々2文字の別の打ち方
if(simple2[i]===chenge2){
if(e.key === another2[i].substring(0, 1)){
untyped= untyped.slice(2);
untyped=another2[i] + untyped;
typed += untyped.substring(0, 1); //正しくタイピングしたとき
untyped = untyped.substring(1);
saccess();
}
}
}
if(back==="s"){
if(e.key ==="h"){ //siをshiにする処理
if(untyped.substring(0,1)==="i"){
typed +="h";
saccess();
}
}
if(untyped.substring(0,1) ==="y"){ //sya → shi + lya にする
for(i=0;i<SmallYLine.length;i++){
if(untyped.substring(0,2)===change[i]){
if(e.key==="h"){
typed += "h";
untyped = untyped.slice(2);
untyped= "i"+SmallYLine[i]+untyped;
saccess();
}
}
}
}
}
if(back==="t"){ //tuをtsuにする処理
if(e.key==="s"){
if(untyped.substring(0,1)==="u"){
typed+="s";
saccess();
}
}
}
if(back==="c"){
if(untyped.substring(0,1)==="y"){
for(i=0;i<SmallYLine.length;i++){
if(untyped.substring(0,2)===change[i]){
if(e.key==="h"){
typed+="h";
untyped=untyped.substring(2);
untped="i"+SmallYLine[i]+untyped;
}
}
}
}
}
function SmallTu(){
typed+=e.key;
untyped=untyped.slice(2);
untyped="tu"+untyped;
saccess();
};
if(untyped.substring(0,1)===untyped.substring(1,2)){
if(untyped.substring(0,1)!=="n"){
for (i=0;i<vowel.length;i++){
if(untyped.substring(0,1)===vowel[i]){
if(e.key==="l"){
SmallTu();
}else if(e.key==="x"){
SmallTu();
}
}
}
}
}
if(untyped.substring(0,1)==="y"){ //「"母音"+"y"+"子音"」を「"母音"+"子音"+"ly"+"子音"」にする処理 例)kya ➡ ki+lya
for(i=0;i<vowel.length;i++){ //母音があるかないか
if(back===vowel[i]){
for(j=0;j<consonant.length;j++){ //子音があるかないか
if(untyped.substring(1,2)===consonant[j]){
if(e.key==="i"){
typed+="i";
untyped=untyped.slice(2);
untyped=SmallYLine[j]+untyped;
saccess();
}
}
}
}
}
}
if(first===second){
if (e.key === untyped.substring(0, 1)) { //アルファベットが2回続く時、処理を遅らせる 例)natto
typed += untyped.substring(0, 1); //正しくタイピングしたとき
untyped = untyped.substring(1);
saccess();
sleep(50);
return;
}
}
if (e.key !== untyped.substring(0, 1)) { //ミスタイピングしたとき
miss += 1;
updateTextField();
return;
}
typed += untyped.substring(0, 1); //正しくタイピングしたとき
untyped = untyped.substring(1);
saccess();
if (untyped === "") { //1単語を打ち終わった時の処理
if (count >= 30) {
finish();
updateTextField();
} else {
count = count + 1;
next();
}
}
}
});
function saccess(){ //正しくタイプできたとき
ReMondaibun();
updateTextField();
correct += 1;
music.play();
music.currentTime = 0;
updateTextField();
}
</script>
</body>
</html>