Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -338,16 +338,16 @@ def run_query(query_text, category, country, capacity, refresh):
|
|
| 338 |
return df, ts, gr.update(choices=[""] + live_categories)
|
| 339 |
|
| 340 |
# ---------------- Gradio UI ----------------
|
| 341 |
-
with gr.Blocks(title="π§³ Torn
|
| 342 |
-
gr.Markdown("## π§³ Torn
|
| 343 |
-
gr.Markdown("_Search
|
| 344 |
|
| 345 |
# Convenience buttons
|
| 346 |
with gr.Row():
|
| 347 |
btn_short = gr.Button("πΈ Flushies (short haul)")
|
| 348 |
btn_medium = gr.Button("π§Έ Flushies (medium haul)")
|
| 349 |
btn_long = gr.Button("π Flushies (long haul)")
|
| 350 |
-
btn_xanax = gr.Button("π Xanax")
|
| 351 |
btn_temps = gr.Button("𧨠Temps")
|
| 352 |
|
| 353 |
query_box = gr.Textbox(label="Search (semantic, e.g. 'flowers in England')")
|
|
@@ -392,24 +392,39 @@ with gr.Blocks(title="π§³ Torn Inventory Viewer") as iface:
|
|
| 392 |
# --- JS: convert all UTC ISO timestamps to browser's local time ---
|
| 393 |
gr.HTML("""
|
| 394 |
<script>
|
| 395 |
-
(function(){
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
const
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
if (text && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$/.test(text.trim())){
|
| 403 |
-
try{
|
| 404 |
-
const dt = new Date(text.trim());
|
| 405 |
-
const local = fmt.format(dt);
|
| 406 |
-
if (el.value !== undefined) el.value = local;
|
| 407 |
-
else el.textContent = local;
|
| 408 |
-
}catch{}
|
| 409 |
-
}
|
| 410 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
}
|
| 412 |
-
|
|
|
|
|
|
|
| 413 |
})();
|
| 414 |
</script>
|
| 415 |
""")
|
|
|
|
| 338 |
return df, ts, gr.update(choices=[""] + live_categories)
|
| 339 |
|
| 340 |
# ---------------- Gradio UI ----------------
|
| 341 |
+
with gr.Blocks(title="π§³ Torn Foreign Stocks") as iface:
|
| 342 |
+
gr.Markdown("## π§³ Torn Foreign Stocks")
|
| 343 |
+
gr.Markdown("_Search YATA's Foreign Stocks_")
|
| 344 |
|
| 345 |
# Convenience buttons
|
| 346 |
with gr.Row():
|
| 347 |
btn_short = gr.Button("πΈ Flushies (short haul)")
|
| 348 |
btn_medium = gr.Button("π§Έ Flushies (medium haul)")
|
| 349 |
btn_long = gr.Button("π Flushies (long haul)")
|
| 350 |
+
btn_xanax = gr.Button("π Xanax (SA)")
|
| 351 |
btn_temps = gr.Button("𧨠Temps")
|
| 352 |
|
| 353 |
query_box = gr.Textbox(label="Search (semantic, e.g. 'flowers in England')")
|
|
|
|
| 392 |
# --- JS: convert all UTC ISO timestamps to browser's local time ---
|
| 393 |
gr.HTML("""
|
| 394 |
<script>
|
| 395 |
+
(function () {
|
| 396 |
+
// Convert any ISO-UTC (β¦Z) timestamp found in component text/values to the browser's local time
|
| 397 |
+
function convertTimesToLocal() {
|
| 398 |
+
const isoRe = /\\b\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z\\b/g;
|
| 399 |
+
const fmt = new Intl.DateTimeFormat([], {
|
| 400 |
+
year: "numeric", month: "2-digit", day: "2-digit",
|
| 401 |
+
hour: "2-digit", minute: "2-digit", second: "2-digit"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
});
|
| 403 |
+
|
| 404 |
+
function processRoot(root) {
|
| 405 |
+
const elems = root.querySelectorAll("td, textarea, input, div, span");
|
| 406 |
+
elems.forEach(el => {
|
| 407 |
+
// Prefer .value for inputs/textareas; otherwise use textContent
|
| 408 |
+
if (typeof el.value === "string") {
|
| 409 |
+
const v = el.value;
|
| 410 |
+
if (isoRe.test(v)) {
|
| 411 |
+
el.value = v.replace(isoRe, m => fmt.format(new Date(m)));
|
| 412 |
+
}
|
| 413 |
+
} else if (el.textContent && isoRe.test(el.textContent)) {
|
| 414 |
+
el.textContent = el.textContent.replace(isoRe, m => fmt.format(new Date(m)));
|
| 415 |
+
}
|
| 416 |
+
});
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
// Handle regular DOM and Gradio's shadow DOM
|
| 420 |
+
const roots = [document];
|
| 421 |
+
const app = document.querySelector("gradio-app");
|
| 422 |
+
if (app && app.shadowRoot) roots.push(app.shadowRoot);
|
| 423 |
+
roots.forEach(processRoot);
|
| 424 |
}
|
| 425 |
+
|
| 426 |
+
// Run periodically to catch re-renders
|
| 427 |
+
setInterval(convertTimesToLocal, 800);
|
| 428 |
})();
|
| 429 |
</script>
|
| 430 |
""")
|