Spaces:
Sleeping
Sleeping
File size: 29,925 Bytes
f61e156 36b9b70 b7044ee f61e156 dda4c00 9c4c7a3 1aef9d9 fae39e8 1aef9d9 1c9a7eb b7044ee 1c9a7eb d1c299d 36b9b70 1c9a7eb f61e156 4028e79 6ec11a5 d440a12 58982d9 1e5bbae f61e156 4028e79 f01ba4a fae39e8 08f05d6 4028e79 36b9b70 4028e79 08f05d6 fae39e8 1e5bbae 08f05d6 bebd456 f01ba4a 36b9b70 f01ba4a 08f05d6 1aef9d9 bbc890c f01ba4a bbc890c 119c284 f01ba4a 3a3f35e bebd456 3b6db63 f01ba4a bebd456 f01ba4a 3b6db63 36b9b70 08f05d6 f01ba4a 08f05d6 f01ba4a b7044ee ede3aa7 08f05d6 52f5b09 08f05d6 52f5b09 08f05d6 f01ba4a 1aef9d9 d1c299d f61e156 1e5bbae 08f05d6 f01ba4a bebd456 f01ba4a 08f05d6 5a9be48 bbc890c 38b7c9d bbc890c f01ba4a d440a12 119c284 f01ba4a bebd456 3a3f35e 36b9b70 1aef9d9 155d648 08f05d6 4028e79 08f05d6 f01ba4a 1e5bbae 08f05d6 36b9b70 f01ba4a 49ab6be 08f05d6 52f5b09 08f05d6 52f5b09 08f05d6 36b9b70 4028e79 bebd456 1e5bbae f61e156 36b9b70 08f05d6 f01ba4a bebd456 3a8b8da 08f05d6 1c9a7eb 3a8b8da f01ba4a 08f05d6 f01ba4a 36b9b70 bbc890c 38b7c9d dda4c00 f01ba4a 36b9b70 f01ba4a bebd456 f01ba4a bebd456 f01ba4a 38b7c9d bebd456 f01ba4a bbc890c 36b9b70 5a9be48 36b9b70 f01ba4a 5a9be48 3b6db63 d1c299d 3b6db63 f01ba4a 36b9b70 f01ba4a bebd456 9c4c7a3 f01ba4a bebd456 4028e79 36b9b70 f01ba4a bebd456 4028e79 f01ba4a 36b9b70 f01ba4a 3b6db63 08f05d6 3b6db63 4028e79 36b9b70 4028e79 155d648 08f05d6 d1c299d 08f05d6 3b6db63 36b9b70 3a8b8da 36b9b70 08f05d6 d471066 b7044ee 08f05d6 d1c299d d471066 36b9b70 155d648 08f05d6 36b9b70 08f05d6 36b9b70 1c9a7eb 069911e 08f05d6 36b9b70 3a8b8da 1c9a7eb 3a8b8da 08f05d6 f01ba4a 9c4c7a3 f01ba4a d471066 08f05d6 1c9a7eb 4fe4593 1c9a7eb 3a8b8da 4fe4593 1c9a7eb 3a8b8da d471066 3a8b8da d471066 6bd6d19 155d648 6ec11a5 d440a12 1c9a7eb 49ab6be 3a8b8da 1c9a7eb ede3aa7 4028e79 d471066 1c9a7eb 4028e79 1e5bbae 6ec11a5 dda4c00 3a8b8da dda4c00 08f05d6 dda4c00 4fe4593 9c4c7a3 1c9a7eb f61e156 08f05d6 36b9b70 4028e79 1aef9d9 f61e156 251dd9b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | import streamlit as st
import streamlit.components.v1 as components
import json
import os
# 1. ํ์ด์ง ์ค์
st.set_page_config(page_title="Drunken Plane", page_icon="โ๏ธ", layout="wide")
st.markdown("""
<style>
.block-container { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
header, footer { display: none !important; }
iframe { height: 100vh !important; display: block; }
</style>
""", unsafe_allow_html=True)
# 2. ๋ฐ์ดํฐ ๋ก๋
try:
with open('places.json', 'r', encoding='utf-8') as f:
PLACE_DB = json.load(f)
except FileNotFoundError:
PLACE_DB = {}
st.error("๐จ 'places.json' ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค. V49.0 ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํด์ฃผ์ธ์!")
db_json = json.dumps(PLACE_DB)
# 3. HTML/JS
html_code = f"""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Drunken Plane Tour</title>
<script src="https://js.puter.com/v2/"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<style>
:root {{ --gold: #d4af37; --dark: #0a0a0a; --card-bg: #1c1c1c; --text: #e0e0e0; --accent: #c5a059; }}
body {{ margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }}
/* --- Common --- */
.page {{ position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); box-sizing: border-box; }}
/* --- Main Page --- */
#main-page {{
background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.95)), url('https://images.unsplash.com/photo-1516981879613-9f5da904015f?q=80&w=2560&auto=format&fit=crop');
background-size: cover; background-position: center;
z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
padding-top: 20px;
}}
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
.lang-btn {{ background: rgba(0,0,0,0.5); border: 1px solid #555; color: #aaa; padding: 5px 10px; border-radius: 15px; cursor: pointer; font-size: 12px; font-weight: bold; transition: all 0.2s; }}
.lang-btn.active {{ background: var(--gold); color: black; border-color: var(--gold); }}
.brand-title {{ font-size: 24px; font-weight: 900; color: var(--gold); letter-spacing: 4px; margin: 20px 0 0 0; text-transform: uppercase; }}
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 10px; }}
/* World Map Entry Button */
.world-map-btn {{
background: rgba(212, 175, 55, 0.2); border: 1px solid var(--gold); color: var(--gold);
padding: 10px 20px; border-radius: 30px; font-weight: bold; cursor: pointer; margin-bottom: 15px;
display: flex; align-items: center; gap: 8px; backdrop-filter: blur(5px);
}}
.world-map-btn:hover {{ background: var(--gold); color: black; }}
.country-select-wrapper {{ width: 80%; max-width: 400px; margin-bottom: 15px; }}
.country-select {{
width: 100%; padding: 12px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold);
color: white; font-size: 16px; border-radius: 8px; outline: none; appearance: none;
background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23d4af37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
background-repeat: no-repeat; background-position: right 15px top 50%; background-size: 12px auto;
}}
.type-filter-container {{ width: 100%; padding: 10px 20px; overflow-x: auto; display: flex; gap: 8px; scrollbar-width: none; }}
.type-btn {{ padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: bold; cursor: pointer; background: #222; color: #888; border: 1px solid #444; white-space: nowrap; transition: all 0.2s; display: flex; align-items: center; gap: 5px; }}
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 10px 20px 50px 20px; box-sizing: border-box; }}
.place-card {{ background: rgba(30,30,30,0.6); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 15px; margin-bottom: 12px; transition: all 0.2s; display: flex; flex-direction: column; position: relative; }}
.card-header {{ display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }}
.card-label {{ font-size: 10px; background: rgba(212, 175, 55, 0.2); color: var(--gold); padding: 3px 8px; border-radius: 4px; font-weight: bold; border: 1px solid var(--gold); }}
.pc-name {{ font-size: 16px; font-weight: bold; color: white; }}
.pc-desc {{ font-size: 12px; color: #bbb; line-height: 1.4; margin-top: 5px; margin-bottom: 15px; }}
.card-actions {{ display: flex; gap: 8px; margin-top: auto; }}
.btn-action {{ flex: 1; padding: 10px 0; border-radius: 8px; font-size: 12px; font-weight: bold; cursor: pointer; text-align: center; transition: all 0.2s; border: none; }}
.btn-ai {{ background: var(--gold); color: black; }}
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
/* --- Detail Page --- */
#detail-page {{ background: #111; z-index: 300; transform: translateX(100%); display: flex; flex-direction: column; }}
.nav-bar {{ height: 50px; background: rgba(0,0,0,0.9); border-bottom: 1px solid #333; display: flex; align-items: center; padding: 0 15px; justify-content: space-between; }}
.back-btn {{ background: none; border: none; color: var(--gold); font-size: 24px; cursor: pointer; }}
#mini-map {{ width: 100%; height: 35%; border-bottom: 2px solid var(--gold); }}
.report-container {{ flex: 1; overflow-y: auto; padding: 25px 20px 80px 20px; }}
.report-title {{ font-size: 24px; color: var(--gold); font-weight: bold; margin-bottom: 5px; }}
.report-meta {{ font-size: 12px; color: #666; margin-bottom: 20px; border-bottom: 1px solid #333; padding-bottom: 15px; }}
.ai-content {{ font-size: 15px; color: #ddd; line-height: 1.8; white-space: pre-wrap; }}
.gmap-btn {{ display: block; width: 90%; margin: 0 auto; padding: 15px 0; background: var(--gold); color: black; text-align: center; font-weight: bold; text-decoration: none; border-radius: 30px; position: fixed; bottom: 20px; left: 5%; z-index: 7000; }}
.gmap-btn.naver {{ background: #03C75A !important; color: white !important; }}
/* --- World Map Page --- */
#world-map-page {{ background: #111; z-index: 200; transform: translateY(100%); display: flex; flex-direction: column; }}
.map-search-bar {{
position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 500px;
z-index: 1000; display: flex; gap: 10px; background: rgba(0,0,0,0.8); padding: 10px; border-radius: 12px; border: 1px solid #444;
}}
.map-input {{ flex: 1; background: transparent; border: none; color: white; font-size: 16px; outline: none; }}
.map-icon-btn {{ background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gold); }}
.home-btn {{ background: #333; color: white; border: 1px solid #555; padding: 0 15px; border-radius: 8px; font-weight: bold; cursor: pointer; }}
.floating-loc-btn {{
position: absolute; bottom: 30px; right: 20px;
width: 50px; height: 50px; border-radius: 50%;
background: white; color: black; border: none;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
font-size: 24px; cursor: pointer; z-index: 1000;
display: flex; justify-content: center; align-items: center;
transition: transform 0.2s;
}}
.floating-loc-btn:active {{ transform: scale(0.95); }}
#full-map {{ width: 100%; height: 100%; }}
/* --- Loader --- */
.loading-screen {{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 8000; display: none; flex-direction: column; justify-content: center; align-items: center; }}
.loader-ring {{ width: 40px; height: 40px; border: 3px solid #333; border-top: 3px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }}
.loader-text {{ color: var(--gold); font-family: monospace; font-size: 13px; text-align: center; }}
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
/* Popup Styling */
.leaflet-popup-content-wrapper {{ background: #222; color: #eee; border: 1px solid var(--gold); }}
.leaflet-popup-tip {{ background: var(--gold); }}
.popup-title {{ font-size: 16px; font-weight: bold; color: var(--gold); margin-bottom: 5px; }}
.popup-badges {{ display: flex; gap: 5px; margin-bottom: 8px; }}
.popup-badge {{ font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: bold; }}
.badge-cat {{ background: #000; color: white; border: 1px solid #444; }}
.badge-lbl {{ background: #eee; color: #333; }}
.popup-desc {{ font-size: 12px; color: #ccc; margin-bottom: 10px; line-height: 1.3; }}
.popup-btn {{ width: 100%; padding: 8px; background: var(--gold); color: black; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; }}
</style>
</head>
<body>
<div id="main-page" class="page">
<div class="lang-switcher">
<div class="lang-btn active" onclick="setLanguage('KO', this)">๐ฐ๐ท</div>
<div class="lang-btn" onclick="setLanguage('EN', this)">๐บ๐ธ</div>
<div class="lang-btn" onclick="setLanguage('JP', this)">๐ฏ๐ต</div>
<div class="lang-btn" onclick="setLanguage('CN', this)">๐จ๐ณ</div>
</div>
<div style="text-align:center;">
<div class="brand-title">DRUNKEN PLANE</div>
<div id="app-subtitle" class="brand-subtitle">GLOBAL ALCOHOL HERITAGE TOUR</div>
<button class="world-map-btn" onclick="openWorldMapPage()">๐บ๏ธ WORLD MAP EXPLORER</button>
</div>
<div class="country-select-wrapper">
<select id="country-select" class="country-select" onchange="selectCountry(this.value)"></select>
</div>
<div class="type-filter-container">
<div class="type-btn selected" id="filter-all" onclick="filterType('All', this)">๐ All</div>
<div class="type-btn" id="filter-traditional" onclick="filterType('Traditional', this)">๐บ Traditional</div>
<div class="type-btn" id="filter-whiskey" onclick="filterType('Whiskey', this)">๐ฅ Whiskey</div>
<div class="type-btn" id="filter-spirits" onclick="filterType('Spirits', this)">๐ธ Spirits</div>
<div class="type-btn" id="filter-beer" onclick="filterType('Beer', this)">๐บ Beer</div>
<div class="type-btn" id="filter-wine" onclick="filterType('Wine', this)">๐ท Wine</div>
<div class="type-btn" id="filter-bar" onclick="filterType('Bar', this)">๐น Bar</div>
</div>
<div class="place-list-container" id="place-list"></div>
</div>
<div id="detail-page" class="page">
<div class="nav-bar">
<button class="back-btn" onclick="closeDetail()">โ</button>
<div id="report-header" style="color:white; font-weight:bold;">TRAVEL REPORT</div>
<div style="width:24px;"></div>
</div>
<div id="mini-map"></div>
<div class="report-container">
<div id="repo-title" class="report-title"></div>
<div id="repo-meta" class="report-meta"></div>
<div id="repo-content" class="ai-content"></div>
</div>
<a id="gmap-link" href="#" target="_blank" class="gmap-btn">๐บ๏ธ Google Maps</a>
</div>
<div id="world-map-page" class="page">
<div class="map-search-bar">
<button class="home-btn" onclick="closeWorldMapPage()">๐ HOME</button>
<input type="text" id="map-search-input" class="map-input" placeholder="Search City (e.g. Gangnam, London)..." onkeydown="if(event.key === 'Enter') searchMapLocation()">
<button class="map-icon-btn" onclick="searchMapLocation()">๐</button>
</div>
<div id="full-map"></div>
<button class="floating-loc-btn" onclick="getMyLocation()">๐ฏ</button>
</div>
<div id="loader" class="loading-screen">
<div class="loader-ring"></div>
<div id="loader-msg" class="loader-text"></div>
</div>
<script>
const PLACE_DB = {db_json};
let miniMap = null;
let miniMarker = null;
let worldMap = null;
let worldMarkers = L.layerGroup();
let selectedCountry = "";
let selectedType = "All";
let currentLang = "KO";
let loadingInterval = null;
const LOADING_MSGS = {{
"KO": ["AI๊ฐ ๋นํ๊ธฐ ํ๊ณ ์ด๋ ์ค... โ๏ธ", "๊ฐ๊ฒ ๋ฌธ์ ์ด๊ณ ๋ค์ด๊ฐ๋๋ค... ๐ช", "๋ถ์๊ธฐ ์ค์บ ์ค... ๐", "์๊ทธ๋์ฒ ์์ ์ค... ๐ท", "์ฌ์ฅ๋ ์ธํฐ๋ทฐ ์ค... ๐ฃ๏ธ", "๋ฆฌํฌํธ ์์ฑ ์ค... ๐"],
"EN": ["Flying to location... โ๏ธ", "Entering venue... ๐ช", "Scanning vibes... ๐", "Tasting drinks... ๐ท", "Interviewing staff... ๐ฃ๏ธ", "Writing report... ๐"],
"JP": ["็พๅฐใธ็งปๅไธญ... โ๏ธ", "ๅ
ฅๅบใใฆใใพใ... ๐ช", "้ฐๅฒๆฐในใญใฃใณไธญ... ๐", "่ฉฆ้ฃฒไธญ... ๐ท", "ใฌใใผใไฝๆไธญ... ๐"],
"CN": ["ๆญฃๅจๅๅพ... โ๏ธ", "ๆญฃๅจ่ฟๅบ... ๐ช", "ๆซๆๆฐๅด... ๐", "ๅๅฐ็พ้
... ๐ท", "ๆฐๅๆฅๅ... ๐"]
}};
const TRANSLATIONS = {{
"KO": {{ "subtitle": "๊ธ๋ก๋ฒ ์ฃผ๋ฅ ํค๋ฆฌํฐ์ง ํฌ์ด", "filters": {{ "All": "์ ์ฒด", "Whiskey": "์์คํค", "Spirits": "์ฆ๋ฅ์ฃผ", "Beer": "๋งฅ์ฃผ", "Wine": "์์ธ", "Traditional": "์ ํต์ฃผ/ํ ์์ฃผ", "Bar": "๋ฐ/ํ" }}, "report_header": "์ฌํ ๋ฆฌํฌํธ", "gmap": "๊ตฌ๊ธ๋งต", "nmap": "๋ค์ด๋ฒ ์ง๋", "cta_ai": "๐ค AI ๋ฆฌ๋ทฐ", "cta_map": "๐บ๏ธ ๊ธธ์ฐพ๊ธฐ" }},
"EN": {{ "subtitle": "GLOBAL ALCOHOL HERITAGE TOUR", "filters": {{ "All": "All", "Whiskey": "Whiskey", "Spirits": "Spirits", "Beer": "Beer", "Wine": "Wine", "Traditional": "Traditional", "Bar": "Bar" }}, "report_header": "TRAVEL REPORT", "gmap": "Google Maps", "nmap": "Naver Map", "cta_ai": "๐ค AI Review", "cta_map": "๐บ๏ธ Map" }},
"JP": {{ "subtitle": "ไธ็ใฎใ้
ใใชใใผใธใใขใผ", "filters": {{ "All": "ใในใฆ", "Whiskey": "ใฆใคในใญใผ", "Spirits": "่ธ็้
", "Beer": "ใใผใซ", "Wine": "ใฏใคใณ", "Traditional": "ไผ็ตฑ้
", "Bar": "ใใผ" }}, "report_header": "ๆ
่กใฌใใผใ", "gmap": "Googleใใใ", "nmap": "Naverใใใ", "cta_ai": "๐ค AIใฌใใฅใผ", "cta_map": "๐บ๏ธ ๅฐๅณ" }},
"CN": {{ "subtitle": "ๅ
จ็้
็ฑป้ไบงไนๆ
", "filters": {{ "All": "ๅ
จ้จ", "Whiskey": "ๅจๅฃซๅฟ", "Spirits": "็้
", "Beer": "ๅค้
", "Wine": "่ก่้
", "Traditional": "ไผ ็ป้
", "Bar": "้
ๅง" }}, "report_header": "ๆ
ๆธธๆฅๅ", "gmap": "่ฐทๆญๅฐๅพ", "nmap": "Naverๅฐๅพ", "cta_ai": "๐ค AI ่ฏ่ฎบ", "cta_map": "๐บ๏ธ ๅฐๅพ" }}
}};
window.onload = function() {{
initCountryDropdown();
const keys = Object.keys(PLACE_DB).sort();
const defaultKey = keys.find(k => k.includes("Korea")) || keys[0];
document.getElementById('country-select').value = defaultKey;
selectCountry(defaultKey);
updateUIText();
}};
function setLanguage(lang, el) {{
currentLang = lang;
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
el.classList.add('active');
updateUIText();
renderList();
}}
function updateUIText() {{
const t = TRANSLATIONS[currentLang];
document.getElementById('app-subtitle').innerText = t.subtitle;
document.getElementById('report-header').innerText = t.report_header;
document.getElementById('filter-all').innerText = `๐ ${{t.filters.All}}`;
document.getElementById('filter-whiskey').innerText = `๐ฅ ${{t.filters.Whiskey}}`;
document.getElementById('filter-spirits').innerText = `๐ธ ${{t.filters.Spirits}}`;
document.getElementById('filter-beer').innerText = `๐บ ${{t.filters.Beer}}`;
document.getElementById('filter-wine').innerText = `๐ท ${{t.filters.Wine}}`;
document.getElementById('filter-traditional').innerText = `๐บ ${{t.filters.Traditional}}`;
document.getElementById('filter-bar').innerText = `๐น ${{t.filters.Bar}}`;
}}
function initCountryDropdown() {{
const select = document.getElementById('country-select');
const keys = Object.keys(PLACE_DB).sort();
keys.forEach(country => {{
const option = document.createElement('option');
option.value = country;
option.text = country;
select.appendChild(option);
}});
}}
function selectCountry(country) {{
selectedCountry = country;
renderList();
}}
function filterType(type, el) {{
selectedType = type;
document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected'));
el.classList.add('selected');
renderList();
}}
function getMapUrl(place) {{
const isKorea = selectedCountry.includes("Korea") || (place.name && place.desc_ko && place.real_addr);
let query = "";
if (isKorea && place.real_addr) {{
query = encodeURIComponent(place.real_addr);
return `https://map.naver.com/v5/search/${{query}}`;
}} else if (isKorea) {{
query = encodeURIComponent(place.name);
return `https://map.naver.com/v5/search/${{query}}`;
}} else {{
query = encodeURIComponent(place.name + " " + selectedCountry);
return `https://www.google.com/maps/search/?api=1&query=$${{query}}`;
}}
}}
function renderList() {{
const list = document.getElementById('place-list');
list.innerHTML = "";
const places = PLACE_DB[selectedCountry];
const filtered = selectedType === "All" ? places : places.filter(p => p.category === selectedType);
if (filtered.length === 0) {{
list.innerHTML = "<div style='color:#888; text-align:center; padding:20px;'>No places found.</div>";
return;
}}
const t = TRANSLATIONS[currentLang];
filtered.forEach(place => {{
const card = document.createElement('div');
card.className = 'place-card';
let desc = currentLang === 'KO' ? place.desc_ko : place.desc_en;
if(currentLang === 'JP' || currentLang === 'CN') desc = place.desc_en;
card.innerHTML = `
<div class="card-header">
<div class="pc-name">${{place.name}}</div>
<div class="card-label">${{place.label}}</div>
</div>
<div class="pc-desc">${{desc}}</div>
<div class="card-actions">
<button class="btn-action btn-ai" onclick="openDetail('${{place.name}}', '${{selectedCountry}}')">${{t.cta_ai}}</button>
<button class="btn-action btn-map" onclick="window.open('${{getMapUrl(place)}}', '_blank')">${{t.cta_map}}</button>
</div>
`;
list.appendChild(card);
}});
}}
/* --- World Map Logic --- */
function openWorldMapPage() {{
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
if (!worldMap) {{
worldMap = L.map('full-map').setView([20, 0], 2);
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png', {{ attribution: 'ยฉ OpenStreetMap' }}).addTo(worldMap);
loadAllMarkers();
}}
}}
function closeWorldMapPage() {{
document.getElementById('world-map-page').style.transform = 'translateY(100%)';
}}
function loadAllMarkers() {{
worldMarkers.clearLayers();
Object.keys(PLACE_DB).forEach(country => {{
PLACE_DB[country].forEach(place => {{
let desc = currentLang === 'KO' ? place.desc_ko : place.desc_en;
if(currentLang === 'JP' || currentLang === 'CN') desc = place.desc_en;
// ๐ฅ Rich Popup Content (V53.0)
const popupContent = `
<div style="min-width: 200px;">
<div class="popup-title">${{place.name}}</div>
<div class="popup-badges">
<span class="popup-badge badge-cat">${{place.category}}</span>
<span class="popup-badge badge-lbl">${{place.label}}</span>
</div>
<div class="popup-desc">${{desc}}</div>
<button class="popup-btn" onclick="openDetailFromMap('${{place.name}}', '${{country}}')">View Details</button>
</div>
`;
const marker = L.marker([place.lat, place.lon]).bindPopup(popupContent);
worldMarkers.addLayer(marker);
}});
}});
worldMarkers.addTo(worldMap);
}}
async function searchMapLocation() {{
const query = document.getElementById('map-search-input').value;
if(!query) return;
try {{
const res = await fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${{query}}`);
const data = await res.json();
if(data && data.length > 0) {{
const lat = data[0].lat;
const lon = data[0].lon;
worldMap.setView([lat, lon], 12);
}} else {{
alert("Location not found!");
}}
}} catch(e) {{
console.error(e);
}}
}}
function getMyLocation() {{
if (navigator.geolocation) {{
navigator.geolocation.getCurrentPosition(position => {{
const lat = position.coords.latitude;
const lon = position.coords.longitude;
worldMap.setView([lat, lon], 12);
L.marker([lat, lon], {{icon: L.divIcon({{html: '๐', className: 'my-loc-icon', iconSize: [20, 20]}})}}).addTo(worldMap).bindPopup("You are here").openPopup();
}});
}} else {{
alert("Geolocation is not supported by this browser.");
}}
}}
async function openDetailFromMap(placeName, countryName) {{
selectedCountry = countryName;
closeWorldMapPage();
openDetail(placeName, countryName);
}}
async function openDetail(placeName, countryName) {{
const cName = countryName || selectedCountry;
const place = PLACE_DB[cName].find(p => p.name === placeName);
if(!place) return;
document.getElementById('main-page').style.transform = 'translateX(-30%)';
document.getElementById('detail-page').style.transform = 'translateX(0%)';
startLoadingAnimation();
document.getElementById('repo-title').innerText = place.name;
document.getElementById('repo-meta').innerText = `${{place.label}} โข ${{cName}}`;
const btn = document.getElementById('gmap-link');
const isKorea = cName.includes("Korea");
btn.href = getMapUrl(place);
btn.innerText = isKorea ? TRANSLATIONS[currentLang].nmap : TRANSLATIONS[currentLang].gmap;
if(isKorea) btn.classList.add("naver"); else btn.classList.remove("naver");
document.getElementById('repo-content').innerHTML = "";
if (!miniMap) {{
miniMap = L.map('mini-map');
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png', {{ attribution: 'ยฉ OpenStreetMap' }}).addTo(miniMap);
}}
setTimeout(() => {{
miniMap.invalidateSize();
miniMap.setView([place.lat, place.lon], 15);
if (miniMarker) miniMap.removeLayer(miniMarker);
miniMarker = L.marker([place.lat, place.lon]).addTo(miniMap).bindPopup(place.name).openPopup();
}}, 300);
let contextDesc = "";
if (place.real_addr) {{
contextDesc = `Address: ${{place.real_addr}}, Vibe: ${{place.real_vibe}}, Drink: ${{place.real_drink}}, Tip: ${{place.real_tip}}`;
}} else {{
contextDesc = currentLang === 'KO' ? place.desc_ko : place.desc_en;
}}
await generatePuterReport(place, cName, contextDesc);
}}
function startLoadingAnimation() {{
const loader = document.getElementById('loader');
loader.style.display = 'flex';
const msgs = LOADING_MSGS[currentLang];
let step = 0;
document.getElementById('loader-msg').innerText = msgs[0];
if (loadingInterval) clearInterval(loadingInterval);
loadingInterval = setInterval(() => {{
step = (step + 1) % msgs.length;
document.getElementById('loader-msg').innerText = msgs[step];
}}, 1500);
}}
function stopLoadingAnimation() {{
if (loadingInterval) clearInterval(loadingInterval);
document.getElementById('loader').style.display = 'none';
}}
async function generatePuterReport(place, countryName, contextDesc) {{
let langFull = "Korean";
if(currentLang === "EN") langFull = "English";
if(currentLang === "JP") langFull = "Japanese";
if(currentLang === "CN") langFull = "Chinese";
const prompt = `
Act as a travel expert. Write a detailed review about "${{place.name}}" in ${{countryName}}.
[Context Info]
${{contextDesc}}
Structure:
1. ๐ **Address/Location**: (Use context if available, else estimate)
2. โญ **Vibe/Atmosphere**: (Describe the feeling)
3. ๐ท **Signature Drink**: (What to drink)
4. โจ **Pro Tip**: (Best time/booking info)
Language: ${{langFull}}.
Format: Clean Markdown.
`;
try {{
const response = await retryPuter(prompt, 3);
let text = "";
if (typeof response === 'string') text = response;
else if (response && response.message) text = response.message.content;
stopLoadingAnimation();
document.getElementById('repo-content').innerHTML = text.replace(/\\n/g, '<br>');
}} catch(e) {{
console.warn(e);
generateLocalReport(place, contextDesc);
}}
}}
async function retryPuter(prompt, retries) {{
for (let i = 0; i < retries; i++) {{
try {{
const res = await puter.ai.chat(prompt);
if(res) return res;
}} catch (err) {{
if (i === retries - 1) throw err;
}}
}}
}}
function generateLocalReport(place, dbDesc) {{
stopLoadingAnimation();
const report = `
โจ **[Offline Info]**
**${{place.name}}**
${{dbDesc}}
(Click the Map button below for details.)
`;
document.getElementById('repo-content').innerHTML = report.replace(/\\n/g, '<br>');
}}
function closeDetail() {{
document.getElementById('detail-page').style.transform = 'translateX(100%)';
document.getElementById('main-page').style.transform = 'translateX(0%)';
}}
</script>
</body>
</html>
"""
components.html(html_code, height=1000, scrolling=True) |