v67: слоги в отдельный #syllables div — защита от перезаписи diff
This commit is contained in:
Vendored
+9
-6
@@ -49,6 +49,7 @@ button:disabled { background:#ccc; cursor:not-allowed; }
|
|||||||
</div>
|
</div>
|
||||||
<div id="score"></div>
|
<div id="score"></div>
|
||||||
<div id="diff"></div>
|
<div id="diff"></div>
|
||||||
|
<div id="syllables"></div>
|
||||||
<div id="translation" style="font-size:0.9em;color:#555;margin-top:8px"></div>
|
<div id="translation" style="font-size:0.9em;color:#555;margin-top:8px"></div>
|
||||||
<div id="recHistory" style="margin-top:16px;font-size:0.85em"></div>
|
<div id="recHistory" style="margin-top:16px;font-size:0.85em"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -628,9 +629,11 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
'<span>🗣 Артикуляция: ' + phon.voiceClarity + '%</span>' +
|
'<span>🗣 Артикуляция: ' + phon.voiceClarity + '%</span>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
// Слоги — кликабельные (DOM-элементы, не innerHTML)
|
// Слоги — в отдельный div, не в diff (diff перезаписывается)
|
||||||
_currentBlob = blob;
|
_currentBlob = blob;
|
||||||
_currentSylBuf = null;
|
_currentSylBuf = null;
|
||||||
|
const sylDiv = document.getElementById('syllables');
|
||||||
|
sylDiv.innerHTML = '';
|
||||||
const sy = syllabifyIT(originalText);
|
const sy = syllabifyIT(originalText);
|
||||||
if (sy && sy.includes('-')) {
|
if (sy && sy.includes('-')) {
|
||||||
const syls = sy.split('-');
|
const syls = sy.split('-');
|
||||||
@@ -645,13 +648,13 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
}
|
}
|
||||||
const chip = document.createElement('span');
|
const chip = document.createElement('span');
|
||||||
chip.textContent = s;
|
chip.textContent = s;
|
||||||
chip.style.cssText = 'cursor:pointer;padding:2px 4px;border-radius:4px;transition:background 0.15s';
|
chip.style.cssText = 'cursor:pointer;padding:2px 6px;border-radius:4px;transition:background 0.1s';
|
||||||
chip.onmouseover = () => { chip.style.background = '#e0e0ff'; };
|
chip.onmouseover = () => { chip.style.background = '#d0d0ff'; };
|
||||||
chip.onmouseout = () => { chip.style.background = ''; };
|
chip.onmouseout = () => { chip.style.background = ''; };
|
||||||
chip.onclick = () => { chip.style.background = '#b0b0ff'; setTimeout(() => { chip.style.background = '#e0e0ff'; }, 150); playSyllable(i, syls.length); };
|
chip.onclick = () => { chip.style.background = '#a0a0ff'; setTimeout(() => { chip.style.background = '#d0d0ff'; }, 200); playSyllable(i, syls.length); };
|
||||||
div.appendChild(chip);
|
div.appendChild(chip);
|
||||||
});
|
});
|
||||||
document.getElementById('diff').appendChild(div);
|
sylDiv.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus('Готово.');
|
setStatus('Готово.');
|
||||||
@@ -663,7 +666,7 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
<script>
|
<script>
|
||||||
// ---------- Глобальные переменные и инициализация ----------
|
// ---------- Глобальные переменные и инициализация ----------
|
||||||
const GROQ_API_KEY = '';
|
const GROQ_API_KEY = '';
|
||||||
const VERSION = 'v66';
|
const VERSION = 'v67';
|
||||||
|
|
||||||
let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = '';
|
let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = '';
|
||||||
let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null;
|
let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="score"></div>
|
<div id="score"></div>
|
||||||
<div id="diff"></div>
|
<div id="diff"></div>
|
||||||
|
<div id="syllables"></div>
|
||||||
<div id="translation" style="font-size:0.9em;color:#555;margin-top:8px"></div>
|
<div id="translation" style="font-size:0.9em;color:#555;margin-top:8px"></div>
|
||||||
<div id="recHistory" style="margin-top:16px;font-size:0.85em"></div>
|
<div id="recHistory" style="margin-top:16px;font-size:0.85em"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+7
-5
@@ -99,9 +99,11 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
'<span>🗣 Артикуляция: ' + phon.voiceClarity + '%</span>' +
|
'<span>🗣 Артикуляция: ' + phon.voiceClarity + '%</span>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
// Слоги — кликабельные (DOM-элементы, не innerHTML)
|
// Слоги — в отдельный div, не в diff (diff перезаписывается)
|
||||||
_currentBlob = blob;
|
_currentBlob = blob;
|
||||||
_currentSylBuf = null;
|
_currentSylBuf = null;
|
||||||
|
const sylDiv = document.getElementById('syllables');
|
||||||
|
sylDiv.innerHTML = '';
|
||||||
const sy = syllabifyIT(originalText);
|
const sy = syllabifyIT(originalText);
|
||||||
if (sy && sy.includes('-')) {
|
if (sy && sy.includes('-')) {
|
||||||
const syls = sy.split('-');
|
const syls = sy.split('-');
|
||||||
@@ -116,13 +118,13 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
}
|
}
|
||||||
const chip = document.createElement('span');
|
const chip = document.createElement('span');
|
||||||
chip.textContent = s;
|
chip.textContent = s;
|
||||||
chip.style.cssText = 'cursor:pointer;padding:2px 4px;border-radius:4px;transition:background 0.15s';
|
chip.style.cssText = 'cursor:pointer;padding:2px 6px;border-radius:4px;transition:background 0.1s';
|
||||||
chip.onmouseover = () => { chip.style.background = '#e0e0ff'; };
|
chip.onmouseover = () => { chip.style.background = '#d0d0ff'; };
|
||||||
chip.onmouseout = () => { chip.style.background = ''; };
|
chip.onmouseout = () => { chip.style.background = ''; };
|
||||||
chip.onclick = () => { chip.style.background = '#b0b0ff'; setTimeout(() => { chip.style.background = '#e0e0ff'; }, 150); playSyllable(i, syls.length); };
|
chip.onclick = () => { chip.style.background = '#a0a0ff'; setTimeout(() => { chip.style.background = '#d0d0ff'; }, 200); playSyllable(i, syls.length); };
|
||||||
div.appendChild(chip);
|
div.appendChild(chip);
|
||||||
});
|
});
|
||||||
document.getElementById('diff').appendChild(div);
|
sylDiv.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus('Готово.');
|
setStatus('Готово.');
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
// ---------- Глобальные переменные и инициализация ----------
|
// ---------- Глобальные переменные и инициализация ----------
|
||||||
const GROQ_API_KEY = '';
|
const GROQ_API_KEY = '';
|
||||||
const VERSION = 'v66';
|
const VERSION = 'v67';
|
||||||
|
|
||||||
let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = '';
|
let mediaRecorder, audioChunks = [], userAudioBlob = null, ttsText = '';
|
||||||
let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null;
|
let isRecording = false, isAnalyzing = false, micAnalyser = null, micAnimId = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user