Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import requests
|
|
| 8 |
import io
|
| 9 |
|
| 10 |
# ==========================================
|
| 11 |
-
# ๐ 1. ์ํฌ๋ฆฟ
|
| 12 |
# ==========================================
|
| 13 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 14 |
SHEET_URL = os.environ.get("PRIVATE_SHEET_URL")
|
|
@@ -24,33 +24,37 @@ st.markdown("""
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
-
# 2. ๋ฐ์ดํฐ ๋ก๋ ๋ฐ ์ ์
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
| 31 |
if not GROQ_API_KEY:
|
| 32 |
-
st.error("๐จ 'GROQ_API_KEY'๊ฐ ์์ต๋๋ค! Settings > Secrets
|
| 33 |
|
| 34 |
try:
|
| 35 |
if SHEET_URL:
|
| 36 |
response = requests.get(SHEET_URL)
|
| 37 |
response.raise_for_status()
|
| 38 |
|
|
|
|
| 39 |
try:
|
| 40 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 41 |
except:
|
| 42 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 43 |
|
| 44 |
-
# [
|
| 45 |
-
#
|
| 46 |
-
df = df.replace({r'\r': ' ', r'\n': ' ', r'
|
| 47 |
-
|
|
|
|
| 48 |
df.columns = df.columns.str.strip()
|
| 49 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
| 50 |
df.rename(columns=col_mapping, inplace=True)
|
| 51 |
|
|
|
|
| 52 |
if 'Country' in df.columns:
|
| 53 |
for country, group in df.groupby('Country'):
|
|
|
|
| 54 |
cleaned_group = group.fillna("").to_dict(orient='records')
|
| 55 |
PLACE_DB[country] = cleaned_group
|
| 56 |
else:
|
|
@@ -61,7 +65,7 @@ try:
|
|
| 61 |
PLACE_DB = json.load(f)
|
| 62 |
|
| 63 |
except Exception as e:
|
| 64 |
-
st.error(f"โ ๋ฐ์ดํฐ ๋ก๋
|
| 65 |
PLACE_DB = {}
|
| 66 |
|
| 67 |
# ==========================================
|
|
@@ -74,11 +78,12 @@ if os.path.exists('emily.jpg'):
|
|
| 74 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 75 |
except: pass
|
| 76 |
|
|
|
|
| 77 |
db_json_raw = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 78 |
db_base64 = base64.b64encode(db_json_raw.encode('utf-8')).decode('utf-8')
|
| 79 |
|
| 80 |
# ==========================================
|
| 81 |
-
# 4. ํ๋ก ํธ์๋ (HTML/JS/CSS) -
|
| 82 |
# ==========================================
|
| 83 |
html_code = f"""
|
| 84 |
<!DOCTYPE html>
|
|
@@ -96,18 +101,9 @@ html_code = f"""
|
|
| 96 |
:root {{ --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }}
|
| 97 |
body {{ margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }}
|
| 98 |
.page {{ position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }}
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
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');
|
| 102 |
-
background-size: cover; background-position: center; z-index: 100; align-items: center; justify-content: flex-start; padding-top: 20px;
|
| 103 |
-
}}
|
| 104 |
-
|
| 105 |
-
.bartender-btn {{
|
| 106 |
-
position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%;
|
| 107 |
-
background-image: url('data:image/jpeg;base64,{emily_base64}'); background-size: cover; background-position: center;
|
| 108 |
-
background-color: #222; border: 3px solid var(--gold); box-shadow: 0 8px 30px rgba(212, 175, 55, 0.6);
|
| 109 |
-
cursor: pointer; z-index: 999; animation: bounce-float 3s ease-in-out infinite;
|
| 110 |
-
}}
|
| 111 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
| 112 |
|
| 113 |
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
|
|
@@ -117,16 +113,8 @@ html_code = f"""
|
|
| 117 |
.brand-title {{ font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 4px; margin-top: 10px; text-transform: uppercase; }}
|
| 118 |
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px; }}
|
| 119 |
|
| 120 |
-
.world-map-btn {{
|
| 121 |
-
|
| 122 |
-
padding: 12px 25px; border-radius: 30px; font-weight: bold; cursor: pointer; margin-bottom: 20px;
|
| 123 |
-
display: flex; align-items: center; gap: 8px; backdrop-filter: blur(5px);
|
| 124 |
-
}}
|
| 125 |
-
.passport-btn {{
|
| 126 |
-
background: rgba(0,0,0,0.6); border: 1px solid var(--gold); color: var(--gold);
|
| 127 |
-
padding: 8px 15px; border-radius: 20px; font-size: 12px; cursor: pointer; margin-top: 10px;
|
| 128 |
-
display: flex; align-items: center; gap: 5px;
|
| 129 |
-
}}
|
| 130 |
|
| 131 |
.country-select-wrapper {{ width: 85%; max-width: 400px; margin-bottom: 15px; }}
|
| 132 |
.country-select {{ width: 100%; padding: 14px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold); color: white; font-size: 16px; border-radius: 10px; outline: none; }}
|
|
@@ -136,28 +124,16 @@ html_code = f"""
|
|
| 136 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 137 |
|
| 138 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 139 |
-
|
| 140 |
-
.place-card {{
|
| 141 |
-
|
| 142 |
-
border: 1px solid rgba(255,255,255,0.1); border-radius: 15px;
|
| 143 |
-
padding: 18px; margin-bottom: 15px; position: relative; transition: all 0.3s ease;
|
| 144 |
-
}}
|
| 145 |
-
.place-card.visited {{
|
| 146 |
-
background: linear-gradient(135deg, rgba(40,10,10,0.9), rgba(20,20,20,0.9));
|
| 147 |
-
border: 1px solid var(--gold);
|
| 148 |
-
box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
|
| 149 |
-
}}
|
| 150 |
-
.visited-badge {{
|
| 151 |
-
position: absolute; top: 10px; right: 10px;
|
| 152 |
-
background: var(--gold); color: black; font-size: 10px; font-weight: bold;
|
| 153 |
-
padding: 3px 8px; border-radius: 10px; display: none;
|
| 154 |
-
}}
|
| 155 |
.place-card.visited .visited-badge {{ display: block; }}
|
| 156 |
|
| 157 |
.pc-name {{ font-size: 18px; font-weight: bold; color: white; }}
|
| 158 |
.place-card.visited .pc-name {{ color: var(--gold); }}
|
| 159 |
.pc-cat {{ font-size: 11px; color: var(--gold); font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }}
|
| 160 |
.pc-desc {{ font-size: 13px; color: #bbb; line-height: 1.5; margin-top: 5px; }}
|
|
|
|
| 161 |
.card-actions {{ display: flex; gap: 10px; margin-top: 15px; }}
|
| 162 |
.btn-action {{ flex: 1; padding: 12px; border-radius: 8px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; }}
|
| 163 |
.btn-ai {{ background: var(--gold); color: black; }}
|
|
@@ -282,44 +258,21 @@ html_code = f"""
|
|
| 282 |
let miniMap = null, worldMap = null, worldMarkers = L.layerGroup();
|
| 283 |
let chatHistory = [];
|
| 284 |
let currentDetailPlace = null;
|
| 285 |
-
let currentFilteredList = [];
|
| 286 |
|
| 287 |
-
// [ํต์ฌ
|
| 288 |
-
|
|
|
|
|
|
|
| 289 |
|
| 290 |
const TRANSLATIONS = {{
|
| 291 |
-
"KO": {{
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
"searchPlace": "์ฅ์ ๊ฒ์ (์: ๊ฐ๋จ)", "emilyName": "์๋ฐ๋ฆฌ (Emily)", "reportHeader": "๋ฆฌํฌํธ",
|
| 296 |
-
"aiBtn": "AI ๋ฆฌ๋ทฐ", "mapLinkBtn": "์ง๋"
|
| 297 |
-
}},
|
| 298 |
-
"EN": {{
|
| 299 |
-
"sub": "GLOBAL ALCOHOL HERITAGE TOUR", "ai": "English", "mapBtn": "๐บ๏ธ WORLD MAP EXPLORER", "passBtn": "๐ MY PASSPORT",
|
| 300 |
-
"filters": ["๐ All", "๐บ Trad.", "๐ฅ Whiskey", "๐บ Beer", "๐ท Wine", "๐น Bar"],
|
| 301 |
-
"chatPlace": "Talk to Emily...", "send": "SEND", "home": "๐ HOME",
|
| 302 |
-
"searchPlace": "Search (e.g. Gangnam)", "emilyName": "Emily", "reportHeader": "REPORT",
|
| 303 |
-
"aiBtn": "AI REVIEW", "mapLinkBtn": "MAP"
|
| 304 |
-
}},
|
| 305 |
-
"JP": {{
|
| 306 |
-
"sub": "ไธ็ใฎใ้
ใใชใใผใธใใขใผ", "ai": "Japanese", "mapBtn": "๐บ๏ธ ไธ็ๅฐๅณๆข็ดข", "passBtn": "๐ ใใคใในใใผใ",
|
| 307 |
-
"filters": ["๐ ๅ
จใฆ", "๐บ ไผ็ตฑ้
", "๐ฅ ใฆใคในใญใผ", "๐บ ใใผใซ", "๐ท ใฏใคใณ", "๐น ใใผ"],
|
| 308 |
-
"chatPlace": "ใจใใชใผใซ่ฉฑใใใใฆ...", "send": "้ไฟก", "home": "๐ ใใผใ ",
|
| 309 |
-
"searchPlace": "ๅ ดๆๆค็ดข (ไพ: ๆฐๅฎฟ)", "emilyName": "ใจใใชใผ (Emily)", "reportHeader": "ใฌใใผใ",
|
| 310 |
-
"aiBtn": "AI ใฌใใฅใผ", "mapLinkBtn": "ๅฐๅณ"
|
| 311 |
-
}},
|
| 312 |
-
"CN": {{
|
| 313 |
-
"sub": "ๅ
จ็้
็ฑป้ไบงไนๆ
", "ai": "Chinese", "mapBtn": "๐บ๏ธ ไธ็ๅฐๅพๆข็ดข", "passBtn": "๐ ๆ็ๆค็
ง",
|
| 314 |
-
"filters": ["๐ ๅ
จ้จ", "๐บ ไผ ็ป้
", "๐ฅ ๅจๅฃซๅฟ", "๐บ ๅค้
", "๐ท ่ก่้
", "๐น ้
ๅง"],
|
| 315 |
-
"chatPlace": "่ท่พ็ฑณไธฝ่ๅคฉ...", "send": "ๅ้", "home": "๐ ไธป้กต",
|
| 316 |
-
"searchPlace": "ๆ็ดขๅฐ็น (ไพๅฆ: ๆฑๅ)", "emilyName": "่พ็ฑณไธฝ (Emily)", "reportHeader": "ๆฅๅ",
|
| 317 |
-
"aiBtn": "AI ็น่ฏ", "mapLinkBtn": "ๅฐๅพ"
|
| 318 |
-
}}
|
| 319 |
}};
|
| 320 |
|
| 321 |
-
const GREETINGS = {{ "KO": "์๋
, ์๊ธฐ?
|
| 322 |
-
const LOAD_MSGS = {{ "KO": ["
|
| 323 |
const CAT_MAP = {{ "Traditional": 1, "Whiskey": 2, "Beer": 3, "Wine": 4, "Bar": 5 }};
|
| 324 |
const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
| 325 |
|
|
@@ -355,52 +308,66 @@ html_code = f"""
|
|
| 355 |
else {{ return "https://www.google.com/maps/search/" + encodeURIComponent(name) + "/@" + lat + "," + lon + ",18z"; }}
|
| 356 |
}}
|
| 357 |
|
| 358 |
-
|
| 359 |
-
|
| 360 |
function renderList() {{
|
| 361 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 362 |
const stamps = getStamps();
|
| 363 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
|
|
|
| 364 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 365 |
-
|
|
|
|
| 366 |
const t = TRANSLATIONS[currentLang];
|
| 367 |
|
| 368 |
filtered.forEach((p, idx) => {{
|
| 369 |
-
const card = document.createElement('div');
|
| 370 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 371 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 372 |
let desc = (currentLang === 'KO' ? p.desc_ko : (currentLang === 'EN' ? p.desc_en : (currentLang === 'JP' ? p.desc_jp : p.desc_cn))) || p.desc_en || "No description.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
let catIdx = CAT_MAP[p.category] || 0;
|
| 374 |
let translatedCat = t.filters[catIdx] || p.category;
|
| 375 |
-
const addr = p.address || "";
|
| 376 |
-
const mapLink = getMapUrl(p.name, selectedCountry, p.lat, p.lon, addr);
|
| 377 |
|
| 378 |
-
//
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
card.innerHTML = "<div class='visited-badge'>VISITED ๐ฎ</div><b>" + safeName + "</b><div class='pc-cat'>" + translatedCat + "</div><div class='pc-desc'>" + safeDesc + "</div>" +
|
| 384 |
-
"<div class='card-actions'><button class='btn-action btn-ai' onclick='openDetailByIndex(" + idx + ")'>" + t.aiBtn + "</button>" +
|
| 385 |
-
"<button class='btn-action btn-map' onclick='openMapLink(\"" + safeMapLink + "\")'>" + t.mapLinkBtn + "</button></div>";
|
| 386 |
list.appendChild(card);
|
| 387 |
}});
|
| 388 |
}}
|
| 389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
function getStamps() {{
|
| 391 |
try {{ return JSON.parse(localStorage.getItem('drunk_passport') || '[]'); }}
|
| 392 |
catch(e) {{ localStorage.setItem('drunk_passport', '[]'); return []; }}
|
| 393 |
}}
|
| 394 |
|
| 395 |
function stampCurrentPlace() {{
|
| 396 |
-
if(!currentDetailPlace) {{ alert("
|
| 397 |
const stamps = getStamps();
|
| 398 |
const exists = stamps.find(s => s.name === currentDetailPlace.name && s.country === currentDetailPlace.country);
|
| 399 |
-
if(exists) {{ alert("
|
| 400 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 401 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 402 |
renderList();
|
| 403 |
-
alert("
|
| 404 |
}}
|
| 405 |
|
| 406 |
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
|
@@ -414,7 +381,7 @@ html_code = f"""
|
|
| 414 |
el.innerHTML = "<div class='stamp-mark' style='transform: rotate(" + rot + "deg)'><div class='stamp-country'>" + s.country + "</div><div class='stamp-name'>" + s.name + "</div><div class='stamp-date'>" + s.date + "</div></div>";
|
| 415 |
grid.appendChild(el);
|
| 416 |
}});
|
| 417 |
-
if(stamps.length === 0) grid.innerHTML = "<div style='color:#666; text-align:center; width:100%; margin-top:50px; grid-column: 1/-1;'>
|
| 418 |
}}
|
| 419 |
|
| 420 |
function exportData() {{
|
|
@@ -430,9 +397,9 @@ html_code = f"""
|
|
| 430 |
reader.onload = function(e) {{
|
| 431 |
try {{
|
| 432 |
const data = JSON.parse(e.target.result);
|
| 433 |
-
if(Array.isArray(data)) {{ localStorage.setItem('drunk_passport', JSON.stringify(data)); renderPassport(); renderList(); alert("Loaded!"); }}
|
| 434 |
else {{ alert("Invalid File"); }}
|
| 435 |
-
}} catch(err) {{ alert("Error"); }}
|
| 436 |
}};
|
| 437 |
reader.readAsText(file);
|
| 438 |
}}
|
|
@@ -479,24 +446,26 @@ html_code = f"""
|
|
| 479 |
|
| 480 |
function addChatMessage(t, s, html=false) {{ const box = document.getElementById('chat-messages'); const div = document.createElement('div'); div.className = "msg " + s; if(html) div.innerHTML = t.replace(/\\n/g, '<br>'); else div.innerText = t; box.appendChild(div); box.scrollTop = box.scrollHeight; return div; }}
|
| 481 |
|
| 482 |
-
// [ํต์ฌ
|
| 483 |
function openWorldMapPage() {{
|
| 484 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 485 |
if(!worldMap) {{
|
| 486 |
worldMap = L.map('full-map').setView([20, 0], 2); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 487 |
-
|
| 488 |
|
| 489 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 490 |
if(p.lat && p.lon) {{
|
| 491 |
-
// ์ขํ๋ฅผ ๊ณ ์
|
| 492 |
const key = p.lat + "_" + p.lon;
|
| 493 |
-
|
|
|
|
|
|
|
| 494 |
|
| 495 |
-
//
|
| 496 |
-
const popupContent = "<div style='text-align:center'><b>" +
|
| 497 |
"<div style='display:flex; gap:5px; margin-top:5px; justify-content:center;'>" +
|
| 498 |
-
"<button onclick=\"
|
| 499 |
-
"<button onclick=\"
|
| 500 |
"</div></div>";
|
| 501 |
L.marker([p.lat, p.lon]).bindPopup(popupContent).addTo(worldMap);
|
| 502 |
}}
|
|
@@ -505,14 +474,14 @@ html_code = f"""
|
|
| 505 |
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 506 |
}}
|
| 507 |
|
| 508 |
-
//
|
| 509 |
-
function
|
| 510 |
-
const data =
|
| 511 |
if(data) {{ closeWorldMapPage(); openDetail(data.name, data.country); }}
|
| 512 |
}}
|
| 513 |
|
| 514 |
-
function
|
| 515 |
-
const data =
|
| 516 |
if(data) window.open(data.url, '_blank');
|
| 517 |
}}
|
| 518 |
|
|
@@ -526,8 +495,7 @@ html_code = f"""
|
|
| 526 |
function flyToUserLocation() {{ if(userLat && userLon) {{ worldMap.flyTo([userLat, userLon], 13); L.marker([userLat, userLon]).addTo(worldMap).bindPopup("๐ You").openPopup(); }} else alert("GPS..."); }}
|
| 527 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 528 |
|
| 529 |
-
function
|
| 530 |
-
function openDetailByIndex(idx) {{ const p = currentFilteredList[idx]; if(p) openDetail(p.name, selectedCountry); }}
|
| 531 |
async function openDetail(n, c) {{
|
| 532 |
const p = (PLACE_DB[c] || []).find(x => x.name === n); if(!p) return;
|
| 533 |
currentDetailPlace = {{ name: n, country: c }};
|
|
@@ -540,8 +508,6 @@ html_code = f"""
|
|
| 540 |
}}
|
| 541 |
|
| 542 |
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 543 |
-
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 544 |
-
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 545 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 546 |
</script>
|
| 547 |
</body>
|
|
|
|
| 8 |
import io
|
| 9 |
|
| 10 |
# ==========================================
|
| 11 |
+
# ๐ 1. ์ค์ ๋ฐ ์ํฌ๋ฆฟ ๋ก๋
|
| 12 |
# ==========================================
|
| 13 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 14 |
SHEET_URL = os.environ.get("PRIVATE_SHEET_URL")
|
|
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
+
# 2. ๋ฐ์ดํฐ ๋ก๋ ๋ฐ "๊ฐ๋ ฅํ" ์ ์
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
| 31 |
if not GROQ_API_KEY:
|
| 32 |
+
st.error("๐จ 'GROQ_API_KEY'๊ฐ ์์ต๋๋ค! Settings > Secrets๋ฅผ ํ์ธํด์ฃผ์ธ์.")
|
| 33 |
|
| 34 |
try:
|
| 35 |
if SHEET_URL:
|
| 36 |
response = requests.get(SHEET_URL)
|
| 37 |
response.raise_for_status()
|
| 38 |
|
| 39 |
+
# 1. CSV ํ์ฑ
|
| 40 |
try:
|
| 41 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 42 |
except:
|
| 43 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 44 |
|
| 45 |
+
# 2. [๊ฐ์ฅ ์ค์] ๋ฐ์ดํฐ ๋์ฒญ์ (Sanitization)
|
| 46 |
+
# ์ค๋ฐ๊ฟ, ํญ, ๋ฐ์ดํ ๋ฑ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ๊นจ๋จ๋ฆด ์ ์๋ ๋ชจ๋ ํน์๋ฌธ์ ์ ๊ฑฐ/์นํ
|
| 47 |
+
df = df.replace({r'\r': ' ', r'\n': ' ', r'\t': ' ', r'"': "'"}, regex=True)
|
| 48 |
+
|
| 49 |
+
# ์ปฌ๋ผ ์ด๋ฆ ์ ๋ฆฌ
|
| 50 |
df.columns = df.columns.str.strip()
|
| 51 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
| 52 |
df.rename(columns=col_mapping, inplace=True)
|
| 53 |
|
| 54 |
+
# 3. JSON ๊ตฌ์กฐ ๋ณํ
|
| 55 |
if 'Country' in df.columns:
|
| 56 |
for country, group in df.groupby('Country'):
|
| 57 |
+
# NaN ๊ฐ์ ๋น ๋ฌธ์์ด๋ก ์ฒ๋ฆฌ
|
| 58 |
cleaned_group = group.fillna("").to_dict(orient='records')
|
| 59 |
PLACE_DB[country] = cleaned_group
|
| 60 |
else:
|
|
|
|
| 65 |
PLACE_DB = json.load(f)
|
| 66 |
|
| 67 |
except Exception as e:
|
| 68 |
+
st.error(f"โ ๋ฐ์ดํฐ ๋ก๋ ์คํจ: {e}")
|
| 69 |
PLACE_DB = {}
|
| 70 |
|
| 71 |
# ==========================================
|
|
|
|
| 78 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 79 |
except: pass
|
| 80 |
|
| 81 |
+
# JSON ๋คํ ์ ensure_ascii=False๋ก ํ๊ธ ๊นจ์ง ๋ฐฉ์ง
|
| 82 |
db_json_raw = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 83 |
db_base64 = base64.b64encode(db_json_raw.encode('utf-8')).decode('utf-8')
|
| 84 |
|
| 85 |
# ==========================================
|
| 86 |
+
# 4. ํ๋ก ํธ์๋ (HTML/JS/CSS) - Safe Logic ์ ์ฉ
|
| 87 |
# ==========================================
|
| 88 |
html_code = f"""
|
| 89 |
<!DOCTYPE html>
|
|
|
|
| 101 |
:root {{ --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }}
|
| 102 |
body {{ margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }}
|
| 103 |
.page {{ position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }}
|
| 104 |
+
#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; align-items: center; justify-content: flex-start; padding-top: 20px; }}
|
| 105 |
|
| 106 |
+
.bartender-btn {{ position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%; background-image: url('data:image/jpeg;base64,{emily_base64}'); background-size: cover; background-position: center; background-color: #222; border: 3px solid var(--gold); box-shadow: 0 8px 30px rgba(212, 175, 55, 0.6); cursor: pointer; z-index: 999; animation: bounce-float 3s ease-in-out infinite; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
| 108 |
|
| 109 |
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
|
|
|
|
| 113 |
.brand-title {{ font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 4px; margin-top: 10px; text-transform: uppercase; }}
|
| 114 |
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px; }}
|
| 115 |
|
| 116 |
+
.world-map-btn {{ background: rgba(212, 175, 55, 0.2); border: 1px solid var(--gold); color: var(--gold); padding: 12px 25px; border-radius: 30px; font-weight: bold; cursor: pointer; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(5px); }}
|
| 117 |
+
.passport-btn {{ background: rgba(0,0,0,0.6); border: 1px solid var(--gold); color: var(--gold); padding: 8px 15px; border-radius: 20px; font-size: 12px; cursor: pointer; margin-top: 10px; display: flex; align-items: center; gap: 5px; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
.country-select-wrapper {{ width: 85%; max-width: 400px; margin-bottom: 15px; }}
|
| 120 |
.country-select {{ width: 100%; padding: 14px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold); color: white; font-size: 16px; border-radius: 10px; outline: none; }}
|
|
|
|
| 124 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 125 |
|
| 126 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 127 |
+
.place-card {{ background: rgba(30,30,30,0.6); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); border-radius: 15px; padding: 18px; margin-bottom: 15px; position: relative; transition: all 0.3s ease; }}
|
| 128 |
+
.place-card.visited {{ background: linear-gradient(135deg, rgba(40,10,10,0.9), rgba(20,20,20,0.9)); border: 1px solid var(--gold); box-shadow: 0 0 15px rgba(212, 175, 55, 0.2); }}
|
| 129 |
+
.visited-badge {{ position: absolute; top: 10px; right: 10px; background: var(--gold); color: black; font-size: 10px; font-weight: bold; padding: 3px 8px; border-radius: 10px; display: none; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
.place-card.visited .visited-badge {{ display: block; }}
|
| 131 |
|
| 132 |
.pc-name {{ font-size: 18px; font-weight: bold; color: white; }}
|
| 133 |
.place-card.visited .pc-name {{ color: var(--gold); }}
|
| 134 |
.pc-cat {{ font-size: 11px; color: var(--gold); font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }}
|
| 135 |
.pc-desc {{ font-size: 13px; color: #bbb; line-height: 1.5; margin-top: 5px; }}
|
| 136 |
+
|
| 137 |
.card-actions {{ display: flex; gap: 10px; margin-top: 15px; }}
|
| 138 |
.btn-action {{ flex: 1; padding: 12px; border-radius: 8px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; }}
|
| 139 |
.btn-ai {{ background: var(--gold); color: black; }}
|
|
|
|
| 258 |
let miniMap = null, worldMap = null, worldMarkers = L.layerGroup();
|
| 259 |
let chatHistory = [];
|
| 260 |
let currentDetailPlace = null;
|
|
|
|
| 261 |
|
| 262 |
+
// [ํต์ฌ ๋ณ๊ฒฝ 1] ๋ฆฌ์คํธ์ ๋งต ๋ฐ์ดํฐ "๊ธ๊ณ " (Global Cache)
|
| 263 |
+
// HTML์ ๋ฐ์ดํฐ๋ฅผ ์ง์ ๋ฃ์ง ์๊ณ , ์ด๊ณณ์ ์ ์ฅ ํ "๋ฒํธํ(Key)"๋ก๋ง ๋ถ๋ฌ์ต๋๋ค.
|
| 264 |
+
let LIST_CACHE = [];
|
| 265 |
+
let MAP_CACHE = {{}};
|
| 266 |
|
| 267 |
const TRANSLATIONS = {{
|
| 268 |
+
"KO": {{ "sub": "๊ธ๋ก๋ฒ ์ฃผ๋ฅ ํค๋ฆฌํฐ์ง ํฌ์ด", "ai": "Korean", "mapBtn": "๐บ๏ธ ์๋๋งต ํํ", "passBtn": "๐ ๋ด ์ฌ๊ถ", "filters": ["๐ ์ ์ฒด", "๐บ ์ ํต์ฃผ", "๐ฅ ์์คํค", "๐บ ๋งฅ์ฃผ", "๐ท ์์ธ", "๐น ๋ฐ"], "chatPlace": "์๋ฐ๋ฆฌ์๊ฒ ๋งํด๋ด, ์๊ธฐ์ผ...", "send": "์ ์ก", "home": "๐ ํ", "searchPlace": "์ฅ์ ๊ฒ์ (์: ๊ฐ๋จ)", "emilyName": "์๋ฐ๋ฆฌ (Emily)", "reportHeader": "๋ฆฌํฌํธ", "aiBtn": "AI ๋ฆฌ๋ทฐ", "mapLinkBtn": "์ง๋" }},
|
| 269 |
+
"EN": {{ "sub": "GLOBAL ALCOHOL HERITAGE TOUR", "ai": "English", "mapBtn": "๐บ๏ธ WORLD MAP EXPLORER", "passBtn": "๐ MY PASSPORT", "filters": ["๐ All", "๐บ Trad.", "๐ฅ Whiskey", "๐บ Beer", "๐ท Wine", "๐น Bar"], "chatPlace": "Talk to Emily...", "send": "SEND", "home": "๐ HOME", "searchPlace": "Search (e.g. Gangnam)", "emilyName": "Emily", "reportHeader": "REPORT", "aiBtn": "AI REVIEW", "mapLinkBtn": "MAP" }},
|
| 270 |
+
"JP": {{ "sub": "ไธ็ใฎใ้
ใใชใใผใธใใขใผ", "ai": "Japanese", "mapBtn": "๐บ๏ธ ไธ็ๅฐๅณๆข็ดข", "passBtn": "๐ ใใคใในใใผใ", "filters": ["๐ ๅ
จใฆ", "๐บ ไผ็ตฑ้
", "๐ฅ ใฆใคในใญใผ", "๐บ ใใผใซ", "๐ท ใฏใคใณ", "๐น ใใผ"], "chatPlace": "ใจใใชใผใซ่ฉฑใใใใฆ...", "send": "้ไฟก", "home": "๐ ใใผใ ", "searchPlace": "ๅ ดๆๆค็ดข (ไพ: ๆฐๅฎฟ)", "emilyName": "ใจใใชใผ (Emily)", "reportHeader": "ใฌใใผใ", "aiBtn": "AI ใฌใใฅใผ", "mapLinkBtn": "ๅฐๅณ" }},
|
| 271 |
+
"CN": {{ "sub": "ๅ
จ็้
็ฑป้ไบงไนๆ
", "ai": "Chinese", "mapBtn": "๐บ๏ธ ไธ็ๅฐๅพๆข็ดข", "passBtn": "๐ ๆ็ๆค็
ง", "filters": ["๐ ๅ
จ้จ", "๐บ ไผ ็ป้
", "๐ฅ ๅจๅฃซๅฟ", "๐บ ๅค้
", "๐ท ่ก่้
", "๐น ้
ๅง"], "chatPlace": "่ท่พ็ฑณไธฝ่ๅคฉ...", "send": "ๅ้", "home": "๐ ไธป้กต", "searchPlace": "ๆ็ดขๅฐ็น (ไพๅฆ: ๆฑๅ)", "emilyName": "่พ็ฑณไธฝ (Emily)", "reportHeader": "ๆฅๅ", "aiBtn": "AI ็น่ฏ", "mapLinkBtn": "ๅฐๅพ" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
}};
|
| 273 |
|
| 274 |
+
const GREETINGS = {{ "KO": "์๋
, ์๊ธฐ? ์ค๋ ์ ๋ง ๊ณ ์ ๋ง์์ด. ์๋ฐ๋ฆฌํํ
๋ญ๋ ๋ฌผ์ด๋ด~", "EN": "Hey darling, rough day? Let Emily pour you a drink.", "JP": "ใใใใใใผใไปๆฅใฏใ็ฒใๆงใใจใใชใผใซใชใใงใ่ใใฆ๏ผ", "CN": "ไบฒ็ฑ็๏ผไปๅคฉ่พ่ฆไบใๆไปไนๆณๅ็ๅ๏ผ" }};
|
| 275 |
+
const LOAD_MSGS = {{ "KO": ["์~ ์๊ธฐ๋ฅผ ์ํ ์ฑ์ง๊ฐ ์ด๋ ์๋๋ผ?", "๊ธ๋ฐ ๋จธ๋ฆฌ ์ข ์ ๋ฆฌํ๊ณ ์๋ ค์ค๊ฒ!"], "EN": ["Searching for your perfect spot...", "Fixing my hair, one sec!"], "JP": ["้ไธญใใฆใใ...", "้ซชใๆดใใฆใใใซๆใใใใญ"], "CN": ["ๆญฃๅจๅพๅฌ...", "ๆญฃๅจๆด็้ๅ..."] }};
|
| 276 |
const CAT_MAP = {{ "Traditional": 1, "Whiskey": 2, "Beer": 3, "Wine": 4, "Bar": 5 }};
|
| 277 |
const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
| 278 |
|
|
|
|
| 308 |
else {{ return "https://www.google.com/maps/search/" + encodeURIComponent(name) + "/@" + lat + "," + lon + ",18z"; }}
|
| 309 |
}}
|
| 310 |
|
| 311 |
+
// [ํต์ฌ ๋ณ๊ฒฝ 2] ๋ฆฌ์คํธ ๋ ๋๋ง ๋ก์ง (์ธ๋ฑ์ค ๊ธฐ๋ฐ)
|
|
|
|
| 312 |
function renderList() {{
|
| 313 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 314 |
const stamps = getStamps();
|
| 315 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
| 316 |
+
|
| 317 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 318 |
+
LIST_CACHE = filtered; // ํ์ฌ ๋ฆฌ์คํธ๋ฅผ ์ ์ญ ๋ณ์์ ์ ์ฅ (์ธ๋ฑ์ค๋ก ์ ๊ทผํ๊ธฐ ์ํจ)
|
| 319 |
+
|
| 320 |
const t = TRANSLATIONS[currentLang];
|
| 321 |
|
| 322 |
filtered.forEach((p, idx) => {{
|
| 323 |
+
const card = document.createElement('div');
|
| 324 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 325 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 326 |
let desc = (currentLang === 'KO' ? p.desc_ko : (currentLang === 'EN' ? p.desc_en : (currentLang === 'JP' ? p.desc_jp : p.desc_cn))) || p.desc_en || "No description.";
|
| 327 |
+
|
| 328 |
+
// HTML ํ์์ฉ (๋ฐ์ดํ ์ ๊ฑฐ)
|
| 329 |
+
const displayDesc = String(desc).replace(/['"]/g, "");
|
| 330 |
+
const displayName = String(p.name).replace(/['"]/g, "");
|
| 331 |
+
|
| 332 |
let catIdx = CAT_MAP[p.category] || 0;
|
| 333 |
let translatedCat = t.filters[catIdx] || p.category;
|
|
|
|
|
|
|
| 334 |
|
| 335 |
+
// onclick์๋ ์ค์ง 'idx'(์ซ์)๋ง ์ ๋ฌ -> ์๋ฌ ์์ฒ ์ฐจ๋จ
|
| 336 |
+
card.innerHTML = "<div class='visited-badge'>VISITED ๐ฎ</div><b>" + displayName + "</b><div class='pc-cat'>" + translatedCat + "</div><div class='pc-desc'>" + displayDesc + "</div>" +
|
| 337 |
+
"<div class='card-actions'><button class='btn-action btn-ai' onclick='clickListDetail(" + idx + ")'>" + t.aiBtn + "</button>" +
|
| 338 |
+
"<button class='btn-action btn-map' onclick='clickListMap(" + idx + ")'>" + t.mapLinkBtn + "</button></div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
list.appendChild(card);
|
| 340 |
}});
|
| 341 |
}}
|
| 342 |
|
| 343 |
+
// [ํต์ฌ ๋ณ๊ฒฝ 3] ๋ฆฌ์คํธ ํด๋ฆญ ํธ๋ค๋ฌ (์ธ๋ฑ์ค๋ก ๋ฐ์ดํฐ ์ฐพ๊ธฐ)
|
| 344 |
+
function clickListDetail(idx) {{
|
| 345 |
+
const p = LIST_CACHE[idx];
|
| 346 |
+
if(p) openDetail(p.name, selectedCountry);
|
| 347 |
+
}}
|
| 348 |
+
|
| 349 |
+
function clickListMap(idx) {{
|
| 350 |
+
const p = LIST_CACHE[idx];
|
| 351 |
+
if(p) {{
|
| 352 |
+
const url = getMapUrl(p.name, selectedCountry, p.lat, p.lon, p.address || "");
|
| 353 |
+
window.open(url, '_blank');
|
| 354 |
+
}}
|
| 355 |
+
}}
|
| 356 |
+
|
| 357 |
function getStamps() {{
|
| 358 |
try {{ return JSON.parse(localStorage.getItem('drunk_passport') || '[]'); }}
|
| 359 |
catch(e) {{ localStorage.setItem('drunk_passport', '[]'); return []; }}
|
| 360 |
}}
|
| 361 |
|
| 362 |
function stampCurrentPlace() {{
|
| 363 |
+
if(!currentDetailPlace) {{ alert("No place selected."); return; }}
|
| 364 |
const stamps = getStamps();
|
| 365 |
const exists = stamps.find(s => s.name === currentDetailPlace.name && s.country === currentDetailPlace.country);
|
| 366 |
+
if(exists) {{ alert("Already Stamped! ๐ฎ"); return; }}
|
| 367 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 368 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 369 |
renderList();
|
| 370 |
+
alert("Stamped! ๐ฎ");
|
| 371 |
}}
|
| 372 |
|
| 373 |
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
|
|
|
| 381 |
el.innerHTML = "<div class='stamp-mark' style='transform: rotate(" + rot + "deg)'><div class='stamp-country'>" + s.country + "</div><div class='stamp-name'>" + s.name + "</div><div class='stamp-date'>" + s.date + "</div></div>";
|
| 382 |
grid.appendChild(el);
|
| 383 |
}});
|
| 384 |
+
if(stamps.length === 0) grid.innerHTML = "<div style='color:#666; text-align:center; width:100%; margin-top:50px; grid-column: 1/-1;'>No Stamps Yet.</div>";
|
| 385 |
}}
|
| 386 |
|
| 387 |
function exportData() {{
|
|
|
|
| 397 |
reader.onload = function(e) {{
|
| 398 |
try {{
|
| 399 |
const data = JSON.parse(e.target.result);
|
| 400 |
+
if(Array.isArray(data)) {{ localStorage.setItem('drunk_passport', JSON.stringify(data)); renderPassport(); renderList(); alert("Data Loaded!"); }}
|
| 401 |
else {{ alert("Invalid File"); }}
|
| 402 |
+
}} catch(err) {{ alert("File Error"); }}
|
| 403 |
}};
|
| 404 |
reader.readAsText(file);
|
| 405 |
}}
|
|
|
|
| 446 |
|
| 447 |
function addChatMessage(t, s, html=false) {{ const box = document.getElementById('chat-messages'); const div = document.createElement('div'); div.className = "msg " + s; if(html) div.innerHTML = t.replace(/\\n/g, '<br>'); else div.innerText = t; box.appendChild(div); box.scrollTop = box.scrollHeight; return div; }}
|
| 448 |
|
| 449 |
+
// [ํต์ฌ ๋ณ๊ฒฝ 4] ์๋๋งต ํ์
๋ก์ง (Key-Value ๋ฐฉ์)
|
| 450 |
function openWorldMapPage() {{
|
| 451 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 452 |
if(!worldMap) {{
|
| 453 |
worldMap = L.map('full-map').setView([20, 0], 2); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 454 |
+
MAP_CACHE = {{}}; // ์ด๊ธฐํ
|
| 455 |
|
| 456 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 457 |
if(p.lat && p.lon) {{
|
| 458 |
+
// ์ขํ๋ฅผ ๊ณ ์ ID(Key)๋ก ์ฌ์ฉ (๋ฌธ์์ด ์๋)
|
| 459 |
const key = p.lat + "_" + p.lon;
|
| 460 |
+
MAP_CACHE[key] = {{ name: p.name, country: c, url: getMapUrl(p.name, c, p.lat, p.lon, "") }};
|
| 461 |
+
|
| 462 |
+
const safeName = String(p.name).replace(/['"]/g, "");
|
| 463 |
|
| 464 |
+
// onclick์๋ ์ค์ง 'key'๋ง ์ ๋ฌ (ํน์๋ฌธ์ ์์)
|
| 465 |
+
const popupContent = "<div style='text-align:center'><b>" + safeName + "</b><br>" +
|
| 466 |
"<div style='display:flex; gap:5px; margin-top:5px; justify-content:center;'>" +
|
| 467 |
+
"<button onclick=\"clickMapDetail('" + key + "')\" style='background:#d4af37; border:none; border-radius:4px; padding:4px 8px; font-size:11px; cursor:pointer;'>๐ค REVIEW</button>" +
|
| 468 |
+
"<button onclick=\"clickMapLink('" + key + "')\" style='background:#333; color:white; border:1px solid #555; border-radius:4px; padding:4px 8px; font-size:11px; cursor:pointer;'>๐บ๏ธ MAP</button>" +
|
| 469 |
"</div></div>";
|
| 470 |
L.marker([p.lat, p.lon]).bindPopup(popupContent).addTo(worldMap);
|
| 471 |
}}
|
|
|
|
| 474 |
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 475 |
}}
|
| 476 |
|
| 477 |
+
// ๋งต ํด๋ฆญ ํธ๋ค๋ฌ (Key๋ก ๋ฐ์ดํฐ ์ฐพ๊ธฐ)
|
| 478 |
+
function clickMapDetail(key) {{
|
| 479 |
+
const data = MAP_CACHE[key];
|
| 480 |
if(data) {{ closeWorldMapPage(); openDetail(data.name, data.country); }}
|
| 481 |
}}
|
| 482 |
|
| 483 |
+
function clickMapLink(key) {{
|
| 484 |
+
const data = MAP_CACHE[key];
|
| 485 |
if(data) window.open(data.url, '_blank');
|
| 486 |
}}
|
| 487 |
|
|
|
|
| 495 |
function flyToUserLocation() {{ if(userLat && userLon) {{ worldMap.flyTo([userLat, userLon], 13); L.marker([userLat, userLon]).addTo(worldMap).bindPopup("๐ You").openPopup(); }} else alert("GPS..."); }}
|
| 496 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 497 |
|
| 498 |
+
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
|
|
|
| 499 |
async function openDetail(n, c) {{
|
| 500 |
const p = (PLACE_DB[c] || []).find(x => x.name === n); if(!p) return;
|
| 501 |
currentDetailPlace = {{ name: n, country: c }};
|
|
|
|
| 508 |
}}
|
| 509 |
|
| 510 |
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
|
|
|
|
|
|
| 511 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 512 |
</script>
|
| 513 |
</body>
|