Fix Read aloud stop button: findReadButton now finds data-action=speak buttons
The button was always returning null because it searched for onclick=speakText but all output cards use data-action="speak" data-target="id". Now checks data-action first so the button correctly toggles to Stop during playback.
This commit is contained in:
parent
535998f01a
commit
1e8aaf75f8
1 changed files with 6 additions and 2 deletions
|
|
@ -435,8 +435,12 @@ function findReadButton(elementId) {
|
|||
if (!card) return null;
|
||||
var buttons = card.querySelectorAll('button');
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
var oc = buttons[i].getAttribute('onclick') || '';
|
||||
if (oc.indexOf('speakText') !== -1 && oc.indexOf(elementId) !== -1) return buttons[i];
|
||||
var btn = buttons[i];
|
||||
// data-action="speak" buttons (current approach)
|
||||
if (btn.getAttribute('data-action') === 'speak' && btn.getAttribute('data-target') === elementId) return btn;
|
||||
// legacy onclick fallback
|
||||
var oc = btn.getAttribute('onclick') || '';
|
||||
if (oc.indexOf('speakText') !== -1 && oc.indexOf(elementId) !== -1) return btn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue