質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,3 +5,257 @@
|
|
5
5
|
例えば、'Let\'s go'(英)、'l\'elefante'(伊)、'l\'éléphant'(仏)などは『Uncaught SyntaxError: missing ) after argument list』というエラーが出ますが、'le zèbre'(仏)はエラーも出ずに正常に動きます。それぞれの文字入力は入力法を切り替えて入力しています。使う言語は 表示言語、音声合成、音声認識、手書きなどインストール済みです。OSはWindowsです。
|
6
6
|
|
7
7
|
どのようにすれば改善するでしょうか?
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```javascript
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
//日本語カードの配列
|
16
|
+
|
17
|
+
const doubutsu =
|
18
|
+
|
19
|
+
['inu', 'usagi', 'ushi', 'uma', 'saru', 'neko', 'nezumi', 'kirin',
|
20
|
+
|
21
|
+
'shika', 'zou', 'buta', 'raion', 'risu', 'kaba', 'kangaru',
|
22
|
+
|
23
|
+
'kitsune', 'kuma', 'pannda', 'koara', 'gorira', 'tora', 'hitsuji',
|
24
|
+
|
25
|
+
'yagi', 'ookami', 'sai', 'shimauma', 'tanuki', 'rakuda', 'kyouryuu',
|
26
|
+
|
27
|
+
'cinpanji', 'hyou', 'koumori', 'tonakai', 'harinezumi', 'mogura',
|
28
|
+
|
29
|
+
'roba', 'sukanku', 'doubutsu', 'shippo', 'araiguma', 'musasabi',
|
30
|
+
|
31
|
+
'inoshishi', 'kamonohashi'];
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
//フランス語の配列
|
36
|
+
|
37
|
+
const Fanimals =
|
38
|
+
|
39
|
+
['le chien', 'le lapin', 'la vache', 'le cheval', 'le singe', 'le chat',
|
40
|
+
|
41
|
+
'la souris', 'la girafe', 'le cerf', 'l\'éléphqnt', 'le cochon', 'le lion',
|
42
|
+
|
43
|
+
'l\'écureil', 'l\'hippopotame', 'les kangourous', 'le renard', 'l\'ours',
|
44
|
+
|
45
|
+
'le panda', 'le koala', 'le gorille', 'le tigre', 'le mouton', 'la chèvre',
|
46
|
+
|
47
|
+
'le loup', 'le rhinocéros', 'le zèbre', 'le blaireau', 'les chameaux',
|
48
|
+
|
49
|
+
'le dinosaure', 'le chimpanzé', 'le léopard', 'la chauve-souris', 'le renne',
|
50
|
+
|
51
|
+
'le hérisson', 'la taupe', 'l\'âne', 'la mouffette', 'les animaux',
|
52
|
+
|
53
|
+
'les queues', 'le raton laveur', 'l\'écureuil volant', 'les sangliers',
|
54
|
+
|
55
|
+
'l\'ornithorynaue'];
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
//イタリア語の配列
|
60
|
+
|
61
|
+
const Ianimals =
|
62
|
+
|
63
|
+
['il cane', 'il coniglio', 'la vacca', 'il cavallo', 'la scimmia',
|
64
|
+
|
65
|
+
'il gatto', 'il topo', 'la giraffa', 'il cervo', 'l\'elefante',
|
66
|
+
|
67
|
+
'il maiale', 'il leone', 'lo scoiattolo', 'l\'ippopotamo', 'i canguri',
|
68
|
+
|
69
|
+
'la volpe', 'l\'orso', 'il panda', 'il koala', 'il gorilla', 'la tigre',
|
70
|
+
|
71
|
+
'la pecola', 'la capra', 'il lupo', 'il rinoceronte', 'la zebra',
|
72
|
+
|
73
|
+
'il cane procione', 'i cammelli', 'il dinosauro', 'il scimpanze',
|
74
|
+
|
75
|
+
'il leopardo', 'il pipistrello', 'la renna', 'il riccio', 'la talpa',
|
76
|
+
|
77
|
+
'l\'asino', 'la moffetta', 'gli animali', 'le code', 'il procione',
|
78
|
+
|
79
|
+
'lo scoiattolo volante', 'i cinghiali', 'l\'ornitorinco'];
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
let matchCards = [];
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
const jCards = doubutsu;
|
88
|
+
|
89
|
+
const wCards = Fanimals;
|
90
|
+
|
91
|
+
const pictures = Array.from(jCards);
|
92
|
+
|
93
|
+
const answers = Array.from(wCards);
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
//日本語カード Yates shuffle
|
98
|
+
|
99
|
+
for(let i = pictures.length - 1; i >= 0; i--){
|
100
|
+
|
101
|
+
let r = Math.floor(Math.random() * ( i + 1));
|
102
|
+
|
103
|
+
const japanese = pictures[r];
|
104
|
+
|
105
|
+
jArea.insertAdjacentHTML('afterbegin', `<img src="image/doubutsu/${japanese}.jpg"
|
106
|
+
|
107
|
+
id="${japanese}" onclick="imgCheck('${japanese}')">`);
|
108
|
+
|
109
|
+
[pictures[i], pictures[r]] = [pictures[r], pictures[i]];
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
//外国語カード Yates shuffle
|
116
|
+
|
117
|
+
for(let i = answers.length - 1; i >= 0; i--){
|
118
|
+
|
119
|
+
let r = Math.floor(Math.random() * (i + 1));
|
120
|
+
|
121
|
+
const words = answers[r];
|
122
|
+
|
123
|
+
wArea.insertAdjacentHTML('afterbegin', `<button id="${words}"
|
124
|
+
|
125
|
+
onclick="wordCheck('${words}')">${words}</button>`);
|
126
|
+
|
127
|
+
[answers[i], answers[r]] = [answers[r], answers[i]];
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
function imgCheck(japanese){
|
134
|
+
|
135
|
+
document.getElementById(japanese).style.opacity = 0.6;
|
136
|
+
|
137
|
+
matchCards.unshift(japanese);
|
138
|
+
|
139
|
+
jArea.style.pointerEvents = "none";
|
140
|
+
|
141
|
+
console.log(matchCards);
|
142
|
+
|
143
|
+
if(matchCards.length === 2){
|
144
|
+
|
145
|
+
check();
|
146
|
+
|
147
|
+
} else {
|
148
|
+
|
149
|
+
return;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
function wordCheck(words){
|
158
|
+
|
159
|
+
document.getElementById(words).style.opacity = 0.6;
|
160
|
+
|
161
|
+
matchCards.push(words);
|
162
|
+
|
163
|
+
wArea.style.pointerEvents = "none";
|
164
|
+
|
165
|
+
console.log(matchCards);
|
166
|
+
|
167
|
+
if(matchCards.length === 2){
|
168
|
+
|
169
|
+
check();
|
170
|
+
|
171
|
+
} else {
|
172
|
+
|
173
|
+
return;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
//const language = 'it-IT';
|
180
|
+
|
181
|
+
//const language = 'en-US';
|
182
|
+
|
183
|
+
//const language = 'es-ES';
|
184
|
+
|
185
|
+
const language = 'fr-FR';
|
186
|
+
|
187
|
+
//const language = 'de-DE'
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
function disappear(){
|
192
|
+
|
193
|
+
console.log(matchCards);
|
194
|
+
|
195
|
+
document.getElementById(matchCards[0]).style.display = "none";
|
196
|
+
|
197
|
+
document.getElementById(matchCards[1]).style.display = "none";
|
198
|
+
|
199
|
+
matchCards = [];
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
function check(){
|
206
|
+
|
207
|
+
console.log(jCards.indexOf(matchCards[0]));
|
208
|
+
|
209
|
+
console.log(wCards.indexOf(matchCards[1]));
|
210
|
+
|
211
|
+
if(jCards.indexOf(matchCards[0]) === wCards.indexOf(matchCards[1])){
|
212
|
+
|
213
|
+
let voice = new SpeechSynthesisUtterance();
|
214
|
+
|
215
|
+
voice.text = matchCards[1];
|
216
|
+
|
217
|
+
voice.lang = language;
|
218
|
+
|
219
|
+
speechSynthesis.speak(voice);
|
220
|
+
|
221
|
+
jArea.style.pointerEvents = "";
|
222
|
+
|
223
|
+
wArea.style.pointerEvents = "";
|
224
|
+
|
225
|
+
setTimeout(disappear, 1300);
|
226
|
+
|
227
|
+
const pIndex = jCards.indexOf(`${matchCards[0]}.jpg`);
|
228
|
+
|
229
|
+
pictures.splice(pIndex, 1);
|
230
|
+
|
231
|
+
if(pictures.length === 0){
|
232
|
+
|
233
|
+
location.href = 'clear.html';
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
} else {
|
238
|
+
|
239
|
+
var voice = new SpeechSynthesisUtterance();
|
240
|
+
|
241
|
+
voice.text = '間違いです';
|
242
|
+
|
243
|
+
voice.lang = 'ja-JP';
|
244
|
+
|
245
|
+
speechSynthesis.speak(voice);
|
246
|
+
|
247
|
+
document.getElementById(matchCards[0]).style.opacity = "initial";
|
248
|
+
|
249
|
+
document.getElementById(matchCards[1]).style.opacity = "initial";
|
250
|
+
|
251
|
+
matchCards = [];
|
252
|
+
|
253
|
+
jArea.style.pointerEvents = "";
|
254
|
+
|
255
|
+
wArea.style.pointerEvents = "";
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
```
|