Skip to content

Commit 17697c5

Browse files
committed
update
1 parent 2f310f4 commit 17697c5

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

plugins/ai_answers.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _get_streaming_connection(url: str):
173173
<button class="sxng-btn" id="btn-regen" title="Regenerate answer">
174174
<svg viewBox="0 0 24 24"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4C7.58 4 4.01 7.58 4.01 12C4.01 16.42 7.58 20 12 20C15.73 20 18.84 17.45 19.73 14H17.65C16.83 16.33 14.61 18 12 18C8.69 18 6 15.31 6 12C6 8.69 8.69 6 12 6C13.66 6 15.14 6.69 16.22 7.78L13 11H20V4L17.65 6.35Z"/></svg>
175175
</button>
176-
<form id="sxng-action-form" class="sxng-input-wrapper" onsubmit="event.preventDefault();">
176+
<form id="sxng-action-form" class="sxng-input-wrapper">
177177
<input type="text" id="sxng-action-input" class="sxng-input" placeholder="Ask..." aria-label="Ask follow-up" autocomplete="off">
178178
<div class="sxng-input-line"></div>
179179
<button type="submit" id="btn-action" class="sxng-input-submit" title="Send / Continue">
@@ -321,7 +321,8 @@ def _get_streaming_connection(url: str):
321321
}
322322
} catch(e) { console.warn('Restore failed', e); }
323323
}
324-
document.getElementById('btn-copy').onclick = async (e) => {
324+
const btnCopy = document.getElementById('btn-copy');
325+
if (btnCopy) btnCopy.addEventListener('click', async (e) => {
325326
const btn = e.currentTarget;
326327
const originalContent = btn.innerHTML;
327328
const text = Array.from(data.childNodes)
@@ -331,13 +332,14 @@ def _get_streaming_connection(url: str):
331332
await navigator.clipboard.writeText(text);
332333
btn.innerHTML = '<svg viewBox="0 0 24 24" style="color:#a3be8c;"><path d="M9 16.17L4.83 12L3.41 13.41L9 19L21 7L19.59 5.59L9 16.17Z"/></svg>';
333334
setTimeout(() => btn.innerHTML = originalContent, 2000);
334-
};
335+
});
335336
336-
document.getElementById('btn-regen').onclick = () => {
337+
const btnRegen = document.getElementById('btn-regen');
338+
if (btnRegen) btnRegen.addEventListener('click', () => {
337339
data.innerHTML = '<span class="sxng-cursor"></span>';
338340
footer.style.display = 'none';
339341
startStream();
340-
};
342+
});
341343
342344
const handleAction = async (e) => {
343345
if (e) e.preventDefault();
@@ -401,12 +403,13 @@ def _get_streaming_connection(url: str):
401403
}
402404
};
403405
404-
document.getElementById('sxng-action-form').onsubmit = handleAction;
405-
input.onfocus = () => {
406+
const actionForm = document.getElementById('sxng-action-form');
407+
if (actionForm) actionForm.addEventListener('submit', handleAction);
408+
input.addEventListener('focus', () => {
406409
setTimeout(() => {
407410
input.scrollIntoView({behavior: 'smooth', block: 'center'});
408411
}, 300);
409-
};
412+
});
410413
411414
const _origStream = startStream;
412415
startStream = async function(...args) {

0 commit comments

Comments
 (0)