-
Notifications
You must be signed in to change notification settings - Fork 0
/
src.html
2076 lines (1892 loc) · 121 KB
/
src.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
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
<html class="light">
<head>
<title>SpeedRead</title>
<!-- SpeedRead by Justin M. Wray -->
<!-- https://www.justinwray.com -->
<!-- All Rights Reserved -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightshade.css"
integrity="sha256-XefEKb9Q/q8W77CCNxxyBONk4tLt9lACdbMs7n9LF5c=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css"
integrity="sha256-8M+b2Hj+vy/2J5tZ9pYDHeuPD59KsaEZn1XXj3xVhjg=" crossorigin="anonymous">
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22 stroke=%22purple%22 fill=%22purple%22>🕮</text></svg>">
<meta name="color-scheme" content="light dark">
<style type="text/css">
.game-word {
font-size: 25vmin !important;
transition: opacity .5s !important;
}
.flash {
animation: flash-frame 1s linear infinite;
}
.bg-disabled {
background-color: var(--bs-gray-200);
}
@keyframes flash-frame {
50% {
opacity: .5;
color: red;
}
}
</style>
</head>
<body class="d-flex bg-gray-100 flex-column h-100">
<header class="navbar bg-dark flex-column">
<div class="container-fluid">
<span class="navbar-brand mb-1 text-light" data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Made with love, for Jaelynn, by Justin Wray">
<i class="bi bi-heart-fill h-100"></i> SpeedRead <i class="bi bi-book h-100"></i>
</span>
<div class="buttons">
<a role="button" class="game-pause btn btn-outline-light h-100 mx-2 invisible">
<i class="bi bi-pause d-flex align-items-center h-100"></i>
</a>
<div class="btn-group">
<button class="game-start-button btn btn-outline-light disabled" data-game="Custom">Custom</button>
<button class="game-start-button btn btn-outline-light" data-game="Pre-K">Pre-K</button>
<button class="game-start-button btn btn-outline-light" data-game="Kindergarten">K</button>
<button class="game-start-button btn btn-outline-light" data-game="1st">1st</button>
<button class="game-start-button btn btn-outline-light" data-game="2nd">2nd</button>
<button class="game-start-button btn btn-outline-light" data-game="3rd">3rd</button>
<button class="game-start-button btn btn-outline-light" data-game="Nouns">Nouns</button>
<button class="game-start-button btn btn-outline-light" data-game="All">All</button>
</div>
<a role="button" class="game-settings btn btn-outline-light h-100 mx-2" data-bs-toggle="modal"
data-bs-target=".game-settings-dialog">
<i class="bi bi-gear-fill d-flex align-items-center h-100"></i>
</a>
</div>
</div>
</header>
<main class="d-flex flex-column h-100">
<section class="game-stats flex-column">
<div class="container-fluid my-4">
<div class="row justify-content-evenly text-center">
<div class="col-3">
<span class="game-timer-average fs-4 badge text-bg-secondary opacity-25"
data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-title="Average: 0">
<span class="fw-semibold">Timer:</span>
<span class="game-round-timer fw-bold">0</span>
</span>
</div>
<div class="col-3">
<span class="fs-4 badge text-bg-secondary opacity-25" data-bs-toggle="tooltip"
data-bs-placement="bottom" data-bs-title="Highest: 0">
<span class="fw-semibold">Streak:</span>
<span class="game-win-streak fw-bold">0</span>
</span>
</div>
<div class="col-3">
<span class="game-score-details fs-4 badge text-bg-secondary opacity-25"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Correct: 0 | Skipped: 0 | Percentage: 0%">
<span class="fw-semibold">Score:</span>
<span class="game-score fw-bold">0</span>
</span>
</div>
</div>
</div>
</section>
<section class="game-main container-fluid flex-grow-1 overflow-auto h-100 px-5">
<div class="game-main-board d-flex border rounded border-secondary bg-light text-center align-self-center h-100"
id="game-main-board">
<div class="game-board-inside d-flex h-100 w-100 align-self-center align-items-center"
id="game-board-inside">
<div class="align-self-center text-center w-100">
<span class="game-word fw-bold fade show">Ready?</span>
<span class="game-start-help-text">
<br>To start a game, select a level in the menu above!
<br><span data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-html="true"
data-bs-title="The wordlists are based on the Dolch words, seperated by target education level.<br><br>
<p>Keyboard Shortcuts:<ul class='text-start'><li>SPACE: Pause/Resume</li><li>LEFT-ARROW: Skip</li><li>RIGHT-ARROW: Correct</li></ul>
<br>Created by Justin M. Wray. All Rights Reserved."><i
class="bi bi-info-square-fill h-100"></i></span>
</span>
<div class="game-board-decorations d-none position-absolute bottom-0"
id="game-board-decorations">
</div>
</div>
</div>
</div>
</section>
<section class="game-buttons flex-column">
<div class="container-fluid my-4">
<div class="row justify-content-evenly text-center">
<a role="button"
class="game-word-skip-btn col-3 btn btn-lg btn-outline-danger disabled opacity-25">Skip <i
class="bi bi-skip-forward h-100"></i></a>
<a role="button"
class="game-word-correct-btn col-3 btn btn-lg btn-outline-success disabled opacity-25">Correct
<i class="bi bi-check-circle h-100"></i></a>
</div>
</div>
</section>
</main>
<div class="game-settings-dialog modal fade" id="game-settings-dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Game Settings</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="form-floating">
<div class="form-control d-flex flex-row justify-content-evenly bg-disabled h-100 mb-3"
id="game-score-type-form">
<input type="radio" class="btn-check disabled" name="game-score-type"
id="game-score-type-plus-minus">
<label class="btn btn-outline-dark mt-2 disabled" for="game-score-type-plus-minus"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="One point earned for every correct answer, and one point lost for every skipped word. [Default]">
<i class="bi bi-check-square" id="game-score-type-plus-minus-icon"></i>
Plus/Minus</label>
<input type="radio" class="btn-check disabled" name="game-score-type"
id="game-score-type-total-stars">
<label class="btn btn-outline-dark mt-2 disabled" for="game-score-type-total-stars"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Score is based on stars earned by speed; no score reductions for skipped words. [Friendly]">
<i class="bi bi-square" id="game-score-type-total-stars-icon"></i> Total Stars</label>
<input type="radio" class="btn-check disabled" name="game-score-type"
id="game-score-type-time-based">
<label class="btn btn-outline-dark mt-2 disabled" for="game-score-type-time-based"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Score is based on speed, with points added for correct answers and deducted for skipped words. [Competitive]">
<i class="bi bi-square" id="game-score-type-time-based-icon"></i> Time-Based</label>
</div>
<label for="game-score-type-form">Game Score Type</label>
</div>
<div class="form-floating mb-3">
<input class="game-time-limit form-control disabled" id="game-time-limit" type="text" disabled
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Time before the word is skipped automatically. Also used as the basis for time warnings. [Default: 30]">
<label for="game-time-limit">Round Time Limit</label>
</div>
<div class="form-floating mb-3">
<input class="game-max-stars form-control disabled" id="game-max-stars" type="text" disabled
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Maximum amount of stars earned per round; used as basis for star awardment for a correct answer. [Default: 5]">
<label for="game-time-limit">Max Stars Per Round</label>
</div>
<div class="form-floating mb-3">
<textarea class="game-custom-wordlist form-control" id="game-custom-wordlist" type="text"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Enter a custom wordlist to enable (or change) the custom game mode. [Comma Seperated Values]"></textarea>
<label for="game-custom-wordlist">Custom Game Wordlist</label>
</div>
<div class="form-floating d-flex flex-row mb-3">
<input class="game-state-data form-control" id="game-state-data" type="text"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Copy and store this data to save the current state for later. Replace with a previously stored state to resume a prior game state.">
<a role="button" class="game-save-link btn btn-outline-dark mx-2 disabled" id="game-save-link"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Link to Saved Game (Right-Click & Copy URL to Save; Use the URL to Resume)">
<i class="bi bi-save-fill d-flex align-items-center h-100"></i>
</a>
<label for="game-state-data">Game State Data</label>
</div>
<div class="form-floating">
<div class="form-control d-flex flex-row flex-wrap justify-content-evenly h-100 mb-3"
id="game-theme-form">
<input type="radio" class="btn-check" name="game-theme" id="game-theme-light" checked>
<label class="btn btn-outline-dark mt-2" for="game-theme-light" data-bs-toggle="tooltip"
data-bs-placement="bottom"
data-bs-title="Light Mode: Light colored backgrounds with dark colored text. [Default]">
<i class="bi bi-check-square" id="game-theme-light-icon"></i> Light</label>
<input type="radio" class="btn-check" name="game-theme" id="game-theme-dark">
<label class="btn btn-outline-dark mt-2" for="game-theme-dark" data-bs-toggle="tooltip"
data-bs-placement="bottom"
data-bs-title="Dark Mode: Dark colored backgrounds with light colored text.">
<i class="bi bi-square" id="game-theme-dark-icon"></i> Dark</label>
<input type="radio" class="btn-check" name="game-theme" id="game-theme-chalkboard">
<label class="btn btn-outline-dark mt-2" for="game-theme-chalkboard"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Light Mode with chalkboard-styled game screen.">
<i class="bi bi-square" id="game-theme-chalkboard-icon"></i> Chalkboard</label>
<input type="radio" class="btn-check" name="game-theme" id="game-theme-chalkboard-dark">
<label class="btn btn-outline-dark mt-2" for="game-theme-chalkboard-dark"
data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Dark Mode with chalkboard-styled game screen.">
<i class="bi bi-square" id="game-theme-chalkboard-dark-icon"></i> Chalkboard
Dark</label>
<input type="radio" class="btn-check" name="game-theme" id="game-theme-prince">
<label class="btn btn-outline-dark mt-2" for="game-theme-prince" data-bs-toggle="tooltip"
data-bs-placement="bottom" data-bs-title="Fun Color Mode with blue accents.">
<i class="bi bi-square" id="game-theme-prince-icon"></i> Prince</label>
<input type="radio" class="btn-check" name="game-theme" id="game-theme-princess">
<label class="btn btn-outline-dark mt-2" for="game-theme-princess" data-bs-toggle="tooltip"
data-bs-placement="bottom" data-bs-title="Fun Color Mode with pink and purple accents.">
<i class="bi bi-square" id="game-theme-princess-icon"></i> Princess</label>
</div>
<label for="game-theme-form">Game Theme</label>
</div>
<a class="text-decoration-none link-dark" data-bs-toggle="collapse"
href="#game-settings-advanced">Advanced Options<i class="bi bi-arrow-down"></i></a>
<div class="collapse border rounded p-3" id="game-settings-advanced">
<h6 data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Merge two Game States; useful for long-term trend tracking.">Merge Game Saves
</h6>
<div class="game-state-merge-data-input collapse" id="game-state-merge-data-input">
<div class="form-floating d-flex flex-row mb-3">
<input class="game-state-data-merge-1 form-control" id="game-state-data-merge-1"
type="text">
<label for="game-state-data-merge-1">Game Save #1</label>
</div>
<div class="collapse form-floating d-flex flex-row mb-3">
<input class="game-state-data-merge-2 form-control" id="game-state-data-merge-2"
type="text">
<label for="game-state-data-merge-2">Game Save #2</label>
</div>
<a role="button" class="game-process-merge-data btn btn-outline-dark"
id="game-process-merge-data">Merge Data</a>
</div>
<div class="game-state-merge-data-output collapse" id="game-state-merge-data-output">
<div class="form-floating d-flex flex-row mb-3">
<input class="game-state-merged-data form-control" id="game-state-merged-data"
type="text" data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Copy and store this data to save the current state for later. Replace with a previously stored state to resume a prior game state.">
<a role="button" class="game-state-merged-data-link btn btn-outline-dark mx-2 disabled"
id="game-state-merged-data-link" data-bs-toggle="tooltip" data-bs-placement="bottom"
data-bs-title="Link to Saved Game (Right-Click & Copy URL to Save; Use the URL to Resume)">
<i class="bi bi-save-fill d-flex align-items-center h-100"></i>
</a>
<label for="game-state-merged-data">Merged Game State Data</label>
</div>
</div>
</div>
</div>
<div class="modal-footer justify-content-between">
<div>
<a role="button" class="btn btn-secondary-outline" href="help.html" data-bs-toggle="tooltip"
data-bs-placement="top" data-bs-title="SpeedRead Documentation"><i
class="bi bi-patch-question-fill"></i></a>
</div>
<div>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="game-settings-save btn btn-primary"
id="game-settings-save">Save</button>
</div>
</div>
</div>
</div>
</div>
<div class="game-stats-dialog modal fade" id="game-stats-dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Game Stats</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="form-floating mb-3">
<input class="game-stats-percentage form-control" id="game-stats-percentage" type="text"
readonly>
<label for="game-stats-percentage">Accuracy (Correct/Total)</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-score form-control" id="game-stats-score" type="text" readonly>
<label for="game-stats-score">Total Score (+/- Correct/Skipped)</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-average-time form-control" id="game-stats-average-time" type="text"
readonly>
<label for="game-stats-average-time">Average Response Time (Correct Answers Only)</label>
</div>
<div class="input-group">
<div class="form-floating mb-3">
<input class="game-stats-highest-streak form-control" id="game-stats-highest-streak"
type="text" readonly>
<label for="game-stats-highest-streak">Highest Correct Streak</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-stars form-control" id="game-stats-stars" type="text" readonly>
<label for="game-stats-stars">Total Stars Earned</label>
</div>
</div>
<div class="input-group">
<div class="form-floating mb-3">
<input class="game-stats-correct form-control" id="game-stats-correct" type="text" readonly>
<label for="game-stats-correct">Total Correct</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-skipped form-control" id="game-stats-skipped" type="text" readonly>
<label for="game-stats-skipped">Total Skipped</label>
</div>
</div>
<div class="input-group">
<div class="form-floating mb-3">
<input class="game-stats-score-plus-minus form-control" id="game-stats-score-plus-minus"
type="text" readonly>
<label for="game-stats-score-plus-minus">Point Score (+/-)</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-score-time-based form-control" id="game-stats-score-time-based"
type="text" readonly>
<label for="game-stats-score-time-based">Time Score</label>
</div>
</div>
<div class="input-group">
<div class="form-floating mb-3">
<input class="game-stats-highest-score-plus-minus form-control"
id="game-stats-highest-score-plus-minus" type="text" readonly>
<label for="game-stats-highest-score-plus-minus">Highest Points Score (+/-)</label>
</div>
<div class="form-floating mb-3">
<input class="game-stats-highest-score-time-based form-control"
id="game-stats-highest-score-time-based" type="text" readonly>
<label for="game-stats-highest-score-time-based">Highest Time Score</label>
</div>
</div>
<div class="form-floating mb-3">
<input class="game-stats-words form-control" id="game-stats-words" type="text" readonly>
<label for="game-stats-words">Total Unique Words</label>
</div>
<hr>
<div class="mb-3">
<h5>Words (Ascending Accuracy)</h5>
<table class="game-stats-word-table table table-striped table-hover">
<thead>
<tr>
<th>Word</th>
<th>Percentage</th>
<th>Correct</th>
<th>Skipped</th>
<th>Avg. Time</th>
</tr>
</thead>
<tbody class="game-stats-word-table-body" id="game-stats-word-table-body">
</tbody>
</table>
</div>
</div>
<div class="modal-footer justify-content-between">
<div>
<a role="button" class="game-stats-image btn btn-secondary-outline" id="game-stats-image"
data-bs-toggle="tooltip" data-bs-placement="top"
data-bs-title="Download an image of Game Stats"><i class="bi bi-image-fill"></i></a>
</div>
<div>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/js/darkmode.min.js"
integrity="sha256-TJFCDUJIlHldAZoOahUGxmotcxJRiV2ZwL2ztw/0sZY=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/lz-string@1.4.4/libs/lz-string.min.js"
integrity="sha256-nRoO8HoupfqozUr7YKBRgHXmdx40Hl/04OSBzv7e7L8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"
integrity="sha256-6H5VB5QyLldKH9oMFUmjxw2uWpPZETQXpCkBaDjquMs=" crossorigin="anonymous"></script>
<script type="text/javascript">
class SpeedRead {
constructor(level) {
this.UI = window.UI;
this.sounds = new SpeedReadSound();
this.wordlists = {
"Pre-K": [
"a",
"and",
"away",
"big",
"blue",
"can",
"come",
"down",
"find",
"for",
"funny",
"go",
"help",
"here",
"I",
"in",
"is",
"it",
"jump",
"little",
"look",
"make",
"me",
"my",
"not",
"one",
"play",
"red",
"run",
"said",
"see",
"the",
"three",
"to",
"two",
"up",
"we",
"where",
"yellow",
"you",
],
"Kindergarten": [
"all",
"am",
"are",
"at",
"ate",
"be",
"black",
"brown",
"but",
"came",
"did",
"do",
"eat",
"four",
"get",
"good",
"have",
"he",
"into",
"like",
"must",
"new",
"no",
"now",
"on",
"our",
"out",
"please",
"pretty",
"ran",
"ride",
"saw",
"say",
"she",
"so",
"soon",
"that",
"there",
"they",
"this",
"too",
"under",
"want",
"was",
],
"1st": [
"after",
"again",
"an",
"any",
"as",
"ask",
"by",
"could",
"every",
"fly",
"from",
"give",
"going",
"had",
"has",
"her",
"him",
"his",
"how",
"just",
"know",
"let",
"live",
"may",
"of",
"old",
"once",
"open",
"over",
"put",
"round",
"some",
"stop",
"take",
"thank",
],
"2nd": [
"always",
"around",
"because",
"been",
"before",
"best",
"both",
"buy",
"call",
"cold",
"does",
"don't",
"fast",
"first",
"five",
"found",
"gave",
"goes",
"green",
"its",
"made",
"many",
"off",
"or",
"pull",
"read",
"right",
"sing",
"sit",
"sleep",
"tell",
"their",
"these",
"those",
"upon",
"us",
"use",
"very",
"wash",
"which",
"why",
"wish",
"work",
"would",
"write",
"your",
],
"3rd": [
"about",
"better",
"bring",
"carry",
"clean",
"cut",
"done",
"draw",
"drink",
"eight",
"fall",
"far",
"full",
"got",
"grow",
"hold",
"hot",
"hurt",
"if",
"keep",
"kind",
"laugh",
"light",
"long",
"much",
"myself",
"never",
"only",
"own",
"pick",
"seven",
"shall",
"show",
"six",
"small",
"start",
"ten",
"today",
"together",
"try",
"warm",
],
"Nouns": [
"apple",
"baby",
"back",
"ball",
"bear",
"bed",
"bell",
"bird",
"birthday",
"boat",
"box",
"boy",
"bread",
"brother",
"cake",
"car",
"cat",
"chair",
"chicken",
"children",
"Christmas",
"coat",
"corn",
"cow",
"day",
"dog",
"doll",
"door",
"duck",
"egg",
"eye",
"farm",
"farmer",
"father",
"feet",
"fire",
"fish",
"floor",
"flower",
"game",
"garden",
"girl",
"goodbye",
"grass",
"ground",
"hand",
"head",
"hill",
"home",
"horse",
"house",
"kitty",
"leg",
"letter",
"man",
"men",
"milk",
"money",
"morning",
"mother",
"name",
"nest",
"night",
"paper",
"party",
"picture",
"pig",
"rabbit",
"rain",
"ring",
"robin",
"Santa Claus",
"school",
"seed",
"sheep",
"shoe",
"sister",
"snow",
"song",
"squirrel",
"stick",
"street",
"sun",
"table",
"thing",
"time",
"top",
"toy",
"tree",
"watch",
"water",
"way",
"wind",
"window",
"wood",
],
};
this.stats = {
"winStreak": 0,
"highestStreak": 0,
"timeAverage": 0,
"totalTime": 0,
"correctWords": 0,
"skippedWords": 0,
"score": 0,
"percentageScore": 0,
"highestScore": 0,
"totalStars": 0,
"wordStats": {},
"scoreDetails": {
"plusMinus": 0,
"timeBased": 0,
"highestPlusMinus": 0,
"highestTimeBased": 0,
},
};
this.wordlist = [];
this.wordlistFilter = new RegExp("[^a-z0-9\\ \\-\\'\\,]", "gi");
this.roundTime = 0;
this.timeLimit = 30;
this.maxStars = 5;
this.clicked = false;
this.paused = false;
this.scoreType = "plus-minus";
this.scoreWarning = .9;
this.timeEffects = {
"timerSound": .25,
"timerFlash": .25,
"wordFlash": .5,
"skipFlash": .75,
};
if (level == "All") {
Object.keys(this.wordlists).forEach(function (list) {
this.wordlist = this.wordlist.concat(this.wordlists[list]);
}.bind(this));
} else if (level == "Custom") {
this.updateWordlist(this.UI.settingsCustomWordlist.value);
this.UI.gameWordlistUpdateDisplay();
} else {
this.wordlist = this.wordlists[level];
}
this.startGame();
return this;
}
startGame() {
this.stats = {
"winStreak": 0,
"highestStreak": 0,
"timeAverage": 0,
"totalTime": 0,
"correctWords": 0,
"skippedWords": 0,
"score": 0,
"percentageScore": 0,
"highestScore": 0,
"totalStars": 0,
"wordStats": {},
"scoreDetails": {
"plusMinus": 0,
"timeBased": 0,
"highestPlusMinus": 0,
"highestTimeBased": 0,
},
};
this.UI.gameStartUpdateDisplay();
this.startRound();
};
stopGame() {
this.stopAllTimers();
this.stopAllSounds();
};
pauseGame() {
this.paused = true;
this.stopAllTimers();
this.stopAllSounds();
this.UI.gamePausedUpdateDisplay();
};
resumeGame() {
this.UI.gameResumedUpdateDisplay();
if (!(this.timeLimit > 0)) {
this.timeLimit = 30;
};
if (!(this.maxStars > 0)) {
this.maxStars = 5;
};
this.startRound();
this.paused = false;
};
startRound() {
this.stopAllTimers();
this.stopTimerSounds();
this.roundTime = 0;
this.UI.gameRoundStartedUpdateDisplay();
this.transitionTimer = setInterval(function () { this.transitionTimerHandler(); }.bind(this), 1000);
this.clicked = false;
};
transitionTimerHandler() {
this.UI.gameWordHideDisplay();
if (isNaN(parseInt(this.UI.gameWordDisplay.textContent))) {
this.playSound("ding");
this.UI.gameWordUpdateDisplay("3");
} else {
var countValue = parseInt(this.UI.gameWordDisplay.textContent);
if (countValue === 1) {
clearInterval(this.transitionTimer);
this.newRound();
} else {
countValue--;
this.playSound("ding");
this.UI.gameWordUpdateDisplay(countValue);
if (countValue === 1) {
this.UI.gameWordHideDisplay();
} else {
this.UI.gameWordShowDisplay();
}
}
}
};
newRound() {
this.currentWord = this.nextWord();
this.playSound("timerStart");
this.UI.gameWordUpdateDisplay(this.currentWord);
this.roundTimer = setInterval(function () { this.roundTimerHandler(); }.bind(this), 1000);
}
roundTimerHandler() {
this.roundTime++;
this.UI.gameRoundTimerTickUpdateDisplay();
if (this.roundTime === Math.round(this.timeLimit * this.timeEffects.timerSound)) {
this.playSound("timer");
};
if (this.roundTime > Math.round(this.timeLimit * this.timeEffects.timerFlash)) {
this.sounds.timer.playbackRate += .05;
}
if (this.roundTime === this.timeLimit) {
this.stopTimerSounds();
this.playSound("timerEnd");
if ('speechSynthesis' in window) {
var speech = new SpeechSynthesisUtterance();
speech.text = "The word was " + this.currentWord;
speech.lang = "en-US";
window.speechSynthesis.speak(speech);
};
};
if (this.roundTime === (this.timeLimit + 5)) {
this.clickedSkip();
};
};
clickedCorrect() {
if (this.roundTime === 0 || this.roundTime >= this.timeLimit || this.paused || this.clicked) {
return false;
};
this.clicked = true;
this.stopAllTimers();
this.stopTimerSounds();
this.playSound("bing");
this.UI.gameAnswerClickedUpdateDisplay("correct");
this.stats.correctWords++;
this.stats.winStreak++;
this.updateScore("correct");
this.stats.totalTime += this.roundTime;
this.stats.timeAverage = Math.round(this.stats.totalTime / this.stats.correctWords);
if (this.stats.winStreak > this.stats.highestStreak) {
this.stats.highestStreak = this.stats.winStreak;
};
if (this.stats.score > this.stats.highestScore) {
this.stats.highestScore = this.stats.score;
};
this.stats.percentageScore = Math.round((this.stats.correctWords / (this.stats.correctWords + this.stats.skippedWords)) * 100);
this.updateWordStats(this.currentWord, "correct");
this.UI.gameStatChangeUpdateDisplay();
this.newRoundDelay = setTimeout(function () {
this.stopTimerSounds();
var stars = Math.round((this.timeLimit - this.roundTime) / this.timeLimit * this.maxStars);
this.UI.renderStars(stars);
this.newRoundDelay = setTimeout(function () { this.startRound(); }.bind(this), 750);
}.bind(this), 250);
};
clickedSkip() {
if (this.roundTime === 0 || this.paused || this.clicked) {
return false;
};
this.clicked = true;
this.stopTimerSounds();
this.playSound("buzzer");
this.UI.gameAnswerClickedUpdateDisplay("skip");
if (this.roundTime < this.timeLimit) {
if ('speechSynthesis' in window) {
var speech = new SpeechSynthesisUtterance();
speech.text = "The word was " + this.currentWord;
speech.lang = "en-US";
window.speechSynthesis.speak(speech);
};
};
this.stats.skippedWords++;
this.stats.winStreak = 0;
this.updateScore("skipped");
this.stats.percentageScore = Math.round((this.stats.correctWords / (this.stats.correctWords + this.stats.skippedWords)) * 100);
this.updateWordStats(this.currentWord, "skipped");
this.UI.gameStatChangeUpdateDisplay();
this.startRound();
};
updateScore(result) {
if (result === "correct") {
var stars = Math.round((this.timeLimit - this.roundTime) / this.timeLimit * this.maxStars);
this.stats.totalStars += stars;
this.stats.scoreDetails.plusMinus++;
this.stats.scoreDetails.timeBased += (this.timeLimit - this.roundTime);
if (this.stats.scoreDetails.plusMinus > this.stats.scoreDetails.highestPlusMinus) {
this.stats.scoreDetails.highestPlusMinus = this.stats.scoreDetails.plusMinus;
};
if (this.stats.scoreDetails.timeBased > this.stats.scoreDetails.highestTimeBased) {
this.stats.scoreDetails.highestTimeBased = this.stats.scoreDetails.timeBased;
};
} else {
this.stats.scoreDetails.plusMinus--;
this.stats.scoreDetails.timeBased -= this.roundTime;
};
if (this.scoreType === "time-based") {
this.stats.score = this.stats.scoreDetails.timeBased;
} else if (this.scoreType === "total-stars") {
this.stats.score = this.stats.totalStars;
} else {
this.stats.score = this.stats.scoreDetails.plusMinus;
};
};
addToWordStats(word) {
if (!(word in this.stats.wordStats)) {
this.stats.wordStats[word] = {
"correct": 0,
"skipped": 0,
"percentage": 0,
"time": 0,
};
};
};
updateWordStats(word, result) {
this.addToWordStats(word);
if (result === "correct") {
this.stats.wordStats[word].correct++;
this.stats.wordStats[word].time += this.roundTime;
} else {
this.stats.wordStats[word].skipped++;
};
this.stats.wordStats[word].percentage =
Math.round((this.stats.wordStats[word].correct / (this.stats.wordStats[word].correct + this.stats.wordStats[word].skipped)) * 100);
}
nextWord() {
this.wordlist.sort(() => 0.5 - Math.random());