Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +17 -19
index.html
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<!DOCTYPE html>
|
| 3 |
<html lang="es">
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
|
@@ -124,7 +122,7 @@
|
|
| 124 |
}
|
| 125 |
|
| 126 |
#word-queue-info {
|
| 127 |
-
font-size: 0.
|
| 128 |
color: var(--text-secondary);
|
| 129 |
margin-top: 4px;
|
| 130 |
}
|
|
@@ -153,12 +151,12 @@
|
|
| 153 |
</div>
|
| 154 |
|
| 155 |
<div class="form-group">
|
| 156 |
-
<label for="word">Palabra
|
| 157 |
<input type="text" id="word" value="casa">
|
| 158 |
-
<div id="word-queue-info">Palabra 1 de
|
| 159 |
</div>
|
| 160 |
|
| 161 |
-
<div class="form-group"
|
| 162 |
<label for="max_repetitions">Máx. Repeticiones:</label>
|
| 163 |
<input type="number" id="max_repetitions" value="4">
|
| 164 |
</div>
|
|
@@ -173,22 +171,22 @@
|
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<script>
|
| 176 |
-
// Lista de palabras
|
| 177 |
const wordList = ["casa", "perro", "gato", "agua", "luz"];
|
| 178 |
let currentWordIndex = 0;
|
| 179 |
-
let repeticionesActualesPalabra = {}; // rastrea repeticiones locales en cliente o confía en backend
|
| 180 |
|
| 181 |
-
// Inicializar primer valor
|
| 182 |
const wordInput = document.getElementById('word');
|
| 183 |
const queueInfo = document.getElementById('word-queue-info');
|
| 184 |
const maxRepInput = document.getElementById('max_repetitions');
|
|
|
|
|
|
|
| 185 |
maxRepInput.value = 4;
|
|
|
|
| 186 |
|
| 187 |
-
function
|
| 188 |
-
wordInput.value = wordList[currentWordIndex]
|
| 189 |
-
queueInfo.textContent = `Palabra ${currentWordIndex + 1} de ${wordList.length} (
|
| 190 |
}
|
| 191 |
-
updateWordDisplay();
|
| 192 |
|
| 193 |
let mediaRecorder;
|
| 194 |
let audioChunks = [];
|
|
@@ -242,22 +240,22 @@
|
|
| 242 |
const result = await response.json();
|
| 243 |
|
| 244 |
if (response.ok) {
|
| 245 |
-
setStatus(`✅ Guardado: Rep. ${result.repetition}/
|
| 246 |
|
| 247 |
-
// Si
|
| 248 |
if (result.repetition >= 4) {
|
| 249 |
currentWordIndex = (currentWordIndex + 1) % wordList.length;
|
| 250 |
setTimeout(() => {
|
| 251 |
-
|
| 252 |
-
setStatus(`🔄
|
| 253 |
}, 1200);
|
| 254 |
}
|
| 255 |
} else {
|
| 256 |
setStatus(`❌ Límite/Error: ${result.detail || 'Error en servidor'}`, 'error');
|
| 257 |
-
// Si
|
| 258 |
if (result.detail && result.detail.includes("límite máximo")) {
|
| 259 |
currentWordIndex = (currentWordIndex + 1) % wordList.length;
|
| 260 |
-
setTimeout(() =>
|
| 261 |
}
|
| 262 |
}
|
| 263 |
} catch (err) {
|
|
|
|
|
|
|
|
|
|
| 1 |
<html lang="es">
|
| 2 |
<head>
|
| 3 |
<meta charset="UTF-8">
|
|
|
|
| 122 |
}
|
| 123 |
|
| 124 |
#word-queue-info {
|
| 125 |
+
font-size: 0.75rem;
|
| 126 |
color: var(--text-secondary);
|
| 127 |
margin-top: 4px;
|
| 128 |
}
|
|
|
|
| 151 |
</div>
|
| 152 |
|
| 153 |
<div class="form-group">
|
| 154 |
+
<label for="word">Palabra a decir:</label>
|
| 155 |
<input type="text" id="word" value="casa">
|
| 156 |
+
<div id="word-queue-info">Palabra 1 de 5 en lista (meta: 4 repeticiones)</div>
|
| 157 |
</div>
|
| 158 |
|
| 159 |
+
<div class="form-group">
|
| 160 |
<label for="max_repetitions">Máx. Repeticiones:</label>
|
| 161 |
<input type="number" id="max_repetitions" value="4">
|
| 162 |
</div>
|
|
|
|
| 171 |
</div>
|
| 172 |
|
| 173 |
<script>
|
| 174 |
+
// Lista de palabras predeterminadas (puedes editar o ampliar)
|
| 175 |
const wordList = ["casa", "perro", "gato", "agua", "luz"];
|
| 176 |
let currentWordIndex = 0;
|
|
|
|
| 177 |
|
|
|
|
| 178 |
const wordInput = document.getElementById('word');
|
| 179 |
const queueInfo = document.getElementById('word-queue-info');
|
| 180 |
const maxRepInput = document.getElementById('max_repetitions');
|
| 181 |
+
|
| 182 |
+
// Fijar valor inicial en 4
|
| 183 |
maxRepInput.value = 4;
|
| 184 |
+
wordInput.value = wordList[0];
|
| 185 |
|
| 186 |
+
function actualizarInfoCola() {
|
| 187 |
+
wordInput.value = wordList[currentWordIndex];
|
| 188 |
+
queueInfo.textContent = `Palabra ${currentWordIndex + 1} de ${wordList.length} (meta: 4 repeticiones)`;
|
| 189 |
}
|
|
|
|
| 190 |
|
| 191 |
let mediaRecorder;
|
| 192 |
let audioChunks = [];
|
|
|
|
| 240 |
const result = await response.json();
|
| 241 |
|
| 242 |
if (response.ok) {
|
| 243 |
+
setStatus(`✅ Guardado: Rep. ${result.repetition}/${result.max_repetitions}`, 'success');
|
| 244 |
|
| 245 |
+
// Si llegó a la 4ta repetición o más, avanza automáticamente a la siguiente palabra
|
| 246 |
if (result.repetition >= 4) {
|
| 247 |
currentWordIndex = (currentWordIndex + 1) % wordList.length;
|
| 248 |
setTimeout(() => {
|
| 249 |
+
actualizarInfoCola();
|
| 250 |
+
setStatus(`🔄 Siguiente palabra: "${wordInput.value}"`);
|
| 251 |
}, 1200);
|
| 252 |
}
|
| 253 |
} else {
|
| 254 |
setStatus(`❌ Límite/Error: ${result.detail || 'Error en servidor'}`, 'error');
|
| 255 |
+
// Si el backend avisa que superó o alcanzó el límite, avanza también
|
| 256 |
if (result.detail && result.detail.includes("límite máximo")) {
|
| 257 |
currentWordIndex = (currentWordIndex + 1) % wordList.length;
|
| 258 |
+
setTimeout(() => actualizarInfoCola(), 1200);
|
| 259 |
}
|
| 260 |
}
|
| 261 |
} catch (err) {
|