51 lines
2.3 KiB
JavaScript
51 lines
2.3 KiB
JavaScript
// ── Init ──────────────────────────────────────────────────────────────────
|
|
|
|
initBenchmarkSampleControls();
|
|
// Sync visible preview-text input with hidden benchmark-sample-text
|
|
(function syncPreviewInput() {
|
|
const visible = $('vl-preview-sample');
|
|
const hidden = $('benchmark-sample-text');
|
|
if (!visible) return;
|
|
const stored = localStorage.getItem(BENCHMARK_SAMPLE_STORAGE_KEY);
|
|
visible.value = stored || DEFAULT_BENCHMARK_SAMPLE_TEXT;
|
|
if (hidden) hidden.value = visible.value;
|
|
visible.addEventListener('input', () => {
|
|
if (hidden) hidden.value = visible.value;
|
|
localStorage.setItem(BENCHMARK_SAMPLE_STORAGE_KEY, visible.value.trim());
|
|
});
|
|
})();
|
|
|
|
// Sync flag button to current preview text language (best-match)
|
|
(function syncPreviewLangBtn() {
|
|
const ta = $('vl-preview-sample');
|
|
const btn = $('vl-preview-lang-btn');
|
|
if (!ta || !btn) return;
|
|
const cur = ta.value.trim();
|
|
const matched = Object.keys(VL_SAMPLE_TEXTS).find(l => VL_SAMPLE_TEXTS[l] === cur) || 'EN';
|
|
const cc = (_VL_LANG_FLAG[matched] || 'gb').toLowerCase();
|
|
btn.innerHTML = `<span class="fi fi-${cc}"></span>`;
|
|
btn.title = (LANGUAGE_LABELS[matched] || matched) + ' — click to change sample language';
|
|
btn.dataset.lang = matched;
|
|
})();
|
|
|
|
// Synth mode segmented control (preview text vs. reference transcript)
|
|
(function initSynthMode() {
|
|
const seg = $('vl-synth-mode-seg');
|
|
const wrap = $('vl-preview-text-wrap');
|
|
if (!seg) return;
|
|
seg.querySelectorAll('.vl-synth-seg-btn').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
seg.querySelectorAll('.vl-synth-seg-btn').forEach(b => b.classList.remove('active'));
|
|
btn.classList.add('active');
|
|
if (wrap) wrap.classList.toggle('hidden', btn.dataset.mode === 'transcript');
|
|
});
|
|
});
|
|
})();
|
|
loadSettings().then(() => {
|
|
refreshSttBackends();
|
|
renderIntegrationSnippets();
|
|
// Do not let the first-run settings dialog's deferred navigation overwrite a
|
|
// section the user opened while the loader was still finishing its startup.
|
|
if (!localStorage.getItem(SETTINGS_SEEN_KEY) && !window._navRequestedSection) openSettings(true);
|
|
}).catch(e => status('Settings load failed: ' + e.message));
|