-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrainer.html
More file actions
456 lines (415 loc) · 20.7 KB
/
Trainer.html
File metadata and controls
456 lines (415 loc) · 20.7 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
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js"></script>
<script src="js/papaparse.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
body {
background-image: linear-gradient(120deg, #7e2222 0%, #254d92 100%);
;
}
.navigation {
width: 1200px;
height: 60px;
margin: 0 auto;
border-radius: 25px;
background-color: #dbd7d7;
margin-top: 50px;
}
.content {
width: 1200px;
margin: 0 auto;
}
a {
text-decoration: none;
font-size: medium;
color: #333;
}
ul li {
float: left;
width: 150px;
height: 60px;
line-height: 60px;
text-align: center;
list-style: none;
}
.btn {
width: 110px;
height: 40px;
margin-top: 100px;
/* margin-left: 75px; */
margin: 50px;
font-size: 16px;
border-radius: 20px;
background-image: linear-gradient(135deg, #D7A942 0%, #A56246 100%);
}
.box {
display: none;
}
.box li {
background-color: #f2ecec;
height: 30px;
line-height: 30px;
}
.box li:hover {
background-color: #f2ecec;
color: #333;
}
h1 {
font-family: 'Times New Roman', Times, serif;
font-size: 66px;
color: #A56246;
}
.symbol {
font-size: 210px;
color: #D7A942;
text-align: center;
font-family: 'Times New Roman', Times, serif;
}
.word {
font-size: 100px;
color: #CAC8C5;
text-align: center;
font-family: 'Times New Roman', Times, serif;
}
.phonetic {
font-size: 140px;
color: #E3E2DE;
text-align: center;
font-family: 'Times New Roman', Times, serif;
}
.pagination {
text-align: center;
}
.footer {
align-items: flex-end;
position: absolute;
right: 0;
bottom: 0;
}
.logo {
width: 5rem;
height: 5rem;
min-width: 5rem;
min-height: 5rem;
float: left;
background-repeat: no-repeat;
background-size: cover;
margin: 10px;
}
.statement {
float: left;
margin-top: 20%;
text-align: center;
font-family: 'Times New Roman', Times, serif;
/* font-size: 66px; */
color: #D7A942;
}
.sounds_block {
height: 500px;
width: 900px;
border: none;
}
.iframe_wrapper {
text-align: center;
}
</style>
</head>
<body onload='console.log(" We have ", words_count/2, " Words to practice!");''>
<h1>Perfect Pronunciation With Google</h1>
<div class="navigation">
<div class="content">
<ul id="nav">
<li>
<a href="javascript:;" onclick="whenChangePage(0, 0, 0)">Vowels</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(0, 0, 0)">i</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 1, 0)">ɪ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 2, 0)">i & ɪ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 3, 0)">ɛ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 4, 0)">ɪ & ɛ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 5, 0)">æ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 6, 0)">ɛ & æ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 7, 0)">ə</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 8, 0)">ʌ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 9, 0)">u</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 10, 0)">ʊ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 11, 0)">ɑ(ɔ)</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 12, 0)">ɑ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(0, 13, 0)">ʌ & ɑ</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(1, 0, 0)">Dipthong</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(1, 0, 0)">eɪ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 1, 0)">eɪ & ɛ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 2, 0)">eɪ & æ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 3, 0)">aɪ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 4, 0)">aʊ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 5, 0)">oʊ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 6, 0)">oʊ & ɑ(ɔ)</a></li>
<li><a href="javascript:;" onclick="whenChangePage(1, 7, 0)">ɔɪ</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(2, 0, 0)">R_Colored</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(2, 0, 0)">ɪr</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 1, 0)">ɛr</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 2, 0)">ɝ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 3, 0)">ɚ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 4, 0)">ɔr</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 5, 0)">ɑr</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 6, 0)">aɪr</a></li>
<li><a href="javascript:;" onclick="whenChangePage(2, 7, 0)">Advanced</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(3, 0, 0)">Stops</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(3, 0, 0)">p</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 1, 0)">b</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 2, 0)">t</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 3, 0)">t̬</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 4, 0)">ʔ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 5, 0)">d</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 6, 0)">k</a></li>
<li><a href="javascript:;" onclick="whenChangePage(3, 7, 0)">g</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(4, 0, 0)">Nasal</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(4, 0, 0)">m</a></li>
<li><a href="javascript:;" onclick="whenChangePage(4, 1, 0)">n</a></li>
<li><a href="javascript:;" onclick="whenChangePage(4, 2, 0)">ŋ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(4, 3, 0)">Advanced ŋ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(4, 4, 0)">n & ŋ</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(5, 0, 0)">Fricative&Affricate</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(5, 0, 0)">f</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 1, 0)">v</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 2, 0)">θ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 3, 0)">ð</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 4, 0)">s</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 5, 0)">z</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 6, 0)">-s words</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 7, 0)">ʃ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 8, 0)">ʒ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 9, 0)">tʃ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 10, 0)">dʒ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(5, 11, 0)">h</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(6, 0, 0)">Approximant</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(6, 0, 0)">r</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 1, 0)">l</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 2, 0)">ɫ</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 3, 0)">l & r</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 4, 0)">Adv l & r</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 5, 0)">j</a></li>
<li><a href="javascript:;" onclick="whenChangePage(6, 6, 0)">w</a></li>
</ul>
</li>
<li>
<a href="javascript:;" onclick="whenChangePage(7, 0, 0)">100 Words</a>
<ul class="box">
<li><a href="javascript:;" onclick="whenChangePage(7, 0, 0)">Most Common P1</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 1, 0)">Most Common P2</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 2, 0)">Winter Holiday</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 3, 0)">Halloween</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 4, 0)">Brands</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 5, 0)">Homophones</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 6, 0)">50 States</a></li>
<li><a href="javascript:;" onclick="whenChangePage(7, 7, 0)">Challenge</a></li>
</ul>
</li>
</ul>
</div>
</div>
<p class="symbol" id="symbol_block">æ</p>
<p class="word" id="word_block">apple</p>
<p class="phonetic" id="phonetic_block">/ ˈæp(ə)l /</p>
<div class="pagination">
<button onclick="whenChangePage(-1, -1, -1)" class="btn">
Last
</button>
<button onclick="whenChangePage(-1, -1, 1)" class="btn">
Next
</button>
</div>
<div class="iframe_wrapper">
<iframe src="https://soundsamerican.net/" class="sounds_block" title="Sounds American"></iframe>
</div>
<div class="footer">
<p class="statement">Powered by@ </p>
<a href="https://www.britannica.com/dictionary/" title="BritannicaDictionary" target="_blank"
rel="noopener noreferrer nofollow">
<div class="logo" style="background-image: url(' img/britannica.png')">
</div>
</a>
<a href="https://soundsamerican.net/" title="SoundsAmerican" target="_blank" rel="noopener noreferrer nofollow">
<div class="logo" style="background-image: url('img/soundsamerican.svg')"></div>
</a>
<a href="https://www.google.com/" title="GoogleSearch" target="_blank" rel="noopener noreferrer nofollow">
<div class="logo" style="background-image: url('img/googlesearch.svg')"></div>
</a>
</div>
<script>
const Categories = ['Vowels', 'Dipthong', 'R_Colored', 'Stops', 'Nasal', 'FricativeAndAffricate', 'Approximant', 'Words'];
var database = [];
var words_count = 0;
const Vowels = [];
const Dipthong = [];
const R_Colored = [];
const Stops = [];
const Nasal = [];
const FricativeAndAffricate = [];
const Approximant = [];
const Words = [];
function loadDataFromCSV() {
for (var i = 0; i < Categories.length; i++) {
let completeFn = eval(functionStringGenerator(Categories[i]));
$.get(urlStringGenerator(Categories[i]), function (data) {
Papa.parse(data, {
complete: completeFn
});
})
}
console.log("database after load:", database);
}
// unused, just for comprehension, has the same logic with functionStringGenerator
function completeFnExample(category) {
return function (results, file) {
console.log("Parsing complete:", results, file);
for (var i = 0; i < results.data[0].length; i++) {
category.push({ Phoneme: results.data[0][i], Vocabulary: [] });
// each 2 consecutive symbols are same, one for words, one for phonetic symbols
i++;
};
for (var i = 1; i < results.data.length; i++) {
for (var j = 0; j < results.data[i].length; j++) {
if (results.data[i][j].length > 0) {
category[j / 2].Vocabulary.push([results.data[i][j], results.data[i][++j]]);
words_count++;
}
}
};
console.log("Loaded category:", category);
database[Categories.indexOf(category)] = category;
// database.push(category);
}
}
// function functionStringGenerator(category) {
// return '(function(a,o) {console.log("Parsing complete:",a,o);for(var t=0;t<a.data[0].length;t++) ' + category + '.push({Phoneme:a.data[0][t],Vocabulary:[]}),t++;for(var t=1;t<a.data.length;t++)for(var e=0;e<a.data[t].length;e++)a.data[t][e].length>0&& ' + category + '[e/2].Vocabulary.push([a.data[t][e],a.data[t][++e]]);console.log("Loaded category:",' + category + ' ); database.push(' + category + ');})';
// }
function functionStringGenerator(category) {
return '(function(a,o) {console.log("Parsing complete:",a,o);for(var t=0;t<a.data[0].length;t++) ' + category + '.push({Phoneme:a.data[0][t],Vocabulary:[]}),t++;for(var t=1;t<a.data.length;t++)for(var e=0;e<a.data[t].length;e++)a.data[t][e].length>0&& ' + category + '[e/2].Vocabulary.push([a.data[t][e],a.data[t][++e]]),words_count += 1;console.log("Loaded category:",' + category + ' ); database[Categories.indexOf("' + category + '")] = ' + category + ';})';
}
// remember to modify the url after forking
function urlStringGenerator(category) {
return 'https://raw.githack.com/Hunter-Plus/AmericanAccentTrainerWithGoogle/main/vocabulary/{{category}}.csv'.replace("{{category}}", category);
}
</script>
<script>
var current_category = 0;
var current_sub_category = 0;
var current_index = 0;
let trainer_window;
let dictionary_window;
const open_dictionary = true;
// index_offset == 1, go next page; == -1, go back to last one; ==0 stay;
function whenChangePage(category, sub_category, index_offset) {
try {
if (trainer_window != undefined) {
trainer_window.close();
}
if (dictionary_window != undefined) {
dictionary_window.close();
}
} catch (error) {
console.log(error);
// do nothing;
}
if (category >= 0 && sub_category >= 0) {
// change the categories
current_category = category;
current_sub_category = sub_category;
current_index = 0;
} else {
if (index_offset == -1) {
if (current_index == 0 && current_sub_category == 0) {
window.alert("This is the first word! Cannot going back!");
return 0;
}
if (current_index == 0) {
// go back to last one sub category
current_sub_category -= 1;
current_index = database[current_category][current_sub_category].Vocabulary.length;
}
} else if (index_offset == 1) {
console.log(database[current_category][current_sub_category].Vocabulary.length);
if (current_index == database[current_category][current_sub_category].Vocabulary.length - 1) {
console.log();
if (current_sub_category == database[current_category].length - 1) {
window.alert("No more word in this category! Good job!");
return 0;
}
// go to next sub category
current_sub_category += 1;
current_index = -1;
}
} else {
// do nothing, opening the current link
}
current_index += index_offset;
}
$('#symbol_block').text(database[current_category][current_sub_category].Phoneme);
$('#word_block').text(database[current_category][current_sub_category].Vocabulary[current_index][0]);
$('#phonetic_block').text(database[current_category][current_sub_category].Vocabulary[current_index][1]);
trainer_window = window.open("https://www.google.com/search?q=" + database[current_category][current_sub_category].Vocabulary[current_index][0] + "+pronunciation", "_child", "popup, menubar=0, toolbar=0, status=0, left=0, top=300, width=700, height=900");
// be temporarily used for gathering phonetic
if (open_dictionary) {
dictionary_window = window.open("https://dictionary.cambridge.org/us/dictionary/english/" + database[current_category][current_sub_category].Vocabulary[current_index][0], "_phonetic", "popup, menubar=0, toolbar=0, status=0, left=3000, top=300, width=700, height=900");
// dictionary_window = window.open("https://www.britannica.com/dictionary/" + database[current_category][current_sub_category].Vocabulary[current_index][0], "_phonetic", "popup, menubar=0, toolbar=0, status=0, left=3000, top=300, width=700, height=900");
}
return 0;
}
</script>
<script>
$("#nav>li").hover(function () {
$(this).children("a").css("color", "#A9143C");
$(this).children("ul").fadeIn(300);
},
function () {
$(this).children("a").css("color", "#333");
$(this).children("ul").fadeOut(100);
});
$("#nav>li>ul>li").hover(function () {
$(this).children("a").css("color", "#0A3161");
$(this).children("a").css("font-size", "xx-large");
}, function () {
$(this).children("a").css("color", "#333");
$(this).children("a").css("font-size", "medium");
})
var btn = $("button")
$("button").hover(function () {
$(this).animate({ fontSize: "22px" });
},
function () {
$(this).animate({ fontSize: "16px" });
})
$(document).ready(loadDataFromCSV());
</script>
</body>
</html>