Dembo commited on
Commit
5e24f19
·
verified ·
1 Parent(s): b99ba36

make it allow to practice words

Browse files
Files changed (1) hide show
  1. index.html +60 -53
index.html CHANGED
@@ -56,7 +56,7 @@
56
  <p class="mb-2"><span class="font-semibold">Meaning:</span> To provide lodging or space for someone.</p>
57
  <p class="mb-2"><span class="font-semibold">Tip:</span> Remember it has two Cs and two Ms.</p>
58
  </div>
59
- <button onclick="practiceWord('Accommodate', '/əˈkɒmədeɪt/')" class="w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors">
60
  Practice This Word
61
  </button>
62
  </div>
@@ -71,7 +71,7 @@
71
  <p class="mb-2"><span class="font-semibold">Meaning:</span> To cause someone to feel self-conscious.</p>
72
  <p class="mb-2"><span class="font-semibold">Tip:</span> Double R and double S - it's embarrassing to forget!</p>
73
  </div>
74
- <button onclick="practiceWord('Embarrass', '/ɪmˈbærəs/')" class="w-full bg-purple-500 hover:bg-purple-600 text-white font-medium py-2 px-4 rounded-md transition-colors">
75
  Practice This Word
76
  </button>
77
  </div>
@@ -86,7 +86,7 @@
86
  <p class="mb-2"><span class="font-semibold">Meaning:</span> The process of maintaining something.</p>
87
  <p class="mb-2"><span class="font-semibold">Tip:</span> Contains "ten" in the middle.</p>
88
  </div>
89
- <button onclick="practiceWord('Maintenance', '/ˈmeɪntənəns/')" class="w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors">
90
  Practice This Word
91
  </button>
92
  </div>
@@ -101,7 +101,7 @@
101
  <p class="mb-2"><span class="font-semibold">Meaning:</span> An inner feeling of right and wrong.</p>
102
  <p class="mb-2"><span class="font-semibold">Tip:</span> Remember "science" is in "conscience".</p>
103
  </div>
104
- <button onclick="practiceWord('Conscience', '/ˈkɒnʃəns/')" class="w-full bg-purple-500 hover:bg-purple-600 text-white font-medium py-2 px-4 rounded-md transition-colors">
105
  Practice This Word
106
  </button>
107
  </div>
@@ -116,7 +116,7 @@
116
  <p class="mb-2"><span class="font-semibold">Meaning:</span> A strong, regular repeated pattern.</p>
117
  <p class="mb-2"><span class="font-semibold">Tip:</span> No vowels except the Y!</p>
118
  </div>
119
- <button onclick="practiceWord('Rhythm', '/ˈrɪðəm/')" class="w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors">
120
  Practice This Word
121
  </button>
122
  </div>
@@ -134,16 +134,15 @@
134
  </div>
135
  </div>
136
  </div>
137
-
138
  <!-- Practice Area -->
139
  <div class="mt-12 bg-white rounded-xl shadow-md overflow-hidden">
140
  <div class="p-8">
141
  <h2 class="text-2xl font-bold text-center text-indigo-800 mb-6">Practice Zone</h2>
 
 
 
 
142
  <div class="mb-6">
143
- <div class="text-center mb-4">
144
- <div id="current-word" class="text-2xl font-bold text-indigo-700"></div>
145
- <div id="current-pronunciation" class="text-gray-500 mt-1"></div>
146
- </div>
147
  <label for="practice-word" class="block text-sm font-medium text-gray-700 mb-2">Type the word you hear:</label>
148
  <div class="flex items-center space-x-2 mb-4">
149
  <input type="text" id="practice-word" class="flex-1 px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500" placeholder="Spell the word...">
@@ -156,13 +155,13 @@
156
  <div class="flex justify-center space-x-4">
157
  <button id="check-spelling" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-md transition-colors">
158
  Check Spelling
159
- </button>
160
- <button id="new-word" class="bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-6 rounded-md transition-colors">
161
- New Word
162
- </button>
 
163
  </div>
164
  </div>
165
- </div>
166
  </main>
167
 
168
  <!-- Footer -->
@@ -210,66 +209,74 @@
210
  feather.replace();
211
  });
212
  // Practice functionality
213
- let currentPracticeWord = '';
214
- let currentPracticePronunciation = '';
215
-
216
- function practiceWord(word, pronunciation) {
217
- currentPracticeWord = word;
218
- currentPracticePronunciation = pronunciation;
 
 
 
 
219
 
220
- document.getElementById('current-word').textContent = word;
221
- document.getElementById('current-pronunciation').textContent = pronunciation;
222
- document.getElementById('practice-word').value = '';
223
- document.getElementById('feedback').classList.add('hidden');
 
 
 
 
224
 
225
- // Scroll to practice area
226
- document.querySelector('.mt-12').scrollIntoView({
227
- behavior: 'smooth'
 
 
 
 
 
 
 
 
 
 
 
 
228
  });
229
- }
230
-
231
- document.addEventListener('DOMContentLoaded', function() {
232
- // Initialize with first word
233
- practiceWord('Accommodate', '/əˈkɒmədeɪt/');
234
 
 
235
  document.getElementById('check-spelling').addEventListener('click', function() {
236
  const input = document.getElementById('practice-word');
237
  const feedback = document.getElementById('feedback');
238
 
239
- if (input.value.toLowerCase() === currentPracticeWord.toLowerCase()) {
240
  feedback.className = 'bg-green-100 text-green-800 mt-2 p-3 rounded-md';
241
  feedback.innerHTML = '<i data-feather="check-circle" class="w-5 h-5 inline mr-2"></i> Correct! Well done!';
 
242
  } else {
243
  feedback.className = 'bg-red-100 text-red-800 mt-2 p-3 rounded-md';
244
- feedback.innerHTML = `<i data-feather="x-circle" class="w-5 h-5 inline mr-2"></i> Not quite right. The correct spelling is: <strong>${currentPracticeWord}</strong>`;
245
  }
246
 
247
  feedback.classList.remove('hidden');
248
  feather.replace();
249
  });
250
 
 
251
  document.getElementById('new-word').addEventListener('click', function() {
252
- // Cycle through available words
253
- const words = [
254
- { word: 'Accommodate', pronunciation: '/əˈkɒmədeɪt/' },
255
- { word: 'Embarrass', pronunciation: '/ɪmˈbærəs/' },
256
- { word: 'Maintenance', pronunciation: '/ˈmeɪntənəns/' },
257
- { word: 'Conscience', pronunciation: '/ˈkɒnʃəns/' },
258
- { word: 'Rhythm', pronunciation: '/ˈrɪðəm/' }
259
- ];
260
-
261
- const currentIndex = words.findIndex(w => w.word === currentPracticeWord);
262
- const nextIndex = (currentIndex + 1) % words.length;
263
-
264
- practiceWord(words[nextIndex].word, words[nextIndex].pronunciation);
265
  });
266
 
 
267
  document.getElementById('play-word').addEventListener('click', function() {
268
- // Use Web Speech API to speak the word
269
- const utterance = new SpeechSynthesisUtterance(currentPracticeWord);
270
- utterance.rate = 0.8;
271
- utterance.pitch = 1;
272
- speechSynthesis.speak(utterance);
 
273
  });
274
  });
275
  </script>
 
56
  <p class="mb-2"><span class="font-semibold">Meaning:</span> To provide lodging or space for someone.</p>
57
  <p class="mb-2"><span class="font-semibold">Tip:</span> Remember it has two Cs and two Ms.</p>
58
  </div>
59
+ <button class="practice-word-btn w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors" data-word="Accommodate" data-pronunciation="/əˈkɒmədeɪt/">
60
  Practice This Word
61
  </button>
62
  </div>
 
71
  <p class="mb-2"><span class="font-semibold">Meaning:</span> To cause someone to feel self-conscious.</p>
72
  <p class="mb-2"><span class="font-semibold">Tip:</span> Double R and double S - it's embarrassing to forget!</p>
73
  </div>
74
+ <button class="practice-word-btn w-full bg-purple-500 hover:bg-purple-600 text-white font-medium py-2 px-4 rounded-md transition-colors" data-word="Embarrass" data-pronunciation="/ɪmˈbærəs/">
75
  Practice This Word
76
  </button>
77
  </div>
 
86
  <p class="mb-2"><span class="font-semibold">Meaning:</span> The process of maintaining something.</p>
87
  <p class="mb-2"><span class="font-semibold">Tip:</span> Contains "ten" in the middle.</p>
88
  </div>
89
+ <button class="practice-word-btn w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors" data-word="Maintenance" data-pronunciation="/ˈmeɪntənəns/">
90
  Practice This Word
91
  </button>
92
  </div>
 
101
  <p class="mb-2"><span class="font-semibold">Meaning:</span> An inner feeling of right and wrong.</p>
102
  <p class="mb-2"><span class="font-semibold">Tip:</span> Remember "science" is in "conscience".</p>
103
  </div>
104
+ <button class="practice-word-btn w-full bg-purple-500 hover:bg-purple-600 text-white font-medium py-2 px-4 rounded-md transition-colors" data-word="Conscience" data-pronunciation="/ˈkɒnʃəns/">
105
  Practice This Word
106
  </button>
107
  </div>
 
116
  <p class="mb-2"><span class="font-semibold">Meaning:</span> A strong, regular repeated pattern.</p>
117
  <p class="mb-2"><span class="font-semibold">Tip:</span> No vowels except the Y!</p>
118
  </div>
119
+ <button class="practice-word-btn w-full bg-indigo-500 hover:bg-indigo-600 text-white font-medium py-2 px-4 rounded-md transition-colors" data-word="Rhythm" data-pronunciation="/ˈrɪðəm/">
120
  Practice This Word
121
  </button>
122
  </div>
 
134
  </div>
135
  </div>
136
  </div>
 
137
  <!-- Practice Area -->
138
  <div class="mt-12 bg-white rounded-xl shadow-md overflow-hidden">
139
  <div class="p-8">
140
  <h2 class="text-2xl font-bold text-center text-indigo-800 mb-6">Practice Zone</h2>
141
+ <div class="text-center mb-6">
142
+ <div id="current-word" class="text-3xl font-bold text-indigo-700 mb-2"></div>
143
+ <div id="current-pronunciation" class="text-gray-500 mb-4"></div>
144
+ </div>
145
  <div class="mb-6">
 
 
 
 
146
  <label for="practice-word" class="block text-sm font-medium text-gray-700 mb-2">Type the word you hear:</label>
147
  <div class="flex items-center space-x-2 mb-4">
148
  <input type="text" id="practice-word" class="flex-1 px-4 py-2 border border-gray-300 rounded-md focus:ring-indigo-500 focus:border-indigo-500" placeholder="Spell the word...">
 
155
  <div class="flex justify-center space-x-4">
156
  <button id="check-spelling" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-md transition-colors">
157
  Check Spelling
158
+ </button>
159
+ <button id="new-word" class="bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-6 rounded-md transition-colors">
160
+ Random Word
161
+ </button>
162
+ </div>
163
  </div>
164
  </div>
 
165
  </main>
166
 
167
  <!-- Footer -->
 
209
  feather.replace();
210
  });
211
  // Practice functionality
212
+ document.addEventListener('DOMContentLoaded', function() {
213
+ const practiceWords = [
214
+ { word: 'Accommodate', pronunciation: '/əˈkɒmədeɪt/' },
215
+ { word: 'Embarrass', pronunciation: '/ɪmˈbærəs/' },
216
+ { word: 'Maintenance', pronunciation: '/ˈmeɪntənəns/' },
217
+ { word: 'Conscience', pronunciation: '/ˈkɒnʃəns/' },
218
+ { word: 'Rhythm', pronunciation: '/ˈrɪðəm/' }
219
+ ];
220
+
221
+ let currentWord = null;
222
 
223
+ // Function to set a new practice word
224
+ function setPracticeWord(wordData) {
225
+ currentWord = wordData;
226
+ document.getElementById('current-word').textContent = '???';
227
+ document.getElementById('current-pronunciation').textContent = wordData.pronunciation;
228
+ document.getElementById('practice-word').value = '';
229
+ document.getElementById('feedback').classList.add('hidden');
230
+ }
231
 
232
+ // Function to get a random word
233
+ function getRandomWord() {
234
+ const randomIndex = Math.floor(Math.random() * practiceWords.length);
235
+ return practiceWords[randomIndex];
236
+ }
237
+
238
+ // Initialize with a random word
239
+ setPracticeWord(getRandomWord());
240
+
241
+ // Practice word button handlers
242
+ document.querySelectorAll('.practice-word-btn').forEach(button => {
243
+ button.addEventListener('click', function() {
244
+ const word = this.getAttribute('data-word');
245
+ const pronunciation = this.getAttribute('data-pronunciation');
246
+ setPracticeWord({ word, pronunciation });
247
  });
 
 
 
 
 
248
 
249
+ // Check spelling
250
  document.getElementById('check-spelling').addEventListener('click', function() {
251
  const input = document.getElementById('practice-word');
252
  const feedback = document.getElementById('feedback');
253
 
254
+ if (currentWord && input.value.toLowerCase() === currentWord.word.toLowerCase()) {
255
  feedback.className = 'bg-green-100 text-green-800 mt-2 p-3 rounded-md';
256
  feedback.innerHTML = '<i data-feather="check-circle" class="w-5 h-5 inline mr-2"></i> Correct! Well done!';
257
+ document.getElementById('current-word').textContent = currentWord.word;
258
  } else {
259
  feedback.className = 'bg-red-100 text-red-800 mt-2 p-3 rounded-md';
260
+ feedback.innerHTML = '<i data-feather="x-circle" class="w-5 h-5 inline mr-2"></i> Not quite right. Try again!';
261
  }
262
 
263
  feedback.classList.remove('hidden');
264
  feather.replace();
265
  });
266
 
267
+ // New random word
268
  document.getElementById('new-word').addEventListener('click', function() {
269
+ setPracticeWord(getRandomWord());
 
 
 
 
 
 
 
 
 
 
 
 
270
  });
271
 
272
+ // Play word sound
273
  document.getElementById('play-word').addEventListener('click', function() {
274
+ if (currentWord) {
275
+ const utterance = new SpeechSynthesisUtterance(currentWord.word);
276
+ utterance.rate = 0.8;
277
+ utterance.pitch = 1;
278
+ speechSynthesis.speak(utterance);
279
+ }
280
  });
281
  });
282
  </script>