Spaces:
Running
on
Zero
Running
on
Zero
Joffrey Thomas
commited on
Commit
·
5c48063
1
Parent(s):
4f4b7bc
fulllscreen button
Browse files
app.py
CHANGED
|
@@ -297,12 +297,10 @@ def score_from_distance_km(distance_km: float) -> float:
|
|
| 297 |
def build_street_html(image_url: str) -> str:
|
| 298 |
base = """
|
| 299 |
<div id="image-container" style="position:relative;max-width:960px;margin:0 auto;">
|
| 300 |
-
<
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
</button>
|
| 305 |
-
</div>
|
| 306 |
<div id="mini-map-wrap" style="transition:all 0.3s ease;position:absolute;right:10px;bottom:10px;border:2px solid #fff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.2);background:#fff;">
|
| 307 |
<div id="mini-map" style="width:100%;height:100%;cursor:pointer"></div>
|
| 308 |
<div id="map-controls" style="position:absolute;right:8px;top:8px;display:flex;gap:6px;z-index:5;">
|
|
@@ -601,8 +599,8 @@ APP_BOOT_JS = """
|
|
| 601 |
function initFullscreenButtonIfPresent() {
|
| 602 |
log('initFullscreenButtonIfPresent called');
|
| 603 |
const btn = document.getElementById('fullscreen-btn');
|
| 604 |
-
const
|
| 605 |
-
if (!btn || !
|
| 606 |
|
| 607 |
const enterIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>';
|
| 608 |
const exitIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0-2-2h-3m-6 0H3a2 2 0 0 0-2 2v3"/></svg>';
|
|
@@ -611,7 +609,7 @@ APP_BOOT_JS = """
|
|
| 611 |
|
| 612 |
btn.addEventListener('click', () => {
|
| 613 |
if (!document.fullscreenElement) {
|
| 614 |
-
|
| 615 |
log('Fullscreen error:', err);
|
| 616 |
});
|
| 617 |
} else {
|
|
@@ -620,10 +618,14 @@ APP_BOOT_JS = """
|
|
| 620 |
});
|
| 621 |
|
| 622 |
document.addEventListener('fullscreenchange', () => {
|
| 623 |
-
if (document.fullscreenElement ===
|
| 624 |
btn.innerHTML = exitIcon;
|
|
|
|
|
|
|
| 625 |
} else {
|
| 626 |
btn.innerHTML = enterIcon;
|
|
|
|
|
|
|
| 627 |
}
|
| 628 |
});
|
| 629 |
|
|
|
|
| 297 |
def build_street_html(image_url: str) -> str:
|
| 298 |
base = """
|
| 299 |
<div id="image-container" style="position:relative;max-width:960px;margin:0 auto;">
|
| 300 |
+
<img id="street-image" src="__IMG_URL__" style="width:100%;height:auto;border-radius:8px;box-shadow:0 4px 6px rgba(0,0,0,0.1)" />
|
| 301 |
+
<button id="fullscreen-btn" title="Toggle Fullscreen" style="position:absolute;top:10px;right:10px;z-index:10;background:rgba(0,0,0,0.5);border:none;color:white;padding:8px;border-radius:4px;cursor:pointer;line-height:0;">
|
| 302 |
+
<!-- SVG icon will be injected by JS -->
|
| 303 |
+
</button>
|
|
|
|
|
|
|
| 304 |
<div id="mini-map-wrap" style="transition:all 0.3s ease;position:absolute;right:10px;bottom:10px;border:2px solid #fff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.2);background:#fff;">
|
| 305 |
<div id="mini-map" style="width:100%;height:100%;cursor:pointer"></div>
|
| 306 |
<div id="map-controls" style="position:absolute;right:8px;top:8px;display:flex;gap:6px;z-index:5;">
|
|
|
|
| 599 |
function initFullscreenButtonIfPresent() {
|
| 600 |
log('initFullscreenButtonIfPresent called');
|
| 601 |
const btn = document.getElementById('fullscreen-btn');
|
| 602 |
+
const img = document.getElementById('street-image');
|
| 603 |
+
if (!btn || !img || btn.dataset.initialized === '1') return;
|
| 604 |
|
| 605 |
const enterIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>';
|
| 606 |
const exitIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0-2-2h-3m-6 0H3a2 2 0 0 0-2 2v3"/></svg>';
|
|
|
|
| 609 |
|
| 610 |
btn.addEventListener('click', () => {
|
| 611 |
if (!document.fullscreenElement) {
|
| 612 |
+
img.requestFullscreen().catch(err => {
|
| 613 |
log('Fullscreen error:', err);
|
| 614 |
});
|
| 615 |
} else {
|
|
|
|
| 618 |
});
|
| 619 |
|
| 620 |
document.addEventListener('fullscreenchange', () => {
|
| 621 |
+
if (document.fullscreenElement === img) {
|
| 622 |
btn.innerHTML = exitIcon;
|
| 623 |
+
btn.style.position = 'fixed';
|
| 624 |
+
btn.style.zIndex = '2147483647';
|
| 625 |
} else {
|
| 626 |
btn.innerHTML = enterIcon;
|
| 627 |
+
btn.style.position = 'absolute';
|
| 628 |
+
btn.style.zIndex = '10';
|
| 629 |
}
|
| 630 |
});
|
| 631 |
|