Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,14 +8,15 @@ import requests
|
|
| 8 |
import io
|
| 9 |
|
| 10 |
# ==========================================
|
| 11 |
-
# 🔐 시크릿 로드
|
| 12 |
# ==========================================
|
|
|
|
| 13 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 14 |
SHEET_URL = os.environ.get("PRIVATE_SHEET_URL")
|
| 15 |
|
| 16 |
st.set_page_config(page_title="Drunken Plane", page_icon="✈️", layout="wide")
|
| 17 |
|
| 18 |
-
# Streamlit
|
| 19 |
st.markdown("""
|
| 20 |
<style>
|
| 21 |
.block-container { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
|
|
@@ -25,53 +26,55 @@ st.markdown("""
|
|
| 25 |
""", unsafe_allow_html=True)
|
| 26 |
|
| 27 |
# ==========================================
|
| 28 |
-
# 2. 데이터 로드 (
|
| 29 |
# ==========================================
|
| 30 |
PLACE_DB = {}
|
| 31 |
|
| 32 |
-
# 시크릿 키
|
| 33 |
if not GROQ_API_KEY:
|
| 34 |
-
st.error("🚨 'GROQ_API_KEY'가 없습니다! Settings > Secrets
|
| 35 |
|
| 36 |
try:
|
| 37 |
if SHEET_URL:
|
| 38 |
-
#
|
| 39 |
response = requests.get(SHEET_URL)
|
| 40 |
response.raise_for_status()
|
| 41 |
|
| 42 |
-
# CSV
|
| 43 |
try:
|
| 44 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 45 |
except:
|
|
|
|
| 46 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 47 |
|
| 48 |
-
# 컬럼
|
| 49 |
df.columns = df.columns.str.strip()
|
| 50 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
| 51 |
df.rename(columns=col_mapping, inplace=True)
|
| 52 |
|
| 53 |
-
# JSON
|
| 54 |
if 'Country' in df.columns:
|
| 55 |
for country, group in df.groupby('Country'):
|
| 56 |
-
# NaN
|
| 57 |
cleaned_group = group.fillna("").to_dict(orient='records')
|
| 58 |
PLACE_DB[country] = cleaned_group
|
| 59 |
else:
|
| 60 |
-
st.error("🚨 CSV 파일에서 'Country' 컬럼을 찾을 수 없습니다.")
|
| 61 |
|
| 62 |
else:
|
| 63 |
-
#
|
| 64 |
if os.path.exists('places.json'):
|
| 65 |
with open('places.json', 'r', encoding='utf-8-sig') as f:
|
| 66 |
PLACE_DB = json.load(f)
|
| 67 |
|
| 68 |
except Exception as e:
|
| 69 |
-
st.error(f"❌ 데이터 로드 중 오류
|
| 70 |
PLACE_DB = {}
|
| 71 |
|
| 72 |
# ==========================================
|
| 73 |
-
# 3.
|
| 74 |
# ==========================================
|
|
|
|
| 75 |
emily_base64 = ""
|
| 76 |
if os.path.exists('emily.jpg'):
|
| 77 |
try:
|
|
@@ -79,11 +82,12 @@ if os.path.exists('emily.jpg'):
|
|
| 79 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 80 |
except: pass
|
| 81 |
|
|
|
|
| 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) -
|
| 87 |
# ==========================================
|
| 88 |
html_code = f"""
|
| 89 |
<!DOCTYPE html>
|
|
@@ -101,13 +105,16 @@ html_code = f"""
|
|
| 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 |
|
|
|
|
| 104 |
.page {{ position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }}
|
| 105 |
|
|
|
|
| 106 |
#main-page {{
|
| 107 |
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');
|
| 108 |
background-size: cover; background-position: center; z-index: 100; align-items: center; justify-content: flex-start; padding-top: 20px;
|
| 109 |
}}
|
| 110 |
|
|
|
|
| 111 |
.bartender-btn {{
|
| 112 |
position: fixed; bottom: 30%; right: 20px;
|
| 113 |
width: 85px; height: 85px; border-radius: 50%;
|
|
@@ -120,6 +127,7 @@ html_code = f"""
|
|
| 120 |
}}
|
| 121 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
| 122 |
|
|
|
|
| 123 |
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
|
| 124 |
.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: 11px; }}
|
| 125 |
.lang-btn.active {{ background: var(--gold); color: black; border-color: var(--gold); font-weight: bold; }}
|
|
@@ -145,6 +153,7 @@ html_code = f"""
|
|
| 145 |
.type-btn {{ padding: 8px 16px; border-radius: 20px; font-size: 12px; font-weight: bold; cursor: pointer; background: #222; color: #888; border: 1px solid #444; white-space: nowrap; }}
|
| 146 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 147 |
|
|
|
|
| 148 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 149 |
|
| 150 |
.place-card {{
|
|
@@ -175,6 +184,7 @@ html_code = f"""
|
|
| 175 |
.btn-ai {{ background: var(--gold); color: black; }}
|
| 176 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 177 |
|
|
|
|
| 178 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 179 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 180 |
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; position: relative; }}
|
|
@@ -189,6 +199,7 @@ html_code = f"""
|
|
| 189 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
| 190 |
.chat-input {{ flex: 1; background: #222; border: 1px solid #444; color: white; padding: 14px; border-radius: 10px; outline: none; }}
|
| 191 |
|
|
|
|
| 192 |
#detail-page {{ background: #111; z-index: 300; transform: translateX(100%); display: flex; flex-direction: column; }}
|
| 193 |
.nav-bar {{ height: 60px; background: rgba(0,0,0,0.9); border-bottom: 1px solid #333; display: flex; align-items: center; padding: 0 20px; justify-content: space-between; }}
|
| 194 |
#mini-map {{ width: 100%; height: 35%; border-bottom: 2px solid var(--gold); }}
|
|
@@ -200,6 +211,7 @@ html_code = f"""
|
|
| 200 |
}}
|
| 201 |
.stamp-btn:hover {{ background: #ffcc00; color: #4a1c1c; border-style: solid; }}
|
| 202 |
|
|
|
|
| 203 |
#passport-page {{ background: #1a1a1a; z-index: 400; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 204 |
.passport-cover {{
|
| 205 |
padding: 20px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center;
|
|
@@ -228,6 +240,7 @@ html_code = f"""
|
|
| 228 |
.data-controls {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; justify-content: center; }}
|
| 229 |
.data-btn {{ background: #333; border: 1px solid #555; color: #ccc; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-size: 12px; }}
|
| 230 |
|
|
|
|
| 231 |
#world-map-page {{ background: #111; z-index: 200; transform: translateY(100%); }}
|
| 232 |
#full-map {{ width: 100%; height: 100%; }}
|
| 233 |
|
|
@@ -249,6 +262,7 @@ html_code = f"""
|
|
| 249 |
animation: bounce-float 3s ease-in-out infinite;
|
| 250 |
}}
|
| 251 |
|
|
|
|
| 252 |
.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; }}
|
| 253 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 254 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
@@ -325,89 +339,50 @@ html_code = f"""
|
|
| 325 |
<div id="loader" class="loading-screen"><div class="loader-ring"></div><div id="loader-msg" style="color:var(--gold); font-family:monospace; margin-top:15px;"></div></div>
|
| 326 |
|
| 327 |
<script>
|
|
|
|
| 328 |
function b64DecodeUnicode(str) {{
|
| 329 |
return decodeURIComponent(atob(str).split('').map(function(c) {{
|
| 330 |
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
| 331 |
}}).join(''));
|
| 332 |
}}
|
| 333 |
|
|
|
|
| 334 |
const PLACE_DB = JSON.parse(b64DecodeUnicode("{db_base64}"));
|
| 335 |
let userLat = null, userLon = null, selectedCountry = "", selectedType = "All", currentLang = "KO", chatInitialized = false;
|
| 336 |
let miniMap = null, worldMap = null, worldMarkers = L.layerGroup();
|
| 337 |
let chatHistory = [];
|
| 338 |
let currentDetailPlace = null;
|
| 339 |
-
let currentFilteredList = [];
|
| 340 |
|
| 341 |
const TRANSLATIONS = {{
|
| 342 |
-
"KO": {{
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
"searchPlace": "장소 검색 (예: 강남)", "emilyName": "에밀리 (Emily)", "reportHeader": "리포트",
|
| 347 |
-
"aiBtn": "AI 리뷰", "mapLinkBtn": "지도"
|
| 348 |
-
}},
|
| 349 |
-
"EN": {{
|
| 350 |
-
"sub": "GLOBAL ALCOHOL HERITAGE TOUR", "ai": "English", "mapBtn": "🗺️ WORLD MAP EXPLORER", "passBtn": "📘 MY PASSPORT",
|
| 351 |
-
"filters": ["🌐 All", "🏺 Trad.", "🥃 Whiskey", "🍺 Beer", "🍷 Wine", "🍹 Bar"],
|
| 352 |
-
"chatPlace": "Talk to Emily...", "send": "SEND", "home": "🏠 HOME",
|
| 353 |
-
"searchPlace": "Search (e.g. Gangnam)", "emilyName": "Emily", "reportHeader": "REPORT",
|
| 354 |
-
"aiBtn": "AI REVIEW", "mapLinkBtn": "MAP"
|
| 355 |
-
}},
|
| 356 |
-
"JP": {{
|
| 357 |
-
"sub": "世界のお酒ヘリテージツアー", "ai": "Japanese", "mapBtn": "🗺️ 世界地図探索", "passBtn": "📘 マイパスポート",
|
| 358 |
-
"filters": ["🌐 全て", "🏺 伝統酒", "🥃 ウイスキー", "🍺 ビール", "🍷 ワイン", "🍹 バー"],
|
| 359 |
-
"chatPlace": "エミリーに話しかけて...", "send": "送信", "home": "🏠 ホーム",
|
| 360 |
-
"searchPlace": "場所検索 (例: 新宿)", "emilyName": "エミリー (Emily)", "reportHeader": "レポート",
|
| 361 |
-
"aiBtn": "AI レビュー", "mapLinkBtn": "地図"
|
| 362 |
-
}},
|
| 363 |
-
"CN": {{
|
| 364 |
-
"sub": "全球酒类遗产之旅", "ai": "Chinese", "mapBtn": "🗺️ 世界地图探索", "passBtn": "📘 我的护照",
|
| 365 |
-
"filters": ["🌐 全部", "🏺 传统酒", "🥃 威士忌", "🍺 啤酒", "🍷 葡萄酒", "🍹 酒吧"],
|
| 366 |
-
"chatPlace": "跟艾米丽聊天...", "send": "发送", "home": "🏠 主页",
|
| 367 |
-
"searchPlace": "搜索地点 (例如: 江南)", "emilyName": "艾米丽 (Emily)", "reportHeader": "报告",
|
| 368 |
-
"aiBtn": "AI 点评", "mapLinkBtn": "地图"
|
| 369 |
-
}}
|
| 370 |
-
}};
|
| 371 |
-
|
| 372 |
-
const GREETINGS = {{
|
| 373 |
-
"KO": "안녕, 자기? 오늘 정말 고생 많았어. 에밀리한테 뭐든 물어봐~",
|
| 374 |
-
"EN": "Hey darling, rough day? Let Emily pour you a drink. Ask me anything.",
|
| 375 |
-
"JP": "あら、ハニー。今日はお疲れ様。エミリーになんでも聞いて?",
|
| 376 |
-
"CN": "亲爱的,今天辛苦了。有什么想喝的吗?尽管问艾米丽吧。"
|
| 377 |
-
}};
|
| 378 |
-
|
| 379 |
-
const LOAD_MSGS = {{
|
| 380 |
-
"KO": ["음~ 자기를 위한 성지가 어디 있더라?", "금발 머리 좀 정리하고 알려줄게!", "에밀리가 지금 술장을 뒤지는 중이야!", "잠시만 기다려줘, 자기야!"],
|
| 381 |
-
"EN": ["Searching for your perfect spot...", "Fixing my hair, one sec!", "Emily is searching the bar cabinet!"],
|
| 382 |
-
"JP": ["集中してるわ...", "髪を整えてすぐに教えるわね"],
|
| 383 |
-
"CN": ["正在倾听...", "正在整理金发..."]
|
| 384 |
}};
|
| 385 |
|
|
|
|
|
|
|
| 386 |
const CAT_MAP = {{ "Traditional": 1, "Whiskey": 2, "Beer": 3, "Wine": 4, "Bar": 5 }};
|
| 387 |
const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
| 388 |
|
|
|
|
| 389 |
window.onload = function() {{
|
| 390 |
initCountryDropdown();
|
| 391 |
const keys = Object.keys(PLACE_DB).sort();
|
| 392 |
if(keys.length > 0) selectCountry(keys[0]);
|
| 393 |
-
navigator.geolocation.getCurrentPosition(p => {{
|
| 394 |
-
userLat = p.coords.latitude;
|
| 395 |
-
userLon = p.coords.longitude;
|
| 396 |
-
}}, err => console.log("GPS Not Available"));
|
| 397 |
}};
|
| 398 |
|
| 399 |
function initCountryDropdown() {{
|
| 400 |
const select = document.getElementById('country-select');
|
| 401 |
-
Object.keys(PLACE_DB).sort().forEach(c => {{
|
| 402 |
-
const opt = document.createElement('option'); opt.value = c; opt.text = c; select.appendChild(opt);
|
| 403 |
-
}});
|
| 404 |
}}
|
| 405 |
|
| 406 |
function setLanguage(lang, el) {{
|
| 407 |
currentLang = lang;
|
| 408 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
| 409 |
el.classList.add('active');
|
| 410 |
-
|
| 411 |
const t = TRANSLATIONS[currentLang];
|
| 412 |
document.getElementById('app-subtitle').innerText = t.sub;
|
| 413 |
document.getElementById('world-map-btn').innerText = t.mapBtn;
|
|
@@ -418,296 +393,168 @@ html_code = f"""
|
|
| 418 |
document.getElementById('map-search-input').placeholder = t.searchPlace;
|
| 419 |
document.getElementById('emily-name').innerText = t.emilyName;
|
| 420 |
document.getElementById('repo-header').innerText = t.reportHeader;
|
| 421 |
-
|
| 422 |
-
for(let i=0; i<6; i++) {{
|
| 423 |
-
document.getElementById('f-btn-' + i).innerText = t.filters[i];
|
| 424 |
-
}}
|
| 425 |
-
|
| 426 |
renderList();
|
| 427 |
}}
|
| 428 |
|
| 429 |
function selectCountry(c) {{ selectedCountry = c; renderList(); }}
|
| 430 |
-
function filterType(t, el) {{
|
| 431 |
-
selectedType = t;
|
| 432 |
-
document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected'));
|
| 433 |
-
el.classList.add('selected');
|
| 434 |
-
renderList();
|
| 435 |
-
}}
|
| 436 |
|
| 437 |
function getMapUrl(name, country, lat, lon, address) {{
|
| 438 |
-
if (country && (country.includes("Korea") || country.includes("한국") || country === "대한민국")) {{
|
| 439 |
-
|
| 440 |
-
return "https://map.naver.com/p/search/" + encodeURIComponent(query);
|
| 441 |
-
}} else {{
|
| 442 |
-
return "https://www.google.com/maps/search/" + encodeURIComponent(name) + "/@" + lat + "," + lon + ",18z";
|
| 443 |
-
}}
|
| 444 |
}}
|
| 445 |
|
| 446 |
-
// [
|
| 447 |
-
function
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
}}
|
| 454 |
}}
|
| 455 |
|
| 456 |
function renderList() {{
|
| 457 |
-
const list = document.getElementById('place-list');
|
| 458 |
-
list.innerHTML = "";
|
| 459 |
const stamps = getStamps();
|
| 460 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
| 461 |
-
|
| 462 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 463 |
-
currentFilteredList = filtered;
|
| 464 |
-
|
| 465 |
const t = TRANSLATIONS[currentLang];
|
| 466 |
|
| 467 |
filtered.forEach((p, idx) => {{
|
| 468 |
const card = document.createElement('div');
|
| 469 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 470 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
|
|
|
| 471 |
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
else if (currentLang === 'JP') desc = p.desc_jp;
|
| 476 |
-
else if (currentLang === 'CN') desc = p.desc_cn;
|
| 477 |
-
|
| 478 |
-
if (!desc) desc = p.desc_en || p.desc_ko || "No description available.";
|
| 479 |
-
|
| 480 |
-
// [안전장치] HTML 표시용 텍스트 정화 (따옴표를 엔티티로 변환)
|
| 481 |
-
const safeName = String(p.name).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
| 482 |
-
const safeDesc = String(desc).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
| 483 |
-
|
| 484 |
let catIdx = CAT_MAP[p.category] || 0;
|
| 485 |
let translatedCat = t.filters[catIdx] || p.category;
|
|
|
|
|
|
|
| 486 |
|
| 487 |
-
// [핵심]
|
| 488 |
-
card.innerHTML = "<div class='visited-badge'>VISITED 💮</div>" +
|
| 489 |
-
"<
|
| 490 |
-
"<
|
| 491 |
-
"<div class='pc-desc'>" + safeDesc + "</div>" +
|
| 492 |
-
"<div class='card-actions'>" +
|
| 493 |
-
"<button class='btn-action btn-ai' onclick='openDetailByIndex(" + idx + ")'>" + t.aiBtn + "</button>" +
|
| 494 |
-
"<button class='btn-action btn-map' onclick='openMapLinkByIndex(" + idx + ")'>" + t.mapLinkBtn + "</button></div>";
|
| 495 |
list.appendChild(card);
|
| 496 |
}});
|
| 497 |
}}
|
| 498 |
|
| 499 |
function getStamps() {{
|
| 500 |
-
try {{
|
| 501 |
-
|
| 502 |
-
}} catch(e) {{
|
| 503 |
-
localStorage.setItem('drunk_passport', '[]');
|
| 504 |
-
return [];
|
| 505 |
-
}}
|
| 506 |
}}
|
| 507 |
|
| 508 |
function stampCurrentPlace() {{
|
| 509 |
-
if(!currentDetailPlace) {{ alert("
|
| 510 |
const stamps = getStamps();
|
| 511 |
-
|
| 512 |
const exists = stamps.find(s => s.name === currentDetailPlace.name && s.country === currentDetailPlace.country);
|
| 513 |
-
if(exists) {{
|
| 514 |
-
|
| 515 |
-
return;
|
| 516 |
-
}}
|
| 517 |
-
|
| 518 |
-
stamps.push({{
|
| 519 |
-
name: currentDetailPlace.name,
|
| 520 |
-
country: currentDetailPlace.country,
|
| 521 |
-
date: new Date().toLocaleDateString()
|
| 522 |
-
}});
|
| 523 |
-
|
| 524 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 525 |
renderList();
|
| 526 |
alert("방문 인증 완료! 💮");
|
| 527 |
}}
|
| 528 |
|
| 529 |
-
function openPassportPage() {{
|
| 530 |
-
document.getElementById('passport-page').style.transform = 'translateY(0%)';
|
| 531 |
-
renderPassport();
|
| 532 |
-
}}
|
| 533 |
-
|
| 534 |
function renderPassport() {{
|
| 535 |
-
const grid = document.getElementById('passport-grid');
|
| 536 |
-
grid.innerHTML = "";
|
| 537 |
const stamps = getStamps();
|
| 538 |
-
|
| 539 |
stamps.forEach(s => {{
|
| 540 |
if(!s || !s.name) return;
|
| 541 |
-
const el = document.createElement('div');
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
el.innerHTML = "<div class='stamp-mark' style='transform: rotate(" + rot + "deg)'>" +
|
| 545 |
-
"<div class='stamp-country'>" + s.country + "</div>" +
|
| 546 |
-
"<div class='stamp-name'>" + s.name + "</div>" +
|
| 547 |
-
"<div class='stamp-date'>" + s.date + "</div></div>";
|
| 548 |
grid.appendChild(el);
|
| 549 |
}});
|
| 550 |
-
|
| 551 |
-
if(stamps.length === 0) {{
|
| 552 |
-
grid.innerHTML = "<div style='color:#666; text-align:center; width:100%; margin-top:50px; grid-column: 1/-1;'>아직 도장이 없어요.<br>술 한 잔 하러 가볼까요? 🍻</div>";
|
| 553 |
-
}}
|
| 554 |
}}
|
| 555 |
|
| 556 |
function exportData() {{
|
| 557 |
const data = localStorage.getItem('drunk_passport');
|
| 558 |
const blob = new Blob([data], {{type: 'application/json'}});
|
| 559 |
const url = URL.createObjectURL(blob);
|
| 560 |
-
const a = document.createElement('a');
|
| 561 |
-
a.href = url;
|
| 562 |
-
a.download = 'drunk_passport_save.json';
|
| 563 |
-
a.click();
|
| 564 |
}}
|
| 565 |
|
| 566 |
function importData(input) {{
|
| 567 |
-
const file = input.files[0];
|
| 568 |
-
if(!file) return;
|
| 569 |
const reader = new FileReader();
|
| 570 |
reader.onload = function(e) {{
|
| 571 |
try {{
|
| 572 |
const data = JSON.parse(e.target.result);
|
| 573 |
-
if(Array.isArray(data)) {{
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
renderList();
|
| 577 |
-
alert("데이터를 성공적으로 불러왔습니다!");
|
| 578 |
-
}} else {{ alert("잘못된 파일 형식입니다."); }}
|
| 579 |
-
}} catch(err) {{ alert("파일을 읽는 중 오류가 발생했습니다."); }}
|
| 580 |
}};
|
| 581 |
reader.readAsText(file);
|
| 582 |
}}
|
| 583 |
|
| 584 |
-
function getDistance(lat1, lon1, lat2, lon2) {{
|
| 585 |
-
const R = 6371;
|
| 586 |
-
const dLat = (lat2 - lat1) * Math.PI / 180;
|
| 587 |
-
const dLon = (lon2 - lon1) * Math.PI / 180;
|
| 588 |
-
const a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
| 589 |
-
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
|
| 590 |
-
Math.sin(dLon/2) * Math.sin(dLon/2);
|
| 591 |
-
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
| 592 |
-
return R * c;
|
| 593 |
-
}}
|
| 594 |
-
|
| 595 |
async function callGroq(messages) {{
|
| 596 |
-
const apiKey = "{GROQ_API_KEY}";
|
| 597 |
-
if(!apiKey || apiKey.length < 10) {{
|
| 598 |
-
return "🚨 Groq API 키가 설정되지 않았습니다.";
|
| 599 |
-
}}
|
| 600 |
-
|
| 601 |
const url = "https://api.groq.com/openai/v1/chat/completions";
|
| 602 |
-
const models = ["llama-3.3-70b-versatile", "llama-3.1-70b-versatile", "
|
| 603 |
-
|
| 604 |
for (const model of models) {{
|
| 605 |
-
const payload = {{ model: model, messages: messages, temperature: 0.7, max_tokens: 2048 }};
|
| 606 |
try {{
|
| 607 |
-
const response = await fetch(url, {{
|
| 608 |
-
method: 'POST',
|
| 609 |
-
headers: {{ 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + apiKey }},
|
| 610 |
-
body: JSON.stringify(payload)
|
| 611 |
-
}});
|
| 612 |
if (!response.ok) throw new Error(response.statusText);
|
| 613 |
-
const data = await response.json();
|
| 614 |
-
|
| 615 |
-
}} catch (error) {{ console.log("Model failed: " + model); }}
|
| 616 |
-
}}
|
| 617 |
-
return "통신 상태가 좋지 않네요 😢 잠시 후 다시 시도해주세요.";
|
| 618 |
-
}}
|
| 619 |
-
|
| 620 |
-
function openChat() {{
|
| 621 |
-
document.getElementById('chat-page').style.transform = 'translateY(0%)';
|
| 622 |
-
if(!chatInitialized) {{
|
| 623 |
-
addChatMessage(GREETINGS[currentLang], 'bot');
|
| 624 |
-
chatInitialized = true;
|
| 625 |
-
chatHistory.push({{ role: "system", content: "You are Emily, a chic and flirtatious blonde bartender. IMPORTANT: Do NOT recommend immediately unless preference is clear. ASK clarifying questions first (e.g., 'Cocktail or Beer?', 'Loud or Quiet?'). Be engaging." }});
|
| 626 |
}}
|
|
|
|
| 627 |
}}
|
| 628 |
|
|
|
|
| 629 |
async function askBartender() {{
|
| 630 |
-
const input = document.getElementById('chat-input');
|
| 631 |
-
|
| 632 |
-
addChatMessage(msg, 'user'); input.value = "";
|
| 633 |
-
chatHistory.push({{ role: "user", content: msg }});
|
| 634 |
-
|
| 635 |
const loadingMsg = addChatMessage(getRandom(LOAD_MSGS[currentLang]), 'bot');
|
| 636 |
-
|
| 637 |
-
if(loadingMsg) loadingMsg.innerText = getRandom(LOAD_MSGS[currentLang]);
|
| 638 |
-
}}, 1800);
|
| 639 |
-
|
| 640 |
let nearbyPlaces = [];
|
| 641 |
if(userLat && userLon) {{
|
| 642 |
-
Object.keys(PLACE_DB).forEach(c => {{
|
| 643 |
-
PLACE_DB[c].forEach(p => {{
|
| 644 |
-
if(p.lat && p.lon) {{
|
| 645 |
-
const d = getDistance(userLat, userLon, p.lat, p.lon);
|
| 646 |
-
nearbyPlaces.push({{ ...p, country: c, dist: d }});
|
| 647 |
-
}}
|
| 648 |
-
}});
|
| 649 |
-
}});
|
| 650 |
-
nearbyPlaces.sort((a, b) => a.dist - b.dist);
|
| 651 |
-
}}
|
| 652 |
-
if(nearbyPlaces.length === 0 || nearbyPlaces[0].dist > 1000) {{
|
| 653 |
-
nearbyPlaces = (PLACE_DB[selectedCountry] || []).map(p => ({{...p, country: selectedCountry, dist: 0}}));
|
| 654 |
}}
|
|
|
|
|
|
|
| 655 |
|
| 656 |
-
const
|
| 657 |
-
p.name + " (" + (p.dist > 0 ? p.dist.toFixed(1) + "km away" : "in " + p.country) + ")"
|
| 658 |
-
).join(', ');
|
| 659 |
-
|
| 660 |
-
const targetLang = TRANSLATIONS[currentLang].ai;
|
| 661 |
-
const currentTurnMessages = [
|
| 662 |
-
...chatHistory,
|
| 663 |
-
{{ role: "system", content: "Current Context: User's Language setting is " + targetLang + ". You MUST ANSWER IN " + targetLang + " ONLY. Nearest places: [" + pool + "]. Format place name as [Name]." }}
|
| 664 |
-
];
|
| 665 |
-
|
| 666 |
-
const res = await callGroq(currentTurnMessages);
|
| 667 |
-
clearInterval(loadInt);
|
| 668 |
if(loadingMsg) loadingMsg.remove();
|
| 669 |
|
| 670 |
let finalMsg = res;
|
| 671 |
const match = res.match(/\[(.*?)\]/);
|
| 672 |
if(match) {{
|
| 673 |
-
const pName = match[1];
|
| 674 |
-
const found = nearbyPlaces.find(p => p.name.includes(pName));
|
| 675 |
if(found) {{
|
| 676 |
const mapUrl = getMapUrl(pName, found.country, found.lat, found.lon, "");
|
| 677 |
-
finalMsg += "<br><a href='" + mapUrl + "' target='_blank' class='reco-btn'>📍
|
| 678 |
}}
|
| 679 |
}}
|
| 680 |
-
addChatMessage(finalMsg, 'bot', true);
|
| 681 |
-
chatHistory.push({{ role: "assistant", content: res }});
|
| 682 |
}}
|
| 683 |
|
| 684 |
-
function addChatMessage(t, s, html=false) {{
|
| 685 |
-
const box = document.getElementById('chat-messages');
|
| 686 |
-
const div = document.createElement('div'); div.className = "msg " + s;
|
| 687 |
-
if(html) div.innerHTML = t.replace(/\\n/g, '<br>'); else div.innerText = t;
|
| 688 |
-
box.appendChild(div); box.scrollTop = box.scrollHeight; return div;
|
| 689 |
-
}}
|
| 690 |
|
|
|
|
| 691 |
function openWorldMapPage() {{
|
| 692 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 693 |
if(!worldMap) {{
|
| 694 |
-
worldMap = L.map('full-map').setView([20, 0], 2);
|
| 695 |
-
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 696 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 697 |
if(p.lat && p.lon) {{
|
| 698 |
-
|
| 699 |
-
const
|
| 700 |
-
const
|
| 701 |
-
|
| 702 |
-
// 팝업 내부 버튼도 index-based 호출로 변경하지 못하므로, 여기서는 단순히 이름만 표시하고 리뷰 기능은 리스트에서 하도록 유도하거나
|
| 703 |
-
// 혹은 가장 안전하게 그냥 텍스트만 표시합니다. (모바일에서 팝업 버튼은 잘 안 눌리기도 함)
|
| 704 |
-
// 하지만 기능을 유지하고 싶다면, 여기서는 안전하게 이스케이프된 문자열을 써야 합니다.
|
| 705 |
-
// 여기서는 간단하게 이름과 지도 버튼만 남기겠습니다. (안전 제일)
|
| 706 |
-
const safeName = String(p.name).replace(/"/g, """).replace(/'/g, "'");
|
| 707 |
|
|
|
|
| 708 |
const popupContent = "<div style='text-align:center'><b>" + safeName + "</b><br>" +
|
| 709 |
"<div style='display:flex; gap:5px; margin-top:5px; justify-content:center;'>" +
|
| 710 |
-
"<button onclick=\"
|
|
|
|
| 711 |
"</div></div>";
|
| 712 |
L.marker([p.lat, p.lon]).bindPopup(popupContent).addTo(worldMap);
|
| 713 |
}}
|
|
@@ -717,69 +564,30 @@ html_code = f"""
|
|
| 717 |
}}
|
| 718 |
|
| 719 |
async function searchLocation() {{
|
| 720 |
-
const query = document.getElementById('map-search-input').value;
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
const data = await res.json();
|
| 725 |
-
if(data && data.length > 0) {{
|
| 726 |
-
const lat = data[0].lat;
|
| 727 |
-
const lon = data[0].lon;
|
| 728 |
-
worldMap.flyTo([lat, lon], 12);
|
| 729 |
-
L.popup().setLatLng([lat, lon]).setContent("🔎 " + query).openOn(worldMap);
|
| 730 |
-
}} else {{
|
| 731 |
-
alert("Not Found");
|
| 732 |
-
}}
|
| 733 |
-
}} catch(e) {{ console.error(e); }}
|
| 734 |
}}
|
| 735 |
|
| 736 |
-
function flyToUserLocation() {{
|
| 737 |
-
|
| 738 |
-
worldMap.flyTo([userLat, userLon], 13);
|
| 739 |
-
L.marker([userLat, userLon]).addTo(worldMap).bindPopup("📍 You are here").openPopup();
|
| 740 |
-
}} else {{ alert("GPS Searching..."); }}
|
| 741 |
-
}}
|
| 742 |
|
| 743 |
function openDetailFromMap(n, c) {{ closeWorldMapPage(); openDetail(n, c); }}
|
| 744 |
-
|
| 745 |
-
function openDetailByIndex(idx) {{
|
| 746 |
-
const p = currentFilteredList[idx];
|
| 747 |
-
if(p) openDetail(p.name, selectedCountry);
|
| 748 |
-
}}
|
| 749 |
-
|
| 750 |
async function openDetail(n, c) {{
|
| 751 |
const p = (PLACE_DB[c] || []).find(x => x.name === n); if(!p) return;
|
| 752 |
currentDetailPlace = {{ name: n, country: c }};
|
| 753 |
-
|
| 754 |
-
document.getElementById('
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
if(!miniMap) {{
|
| 760 |
-
miniMap = L.map('mini-map');
|
| 761 |
-
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap);
|
| 762 |
-
}}
|
| 763 |
-
setTimeout(() => {{
|
| 764 |
-
miniMap.invalidateSize();
|
| 765 |
-
miniMap.setView([p.lat, p.lon], 15);
|
| 766 |
-
L.marker([p.lat, p.lon]).addTo(miniMap).bindPopup(p.name).openPopup();
|
| 767 |
-
}}, 400);
|
| 768 |
-
|
| 769 |
-
const targetLang = TRANSLATIONS[currentLang].ai;
|
| 770 |
-
const detailMessages = [
|
| 771 |
-
{{ role: "system", content: "Act as Emily. Write a DETAILED, structured travel report." }},
|
| 772 |
-
{{ role: "user", content: "Write a report for '" + n + "' in '" + c + "'. Include sections: 'Vibe & Atmosphere', 'Must Try Drinks/Food', 'Secret Tip'. Use Markdown. IMPORTANT: Write this report IN " + targetLang + " ONLY. " }}
|
| 773 |
-
];
|
| 774 |
-
|
| 775 |
-
const res = await callGroq(detailMessages);
|
| 776 |
-
document.getElementById('loader').style.display='none';
|
| 777 |
-
document.getElementById('repo-content').innerHTML = res.replace(/\\n/g, '<br>').replace(/###/g, '⭐');
|
| 778 |
}}
|
| 779 |
|
| 780 |
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 781 |
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 782 |
-
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 783 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 784 |
</script>
|
| 785 |
</body>
|
|
|
|
| 8 |
import io
|
| 9 |
|
| 10 |
# ==========================================
|
| 11 |
+
# 🔐 시크릿 로드 및 기본 설정
|
| 12 |
# ==========================================
|
| 13 |
+
# 허깅페이스 Settings > Variables and secrets에서 불러옵니다.
|
| 14 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 15 |
SHEET_URL = os.environ.get("PRIVATE_SHEET_URL")
|
| 16 |
|
| 17 |
st.set_page_config(page_title="Drunken Plane", page_icon="✈️", layout="wide")
|
| 18 |
|
| 19 |
+
# Streamlit 상단 여백 제거 스타일
|
| 20 |
st.markdown("""
|
| 21 |
<style>
|
| 22 |
.block-container { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
|
|
|
|
| 26 |
""", unsafe_allow_html=True)
|
| 27 |
|
| 28 |
# ==========================================
|
| 29 |
+
# 2. 데이터 로드 (Google Sheets -> DataFrame -> JSON)
|
| 30 |
# ==========================================
|
| 31 |
PLACE_DB = {}
|
| 32 |
|
| 33 |
+
# 시크릿 키 누락 경고 (디버깅용)
|
| 34 |
if not GROQ_API_KEY:
|
| 35 |
+
st.error("🚨 'GROQ_API_KEY'가 없습니다! Settings > Secrets 설정을 확인하세요.")
|
| 36 |
|
| 37 |
try:
|
| 38 |
if SHEET_URL:
|
| 39 |
+
# 1. CSV 다운로드
|
| 40 |
response = requests.get(SHEET_URL)
|
| 41 |
response.raise_for_status()
|
| 42 |
|
| 43 |
+
# 2. CSV 파싱 (형식 에러 방지 옵션 적용)
|
| 44 |
try:
|
| 45 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 46 |
except:
|
| 47 |
+
# 파이썬 엔진이 더 유연하게 읽어들임
|
| 48 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 49 |
|
| 50 |
+
# 3. 컬럼 정규화 (공백 제거, 대소문자 통일)
|
| 51 |
df.columns = df.columns.str.strip()
|
| 52 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
| 53 |
df.rename(columns=col_mapping, inplace=True)
|
| 54 |
|
| 55 |
+
# 4. JSON 변환 (국가별 그룹화)
|
| 56 |
if 'Country' in df.columns:
|
| 57 |
for country, group in df.groupby('Country'):
|
| 58 |
+
# NaN(빈값)을 빈 문자열로 처리 (JS 에러 방지 핵심)
|
| 59 |
cleaned_group = group.fillna("").to_dict(orient='records')
|
| 60 |
PLACE_DB[country] = cleaned_group
|
| 61 |
else:
|
| 62 |
+
st.error("🚨 CSV 파일에서 'Country' 컬럼을 찾을 수 없습니다. (헤더 확인 필요)")
|
| 63 |
|
| 64 |
else:
|
| 65 |
+
# 백업: 로컬 파일 사용
|
| 66 |
if os.path.exists('places.json'):
|
| 67 |
with open('places.json', 'r', encoding='utf-8-sig') as f:
|
| 68 |
PLACE_DB = json.load(f)
|
| 69 |
|
| 70 |
except Exception as e:
|
| 71 |
+
st.error(f"❌ 데이터 로드 중 치명적 오류: {e}")
|
| 72 |
PLACE_DB = {}
|
| 73 |
|
| 74 |
# ==========================================
|
| 75 |
+
# 3. 데이터 인코딩 (JS로 넘기기 위함)
|
| 76 |
# ==========================================
|
| 77 |
+
# 에밀리 이미지 로드
|
| 78 |
emily_base64 = ""
|
| 79 |
if os.path.exists('emily.jpg'):
|
| 80 |
try:
|
|
|
|
| 82 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 83 |
except: pass
|
| 84 |
|
| 85 |
+
# DB 데이터를 Base64로 인코딩 (특수문자/따옴표 충돌 원천 봉쇄)
|
| 86 |
db_json_raw = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 87 |
db_base64 = base64.b64encode(db_json_raw.encode('utf-8')).decode('utf-8')
|
| 88 |
|
| 89 |
# ==========================================
|
| 90 |
+
# 4. 프론트엔드 (HTML/JS/CSS) - Final Robust Version
|
| 91 |
# ==========================================
|
| 92 |
html_code = f"""
|
| 93 |
<!DOCTYPE html>
|
|
|
|
| 105 |
:root {{ --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }}
|
| 106 |
body {{ margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }}
|
| 107 |
|
| 108 |
+
/* 페이지 컨테이너 */
|
| 109 |
.page {{ position: absolute; top: 0; left: 0; width: 100%; height: 100vh; transition: transform 0.5s ease; display: flex; flex-direction: column; }}
|
| 110 |
|
| 111 |
+
/* 메인 배경 */
|
| 112 |
#main-page {{
|
| 113 |
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');
|
| 114 |
background-size: cover; background-position: center; z-index: 100; align-items: center; justify-content: flex-start; padding-top: 20px;
|
| 115 |
}}
|
| 116 |
|
| 117 |
+
/* 에밀리 버튼 (플로팅) */
|
| 118 |
.bartender-btn {{
|
| 119 |
position: fixed; bottom: 30%; right: 20px;
|
| 120 |
width: 85px; height: 85px; border-radius: 50%;
|
|
|
|
| 127 |
}}
|
| 128 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
| 129 |
|
| 130 |
+
/* 상단 UI 요소들 */
|
| 131 |
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
|
| 132 |
.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: 11px; }}
|
| 133 |
.lang-btn.active {{ background: var(--gold); color: black; border-color: var(--gold); font-weight: bold; }}
|
|
|
|
| 153 |
.type-btn {{ padding: 8px 16px; border-radius: 20px; font-size: 12px; font-weight: bold; cursor: pointer; background: #222; color: #888; border: 1px solid #444; white-space: nowrap; }}
|
| 154 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 155 |
|
| 156 |
+
/* 장소 리스트 카드 */
|
| 157 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 158 |
|
| 159 |
.place-card {{
|
|
|
|
| 184 |
.btn-ai {{ background: var(--gold); color: black; }}
|
| 185 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 186 |
|
| 187 |
+
/* 채팅 UI */
|
| 188 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 189 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 190 |
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; position: relative; }}
|
|
|
|
| 199 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
| 200 |
.chat-input {{ flex: 1; background: #222; border: 1px solid #444; color: white; padding: 14px; border-radius: 10px; outline: none; }}
|
| 201 |
|
| 202 |
+
/* 상세 리포트 UI */
|
| 203 |
#detail-page {{ background: #111; z-index: 300; transform: translateX(100%); display: flex; flex-direction: column; }}
|
| 204 |
.nav-bar {{ height: 60px; background: rgba(0,0,0,0.9); border-bottom: 1px solid #333; display: flex; align-items: center; padding: 0 20px; justify-content: space-between; }}
|
| 205 |
#mini-map {{ width: 100%; height: 35%; border-bottom: 2px solid var(--gold); }}
|
|
|
|
| 211 |
}}
|
| 212 |
.stamp-btn:hover {{ background: #ffcc00; color: #4a1c1c; border-style: solid; }}
|
| 213 |
|
| 214 |
+
/* 여권 UI */
|
| 215 |
#passport-page {{ background: #1a1a1a; z-index: 400; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 216 |
.passport-cover {{
|
| 217 |
padding: 20px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center;
|
|
|
|
| 240 |
.data-controls {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; justify-content: center; }}
|
| 241 |
.data-btn {{ background: #333; border: 1px solid #555; color: #ccc; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-size: 12px; }}
|
| 242 |
|
| 243 |
+
/* 월드맵 UI */
|
| 244 |
#world-map-page {{ background: #111; z-index: 200; transform: translateY(100%); }}
|
| 245 |
#full-map {{ width: 100%; height: 100%; }}
|
| 246 |
|
|
|
|
| 262 |
animation: bounce-float 3s ease-in-out infinite;
|
| 263 |
}}
|
| 264 |
|
| 265 |
+
/* 로딩 스피너 */
|
| 266 |
.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; }}
|
| 267 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 268 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
|
|
| 339 |
<div id="loader" class="loading-screen"><div class="loader-ring"></div><div id="loader-msg" style="color:var(--gold); font-family:monospace; margin-top:15px;"></div></div>
|
| 340 |
|
| 341 |
<script>
|
| 342 |
+
// 데이터 디코딩 유틸리티
|
| 343 |
function b64DecodeUnicode(str) {{
|
| 344 |
return decodeURIComponent(atob(str).split('').map(function(c) {{
|
| 345 |
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
| 346 |
}}).join(''));
|
| 347 |
}}
|
| 348 |
|
| 349 |
+
// 전역 변수 설정
|
| 350 |
const PLACE_DB = JSON.parse(b64DecodeUnicode("{db_base64}"));
|
| 351 |
let userLat = null, userLon = null, selectedCountry = "", selectedType = "All", currentLang = "KO", chatInitialized = false;
|
| 352 |
let miniMap = null, worldMap = null, worldMarkers = L.layerGroup();
|
| 353 |
let chatHistory = [];
|
| 354 |
let currentDetailPlace = null;
|
| 355 |
+
let currentFilteredList = []; // 리스트 인덱스 접근용
|
| 356 |
|
| 357 |
const TRANSLATIONS = {{
|
| 358 |
+
"KO": {{ "sub": "글로벌 주류 헤리티지 투어", "ai": "Korean", "mapBtn": "🗺️ 월드맵 탐험", "passBtn": "📘 내 여권", "filters": ["🌐 전체", "🏺 전통주", "🥃 위스키", "🍺 맥주", "🍷 와인", "🍹 바"], "chatPlace": "에밀리에게 말해봐, 자기야...", "send": "전송", "home": "🏠 홈", "searchPlace": "장소 검색 (예: 강남)", "emilyName": "에밀리 (Emily)", "reportHeader": "리포트", "aiBtn": "AI 리뷰", "mapLinkBtn": "지도" }},
|
| 359 |
+
"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" }},
|
| 360 |
+
"JP": {{ "sub": "世界のお酒ヘリテージツアー", "ai": "Japanese", "mapBtn": "🗺️ 世界地図探索", "passBtn": "📘 マイパスポート", "filters": ["🌐 全て", "🏺 伝統酒", "🥃 ウイスキー", "🍺 ビール", "🍷 ワイン", "🍹 バー"], "chatPlace": "エミリーに話しかけて...", "send": "送信", "home": "🏠 ホーム", "searchPlace": "場所検索 (例: 新宿)", "emilyName": "エミリー (Emily)", "reportHeader": "レポート", "aiBtn": "AI レビュー", "mapLinkBtn": "地図" }},
|
| 361 |
+
"CN": {{ "sub": "全球酒类遗产之旅", "ai": "Chinese", "mapBtn": "��️ 世界地图探索", "passBtn": "📘 我的护照", "filters": ["🌐 全部", "🏺 传统酒", "🥃 威士忌", "🍺 啤酒", "🍷 葡萄酒", "🍹 酒吧"], "chatPlace": "跟艾米丽聊天...", "send": "发送", "home": "🏠 主页", "searchPlace": "搜索地点 (例如: 江南)", "emilyName": "艾米丽 (Emily)", "reportHeader": "报告", "aiBtn": "AI 点评", "mapLinkBtn": "地图" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
}};
|
| 363 |
|
| 364 |
+
const GREETINGS = {{ "KO": "안녕, 자기? 오늘 정말 고생 많았어. 에밀리한테 뭐든 물어봐~", "EN": "Hey darling, rough day? Let Emily pour you a drink.", "JP": "あら、ハニー。今日はお疲れ様。エミリーになんでも聞いて?", "CN": "亲爱的,今天辛苦了。有什么想喝的吗?" }};
|
| 365 |
+
const LOAD_MSGS = {{ "KO": ["음~ 자기를 위한 성지가 어디 있더라?", "금발 머리 좀 정리하고 알려줄게!"], "EN": ["Searching for your perfect spot...", "Fixing my hair, one sec!"], "JP": ["集中してるわ...", "髪を整えてすぐに教えるわね"], "CN": ["正在倾听...", "正在整理金发..."] }};
|
| 366 |
const CAT_MAP = {{ "Traditional": 1, "Whiskey": 2, "Beer": 3, "Wine": 4, "Bar": 5 }};
|
| 367 |
const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
| 368 |
|
| 369 |
+
// 초기화
|
| 370 |
window.onload = function() {{
|
| 371 |
initCountryDropdown();
|
| 372 |
const keys = Object.keys(PLACE_DB).sort();
|
| 373 |
if(keys.length > 0) selectCountry(keys[0]);
|
| 374 |
+
navigator.geolocation.getCurrentPosition(p => {{ userLat = p.coords.latitude; userLon = p.coords.longitude; }}, err => console.log("GPS Not Available"));
|
|
|
|
|
|
|
|
|
|
| 375 |
}};
|
| 376 |
|
| 377 |
function initCountryDropdown() {{
|
| 378 |
const select = document.getElementById('country-select');
|
| 379 |
+
Object.keys(PLACE_DB).sort().forEach(c => {{ const opt = document.createElement('option'); opt.value = c; opt.text = c; select.appendChild(opt); }});
|
|
|
|
|
|
|
| 380 |
}}
|
| 381 |
|
| 382 |
function setLanguage(lang, el) {{
|
| 383 |
currentLang = lang;
|
| 384 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
| 385 |
el.classList.add('active');
|
|
|
|
| 386 |
const t = TRANSLATIONS[currentLang];
|
| 387 |
document.getElementById('app-subtitle').innerText = t.sub;
|
| 388 |
document.getElementById('world-map-btn').innerText = t.mapBtn;
|
|
|
|
| 393 |
document.getElementById('map-search-input').placeholder = t.searchPlace;
|
| 394 |
document.getElementById('emily-name').innerText = t.emilyName;
|
| 395 |
document.getElementById('repo-header').innerText = t.reportHeader;
|
| 396 |
+
for(let i=0; i<6; i++) {{ document.getElementById('f-btn-' + i).innerText = t.filters[i]; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
renderList();
|
| 398 |
}}
|
| 399 |
|
| 400 |
function selectCountry(c) {{ selectedCountry = c; renderList(); }}
|
| 401 |
+
function filterType(t, el) {{ selectedType = t; document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected')); el.classList.add('selected'); renderList(); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
|
| 403 |
function getMapUrl(name, country, lat, lon, address) {{
|
| 404 |
+
if (country && (country.includes("Korea") || country.includes("한국") || country === "대한민국")) {{ return "https://map.naver.com/p/search/" + encodeURIComponent(address ? address : name); }}
|
| 405 |
+
else {{ return "https://www.google.com/maps/search/" + encodeURIComponent(name) + "/@" + lat + "," + lon + ",18z"; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
}}
|
| 407 |
|
| 408 |
+
// [안전 함수 1] URL 열기 (따옴표 충돌 방지)
|
| 409 |
+
function openMapLink(url) {{ window.open(url, '_blank'); }}
|
| 410 |
+
|
| 411 |
+
// [안전 함수 2] 맵에서 상세 열기 (따옴표 충돌 방지)
|
| 412 |
+
function openDetailFromMapSafe(name, country) {{
|
| 413 |
+
closeWorldMapPage();
|
| 414 |
+
openDetail(name, country);
|
|
|
|
| 415 |
}}
|
| 416 |
|
| 417 |
function renderList() {{
|
| 418 |
+
const list = document.getElementById('place-list'); list.innerHTML = "";
|
|
|
|
| 419 |
const stamps = getStamps();
|
| 420 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
|
|
|
| 421 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 422 |
+
currentFilteredList = filtered;
|
|
|
|
| 423 |
const t = TRANSLATIONS[currentLang];
|
| 424 |
|
| 425 |
filtered.forEach((p, idx) => {{
|
| 426 |
const card = document.createElement('div');
|
| 427 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 428 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 429 |
+
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.";
|
| 430 |
|
| 431 |
+
// 텍스트 정화 (HTML 표시용)
|
| 432 |
+
const safeName = String(p.name).replace(/"/g, "").replace(/'/g, "");
|
| 433 |
+
const safeDesc = String(desc).replace(/"/g, "").replace(/'/g, "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
let catIdx = CAT_MAP[p.category] || 0;
|
| 435 |
let translatedCat = t.filters[catIdx] || p.category;
|
| 436 |
+
const addr = p.address ? p.address.replace(/'/g, "").replace(/"/g, "") : "";
|
| 437 |
+
const mapLink = getMapUrl(p.name, selectedCountry, p.lat, p.lon, addr).replace(/"/g, "");
|
| 438 |
|
| 439 |
+
// [핵심] 리스트는 Index로 접근하여 에러 원천 차단
|
| 440 |
+
card.innerHTML = "<div class='visited-badge'>VISITED 💮</div><b>" + safeName + "</b><div class='pc-cat'>" + translatedCat + "</div><div class='pc-desc'>" + safeDesc + "</div>" +
|
| 441 |
+
"<div class='card-actions'><button class='btn-action btn-ai' onclick='openDetailByIndex(" + idx + ")'>" + t.aiBtn + "</button>" +
|
| 442 |
+
"<button class='btn-action btn-map' onclick='openMapLink(\"" + mapLink + "\")'>" + t.mapLinkBtn + "</button></div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
list.appendChild(card);
|
| 444 |
}});
|
| 445 |
}}
|
| 446 |
|
| 447 |
function getStamps() {{
|
| 448 |
+
try {{ return JSON.parse(localStorage.getItem('drunk_passport') || '[]'); }}
|
| 449 |
+
catch(e) {{ localStorage.setItem('drunk_passport', '[]'); return []; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
}}
|
| 451 |
|
| 452 |
function stampCurrentPlace() {{
|
| 453 |
+
if(!currentDetailPlace) {{ alert("Error: No place selected."); return; }}
|
| 454 |
const stamps = getStamps();
|
|
|
|
| 455 |
const exists = stamps.find(s => s.name === currentDetailPlace.name && s.country === currentDetailPlace.country);
|
| 456 |
+
if(exists) {{ alert("이미 도장이 찍혀 있습니다! 💮"); return; }}
|
| 457 |
+
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 459 |
renderList();
|
| 460 |
alert("방문 인증 완료! 💮");
|
| 461 |
}}
|
| 462 |
|
| 463 |
+
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
function renderPassport() {{
|
| 465 |
+
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
|
|
|
| 466 |
const stamps = getStamps();
|
|
|
|
| 467 |
stamps.forEach(s => {{
|
| 468 |
if(!s || !s.name) return;
|
| 469 |
+
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 470 |
+
const rot = Math.floor(Math.random() * 30) - 15;
|
| 471 |
+
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>";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
grid.appendChild(el);
|
| 473 |
}});
|
| 474 |
+
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>";
|
|
|
|
|
|
|
|
|
|
| 475 |
}}
|
| 476 |
|
| 477 |
function exportData() {{
|
| 478 |
const data = localStorage.getItem('drunk_passport');
|
| 479 |
const blob = new Blob([data], {{type: 'application/json'}});
|
| 480 |
const url = URL.createObjectURL(blob);
|
| 481 |
+
const a = document.createElement('a'); a.href = url; a.download = 'drunk_passport_save.json'; a.click();
|
|
|
|
|
|
|
|
|
|
| 482 |
}}
|
| 483 |
|
| 484 |
function importData(input) {{
|
| 485 |
+
const file = input.files[0]; if(!file) return;
|
|
|
|
| 486 |
const reader = new FileReader();
|
| 487 |
reader.onload = function(e) {{
|
| 488 |
try {{
|
| 489 |
const data = JSON.parse(e.target.result);
|
| 490 |
+
if(Array.isArray(data)) {{ localStorage.setItem('drunk_passport', JSON.stringify(data)); renderPassport(); renderList(); alert("Data Loaded!"); }}
|
| 491 |
+
else {{ alert("Invalid File"); }}
|
| 492 |
+
}} catch(err) {{ alert("File Error"); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
}};
|
| 494 |
reader.readAsText(file);
|
| 495 |
}}
|
| 496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
async function callGroq(messages) {{
|
| 498 |
+
const apiKey = "{GROQ_API_KEY}"; if(!apiKey || apiKey.length < 10) return "Error: API Key Missing";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
const url = "https://api.groq.com/openai/v1/chat/completions";
|
| 500 |
+
const models = ["llama-3.3-70b-versatile", "llama-3.1-70b-versatile", "mixtral-8x7b-32768"];
|
|
|
|
| 501 |
for (const model of models) {{
|
|
|
|
| 502 |
try {{
|
| 503 |
+
const response = await fetch(url, {{ method: 'POST', headers: {{ 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + apiKey }}, body: JSON.stringify({{ model: model, messages: messages, temperature: 0.7, max_tokens: 2048 }}) }});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
if (!response.ok) throw new Error(response.statusText);
|
| 505 |
+
const data = await response.json(); return data.choices[0].message.content;
|
| 506 |
+
}} catch (error) {{ console.log(error); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
}}
|
| 508 |
+
return "Connection Failed.";
|
| 509 |
}}
|
| 510 |
|
| 511 |
+
function openChat() {{ document.getElementById('chat-page').style.transform = 'translateY(0%)'; if(!chatInitialized) {{ addChatMessage(GREETINGS[currentLang], 'bot'); chatInitialized = true; }} }}
|
| 512 |
async function askBartender() {{
|
| 513 |
+
const input = document.getElementById('chat-input'); const msg = input.value.trim(); if(!msg) return;
|
| 514 |
+
addChatMessage(msg, 'user'); input.value = ""; chatHistory.push({{ role: "user", content: msg }});
|
|
|
|
|
|
|
|
|
|
| 515 |
const loadingMsg = addChatMessage(getRandom(LOAD_MSGS[currentLang]), 'bot');
|
| 516 |
+
|
|
|
|
|
|
|
|
|
|
| 517 |
let nearbyPlaces = [];
|
| 518 |
if(userLat && userLon) {{
|
| 519 |
+
Object.keys(PLACE_DB).forEach(c => {{ PLACE_DB[c].forEach(p => {{ if(p.lat && p.lon) nearbyPlaces.push({{ ...p, country: c }}); }}); }});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
}}
|
| 521 |
+
if(nearbyPlaces.length === 0) nearbyPlaces = (PLACE_DB[selectedCountry] || []).map(p => ({{...p, country: selectedCountry}}));
|
| 522 |
+
const pool = nearbyPlaces.slice(0, 10).map(p => p.name).join(', ');
|
| 523 |
|
| 524 |
+
const res = await callGroq([...chatHistory, {{ role: "system", content: "You are Emily. Recommend from: [" + pool + "]. Language: " + TRANSLATIONS[currentLang].ai }}]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
if(loadingMsg) loadingMsg.remove();
|
| 526 |
|
| 527 |
let finalMsg = res;
|
| 528 |
const match = res.match(/\[(.*?)\]/);
|
| 529 |
if(match) {{
|
| 530 |
+
const pName = match[1]; const found = nearbyPlaces.find(p => p.name.includes(pName));
|
|
|
|
| 531 |
if(found) {{
|
| 532 |
const mapUrl = getMapUrl(pName, found.country, found.lat, found.lon, "");
|
| 533 |
+
finalMsg += "<br><a href='" + mapUrl + "' target='_blank' class='reco-btn'>📍 MAP</a>";
|
| 534 |
}}
|
| 535 |
}}
|
| 536 |
+
addChatMessage(finalMsg, 'bot', true); chatHistory.push({{ role: "assistant", content: res }});
|
|
|
|
| 537 |
}}
|
| 538 |
|
| 539 |
+
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; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
+
// [중요 수정] 월드맵 팝업 생성 로직 (따옴표 완전 제거 후 삽입)
|
| 542 |
function openWorldMapPage() {{
|
| 543 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 544 |
if(!worldMap) {{
|
| 545 |
+
worldMap = L.map('full-map').setView([20, 0], 2); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
|
|
|
| 546 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 547 |
if(p.lat && p.lon) {{
|
| 548 |
+
// 따옴표를 모두 제거하여 JS 에러 원천 차단
|
| 549 |
+
const safeName = String(p.name).replace(/['"]/g, "");
|
| 550 |
+
const safeCountry = String(c).replace(/['"]/g, "");
|
| 551 |
+
const mapUrl = getMapUrl(p.name, c, p.lat, p.lon, "").replace(/['"]/g, "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
|
| 553 |
+
// 팝업 HTML 생성 시, 안전한 문자열만 사용
|
| 554 |
const popupContent = "<div style='text-align:center'><b>" + safeName + "</b><br>" +
|
| 555 |
"<div style='display:flex; gap:5px; margin-top:5px; justify-content:center;'>" +
|
| 556 |
+
"<button onclick=\\"openDetailFromMapSafe('" + safeName + "', '" + safeCountry + "')\\" style='background:#d4af37; border:none; border-radius:4px; padding:4px 8px; font-size:11px; cursor:pointer;'>🤖 REVIEW</button>" +
|
| 557 |
+
"<button onclick=\\"openMapLink('" + mapUrl + "')\\" style='background:#333; color:white; border:1px solid #555; border-radius:4px; padding:4px 8px; font-size:11px; cursor:pointer;'>🗺️ MAP</button>" +
|
| 558 |
"</div></div>";
|
| 559 |
L.marker([p.lat, p.lon]).bindPopup(popupContent).addTo(worldMap);
|
| 560 |
}}
|
|
|
|
| 564 |
}}
|
| 565 |
|
| 566 |
async function searchLocation() {{
|
| 567 |
+
const query = document.getElementById('map-search-input').value; if(!query) return;
|
| 568 |
+
try {{ const res = await fetch('https://nominatim.openstreetmap.org/search?format=json&q=' + encodeURIComponent(query)); const data = await res.json();
|
| 569 |
+
if(data.length > 0) {{ worldMap.flyTo([data[0].lat, data[0].lon], 12); L.popup().setLatLng([data[0].lat, data[0].lon]).setContent("🔎 " + query).openOn(worldMap); }} else alert("Not Found");
|
| 570 |
+
}} catch(e) {{}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
}}
|
| 572 |
|
| 573 |
+
function flyToUserLocation() {{ if(userLat && userLon) {{ worldMap.flyTo([userLat, userLon], 13); L.marker([userLat, userLon]).addTo(worldMap).bindPopup("📍 You").openPopup(); }} else alert("GPS..."); }}
|
| 574 |
+
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
function openDetailFromMap(n, c) {{ closeWorldMapPage(); openDetail(n, c); }}
|
| 577 |
+
function openDetailByIndex(idx) {{ const p = currentFilteredList[idx]; if(p) openDetail(p.name, selectedCountry); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
async function openDetail(n, c) {{
|
| 579 |
const p = (PLACE_DB[c] || []).find(x => x.name === n); if(!p) return;
|
| 580 |
currentDetailPlace = {{ name: n, country: c }};
|
| 581 |
+
document.getElementById('detail-page').style.transform = 'translateX(0%)'; document.getElementById('repo-title').innerText = n;
|
| 582 |
+
document.getElementById('loader-msg').innerText = TRANSLATIONS[currentLang].aiBtn + "..."; document.getElementById('loader').style.display='flex';
|
| 583 |
+
if(!miniMap) {{ miniMap = L.map('mini-map'); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap); }}
|
| 584 |
+
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap).bindPopup(p.name).openPopup(); }}, 400);
|
| 585 |
+
const res = await callGroq([{{ role: "system", content: "Act as Emily. Write DETAILED report." }}, {{ role: "user", content: "Report for '" + n + "' in '" + c + "'. In " + TRANSLATIONS[currentLang].ai + "." }}]);
|
| 586 |
+
document.getElementById('loader').style.display='none'; document.getElementById('repo-content').innerHTML = res.replace(/\\n/g, '<br>').replace(/###/g, '⭐');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
}}
|
| 588 |
|
| 589 |
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 590 |
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
|
|
|
| 591 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 592 |
</script>
|
| 593 |
</body>
|