fix: restore missing generateAudio, settingsPanel, chapterListPanel DOM refs removed in cleanup
This commit is contained in:
@@ -2510,6 +2510,9 @@ const chapterTmpl = `
|
||||
var seekCur = document.getElementById('seek-cur');
|
||||
var seekTot = document.getElementById('seek-tot');
|
||||
var seekTimes = document.getElementById('seek-times');
|
||||
var settingsPanel = document.getElementById('settings-panel');
|
||||
var chapterListPanel= document.getElementById('chapter-list-panel');
|
||||
var chapterListBtn = document.getElementById('chapter-list-btn');
|
||||
|
||||
// ── badge helper ──────────────────────────────────────────────────────────
|
||||
var BADGE_CLASSES = ['queue-badge-idle','queue-badge-generating','queue-badge-ready',
|
||||
@@ -2826,6 +2829,36 @@ const chapterTmpl = `
|
||||
hideSeek();
|
||||
}
|
||||
|
||||
// ── audio generation ─────────────────────────────────────────────────────
|
||||
var currentAudioCtrl = null;
|
||||
var genStartTime = 0;
|
||||
|
||||
function generateAudio(chapterN, cb) {
|
||||
if (currentAudioCtrl) currentAudioCtrl.abort();
|
||||
var ctrl = new AbortController();
|
||||
currentAudioCtrl = ctrl;
|
||||
genStartTime = Date.now();
|
||||
fetch('/ui/audio/' + SLUG + '/' + chapterN, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ voice: voiceSel.value, speed: getSpeed() }),
|
||||
signal: ctrl.signal
|
||||
})
|
||||
.then(function (res) {
|
||||
if (!res.ok) return res.text().then(function (t) { throw new Error(res.status + ': ' + t); });
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (stale()) return;
|
||||
if (!data || !data.url) throw new Error('no url in response');
|
||||
cb(data.url);
|
||||
})
|
||||
.catch(function (e) {
|
||||
if (e.name === 'AbortError' || stale()) return;
|
||||
setError(e.message);
|
||||
});
|
||||
}
|
||||
|
||||
// ── audio events ──────────────────────────────────────────────────────────
|
||||
function onTimeUpdate() {
|
||||
if (stale()) { audio.removeEventListener('timeupdate', onTimeUpdate); return; }
|
||||
|
||||
Reference in New Issue
Block a user