fix: embed style/script in article, remove top positioning
This commit is contained in:
+3
-6
@@ -172,6 +172,7 @@ class SXNGPlugin(Plugin):
|
||||
js_q = json.dumps(q_clean)
|
||||
|
||||
html_payload = f'''
|
||||
<article id="sxng-stream-box" class="answer" style="display:none; margin-bottom: 1rem;">
|
||||
<style>
|
||||
@keyframes sxng-blink {{ 0%, 100% {{ opacity: 1; }} 50% {{ opacity: 0; }} }}
|
||||
.sxng-cursor {{
|
||||
@@ -181,9 +182,7 @@ class SXNGPlugin(Plugin):
|
||||
animation: sxng-blink 1s step-end infinite;
|
||||
}}
|
||||
</style>
|
||||
<article id="sxng-stream-box" class="answer" style="display:none; margin-bottom: 1rem;">
|
||||
<p id="sxng-stream-data" style="white-space: pre-wrap; color: var(--color-result-description); font-size: 0.95rem;"></p>
|
||||
</article>
|
||||
<script>
|
||||
(async () => {{
|
||||
const q = {js_q};
|
||||
@@ -192,9 +191,6 @@ class SXNGPlugin(Plugin):
|
||||
const box = document.getElementById('sxng-stream-box');
|
||||
const data = document.getElementById('sxng-stream-data');
|
||||
|
||||
const container = document.getElementById('urls') || document.getElementById('main_results');
|
||||
if (container && box) {{ container.prepend(box); }}
|
||||
|
||||
try {{
|
||||
const ctx = new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0)));
|
||||
const res = await fetch('/gemini-stream', {{
|
||||
@@ -219,7 +215,7 @@ class SXNGPlugin(Plugin):
|
||||
if (chunk) {{
|
||||
let text = chunk;
|
||||
if (!started) {{
|
||||
text = text.replace(/^[\s.,;:!?]+/, '');
|
||||
text = text.replace(/^[\\s.,;:!?]+/, '');
|
||||
if (!text) continue;
|
||||
data.appendChild(cursor);
|
||||
box.style.display = 'block';
|
||||
@@ -233,6 +229,7 @@ class SXNGPlugin(Plugin):
|
||||
}} catch (e) {{ console.error(e); box.remove(); }}
|
||||
}})();
|
||||
</script>
|
||||
</article>
|
||||
'''
|
||||
search.result_container.answers.add(results.types.Answer(answer=Markup(html_payload)))
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user