Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -278,19 +278,26 @@ HEAD_HTML = """
|
|
| 278 |
}
|
| 279 |
|
| 280 |
/* ββ Poll the hidden output textarea for results ββββββββββββββββββ */
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
lastSeenOutput = val;
|
| 288 |
applyExplanation(val);
|
| 289 |
}
|
| 290 |
-
}
|
|
|
|
|
|
|
| 291 |
}
|
| 292 |
-
setTimeout(pollOutput, 250);
|
| 293 |
-
}
|
| 294 |
|
| 295 |
function applyExplanation(text) {
|
| 296 |
if (placeholder) {
|
|
@@ -323,7 +330,7 @@ HEAD_HTML = """
|
|
| 323 |
/* ββ Boot βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 324 |
function boot() {
|
| 325 |
buildFAB();
|
| 326 |
-
|
| 327 |
}
|
| 328 |
|
| 329 |
if (document.readyState === 'loading') {
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
/* ββ Poll the hidden output textarea for results ββββββββββββββββββ */
|
| 281 |
+
function watchOutput() {
|
| 282 |
+
const target = document.querySelector('#hidden-output');
|
| 283 |
+
if (!target) {
|
| 284 |
+
setTimeout(watchOutput, 500);
|
| 285 |
+
return;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
const observer = new MutationObserver(() => {
|
| 289 |
+
const ta = document.querySelector('#hidden-output textarea');
|
| 290 |
+
if (!ta) return;
|
| 291 |
+
|
| 292 |
+
const val = ta.value.trim();
|
| 293 |
+
if (isExplaining && val && val !== lastSeenOutput) {
|
| 294 |
lastSeenOutput = val;
|
| 295 |
applyExplanation(val);
|
| 296 |
}
|
| 297 |
+
});
|
| 298 |
+
|
| 299 |
+
observer.observe(target, { subtree: true, childList: true });
|
| 300 |
}
|
|
|
|
|
|
|
| 301 |
|
| 302 |
function applyExplanation(text) {
|
| 303 |
if (placeholder) {
|
|
|
|
| 330 |
/* ββ Boot βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 331 |
function boot() {
|
| 332 |
buildFAB();
|
| 333 |
+
watchOutput();
|
| 334 |
}
|
| 335 |
|
| 336 |
if (document.readyState === 'loading') {
|