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,19 +24,17 @@ st.markdown("""
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
-
# 2. 데이터 로드 및 정제 (유니코드 보존
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
| 31 |
try:
|
| 32 |
if SHEET_URL:
|
| 33 |
response = requests.get(SHEET_URL)
|
| 34 |
-
response.encoding = 'utf-8'
|
| 35 |
response.raise_for_status()
|
| 36 |
-
|
| 37 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 38 |
|
| 39 |
-
# [수정] 따옴표와 줄바꿈만 살짝 다듬고 한글은 그대로 둡니다.
|
| 40 |
for col in df.select_dtypes(include=['object']).columns:
|
| 41 |
df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '').str.replace("'", "")
|
| 42 |
|
|
@@ -50,7 +48,6 @@ try:
|
|
| 50 |
except Exception as e:
|
| 51 |
st.error(f"데이터 로드 실패: {e}")
|
| 52 |
|
| 53 |
-
# 에밀리 이미지 처리
|
| 54 |
emily_base64 = ""
|
| 55 |
if os.path.exists('emily.jpg'):
|
| 56 |
try:
|
|
@@ -58,12 +55,11 @@ if os.path.exists('emily.jpg'):
|
|
| 58 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 59 |
except: pass
|
| 60 |
|
| 61 |
-
# [핵심] 데이터를 Base64로 인코딩하되 유니코드를 지원하는 방식으로 처리
|
| 62 |
db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 63 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 64 |
|
| 65 |
# ==========================================
|
| 66 |
-
# 3. 프론트엔드 (
|
| 67 |
# ==========================================
|
| 68 |
html_code = f"""
|
| 69 |
<!DOCTYPE html>
|
|
@@ -82,13 +78,10 @@ html_code = f"""
|
|
| 82 |
#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; }}
|
| 83 |
.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; }}
|
| 84 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
| 85 |
-
.lang-switcher {{ position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px; }}
|
| 86 |
.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; }}
|
| 87 |
.lang-btn.active {{ background: var(--gold); color: black; border-color: var(--gold); font-weight: bold; }}
|
| 88 |
.brand-title {{ font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 4px; margin-top: 10px; text-transform: uppercase; }}
|
| 89 |
-
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px; }}
|
| 90 |
.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); }}
|
| 91 |
-
.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; }}
|
| 92 |
.country-select {{ width: 85%; max-width: 400px; padding: 14px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold); color: white; font-size: 16px; border-radius: 10px; outline: none; margin-bottom: 15px; }}
|
| 93 |
.type-filter-container {{ width: 100%; padding: 10px 20px; overflow-x: auto; display: flex; gap: 8px; scrollbar-width: none; }}
|
| 94 |
.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; }}
|
|
@@ -104,7 +97,7 @@ html_code = f"""
|
|
| 104 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 105 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 106 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 107 |
-
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; }}
|
| 108 |
.msg.bot {{ align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }}
|
| 109 |
.msg.user {{ align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }}
|
| 110 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
|
@@ -120,7 +113,6 @@ html_code = f"""
|
|
| 120 |
#full-map {{ width: 100%; height: 100%; }}
|
| 121 |
.map-search-bar {{ position: absolute; top: 80px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; gap: 10px; background: rgba(0,0,0,0.85); padding: 10px 20px; border-radius: 30px; border: 1px solid var(--gold); }}
|
| 122 |
.search-input {{ background: transparent; border: none; color: white; outline: none; width: 180px; font-size: 15px; }}
|
| 123 |
-
.map-gps-btn {{ position: absolute; bottom: 30%; right: 20px; z-index: 2000; width: 60px; height: 60px; border-radius: 50%; background: #222; border: 3px solid var(--gold); color: white; font-size: 26px; cursor: pointer; display: flex; justify-content: center; align-items: center; }}
|
| 124 |
.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; }}
|
| 125 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 126 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
@@ -128,7 +120,7 @@ html_code = f"""
|
|
| 128 |
</head>
|
| 129 |
<body>
|
| 130 |
<div id="main-page" class="page">
|
| 131 |
-
<div class="lang-switcher">
|
| 132 |
<div class="lang-btn active" onclick="setLanguage('KO', this)">🇰🇷</div>
|
| 133 |
<div class="lang-btn" onclick="setLanguage('EN', this)">🇺🇸</div>
|
| 134 |
<div class="lang-btn" onclick="setLanguage('JP', this)">🇯🇵</div>
|
|
@@ -136,9 +128,9 @@ html_code = f"""
|
|
| 136 |
</div>
|
| 137 |
<div style="text-align:center; padding:10px 0;">
|
| 138 |
<div class="brand-title">DRUNKEN PLANE</div>
|
| 139 |
-
<div id="app-subtitle"
|
| 140 |
<button class="world-map-btn" onclick="openWorldMapPage()">🗺️ WORLD MAP EXPLORER</button>
|
| 141 |
-
<button class="passport-btn" onclick="openPassportPage()" style="margin: 10px auto;">📘 MY PASSPORT</button>
|
| 142 |
</div>
|
| 143 |
<center><select id="country-select" class="country-select" onchange="selectCountry(this.value)"></select></center>
|
| 144 |
<div class="type-filter-container">
|
|
@@ -156,12 +148,12 @@ html_code = f"""
|
|
| 156 |
<div id="chat-page" class="page">
|
| 157 |
<div class="nav-bar" style="background:#111; padding:15px; display:flex; align-items:center;">
|
| 158 |
<button onclick="closeChat()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button>
|
| 159 |
-
<div style="color:var(--gold); font-weight:bold; margin-left:15px;">
|
| 160 |
</div>
|
| 161 |
<div id="chat-messages"></div>
|
| 162 |
<div class="chat-input-area">
|
| 163 |
-
<input type="text" id="chat-input" class="chat-input" placeholder="
|
| 164 |
-
<button onclick="askBartender()" style="background:var(--gold); border:none; padding:10px 20px; border-radius:8px; font-weight:bold;">SEND</button>
|
| 165 |
</div>
|
| 166 |
</div>
|
| 167 |
|
|
@@ -170,7 +162,7 @@ html_code = f"""
|
|
| 170 |
<div id="mini-map"></div>
|
| 171 |
<div style="flex:1; overflow-y:auto; padding:20px;">
|
| 172 |
<div id="repo-title" style="font-size:24px; color:var(--gold); font-weight:bold;"></div>
|
| 173 |
-
<div id="repo-content" style="margin-top:15px; line-height:1.8; white-space:pre-wrap;"></div>
|
| 174 |
<button class="stamp-btn" onclick="stampCurrentPlace()">💮 Stamp This Place</button>
|
| 175 |
</div>
|
| 176 |
</div>
|
|
@@ -178,22 +170,25 @@ html_code = f"""
|
|
| 178 |
<div id="passport-page" class="page">
|
| 179 |
<div class="nav-bar" style="background:#2c0b0e; padding:15px;"><button onclick="closePassportPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button></div>
|
| 180 |
<div id="passport-grid" class="passport-grid"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
</div>
|
| 182 |
|
| 183 |
<div id="world-map-page" class="page">
|
| 184 |
<div class="nav-bar" style="background:#000; padding:15px;"><button onclick="closeWorldMapPage()" style="background:none; border:none; color:var(--gold); font-size:18px;">🏠 HOME</button></div>
|
| 185 |
<div class="map-search-bar">
|
| 186 |
-
<input type="text" id="map-search-input" class="search-input" placeholder="Search..."
|
| 187 |
-
<button onclick="searchLocation()" style="background:var(--gold); border:none; border-radius:50%; width:30px; height:30px;">🔍</button>
|
| 188 |
</div>
|
| 189 |
-
<
|
| 190 |
-
<div id="full-map"></div>
|
| 191 |
</div>
|
| 192 |
|
| 193 |
-
<div id="loader" class="loading-screen"><div class="loader-ring"></div><div id="loader-msg" style="color:var(--gold); margin-top:15px;"></div></div>
|
| 194 |
|
| 195 |
<script>
|
| 196 |
-
// [수정] 한글 깨짐을 방지하는 유니코드 안전 디코딩 함수
|
| 197 |
function decodeUnicodeBase64(s) {{
|
| 198 |
return decodeURIComponent(Array.prototype.map.call(atob(s), function(c) {{
|
| 199 |
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
@@ -203,12 +198,13 @@ html_code = f"""
|
|
| 203 |
const PLACE_DB = JSON.parse(decodeUnicodeBase64("{db_base64}"));
|
| 204 |
let userLat=null, userLon=null, selectedCountry="", selectedType="All", currentLang="KO", chatInitialized=false;
|
| 205 |
let miniMap=null, worldMap=null, currentFilteredList=[], mapCache={{}}, mapIdCounter=0;
|
|
|
|
| 206 |
|
| 207 |
const TRANSLATIONS = {{
|
| 208 |
-
"KO": {{ "ai": "Korean", "aiBtn": "AI 리뷰", "mapLinkBtn": "지도" }},
|
| 209 |
-
"EN": {{ "ai": "English", "aiBtn": "AI REVIEW", "mapLinkBtn": "MAP" }},
|
| 210 |
-
"JP": {{ "ai": "Japanese", "aiBtn": "AI レ
|
| 211 |
-
"CN": {{ "ai": "Chinese", "aiBtn": "AI 点评", "mapLinkBtn": "地图" }}
|
| 212 |
}};
|
| 213 |
|
| 214 |
window.onload = function() {{
|
|
@@ -226,7 +222,6 @@ html_code = f"""
|
|
| 226 |
el.classList.add('selected');
|
| 227 |
renderList();
|
| 228 |
}}
|
| 229 |
-
|
| 230 |
function setLanguage(lang, el) {{
|
| 231 |
currentLang = lang;
|
| 232 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
|
@@ -246,13 +241,10 @@ html_code = f"""
|
|
| 246 |
const card = document.createElement('div');
|
| 247 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 248 |
const t = TRANSLATIONS[currentLang];
|
| 249 |
-
const desc = p['desc_' + currentLang.toLowerCase()] || p.desc_en || "...";
|
| 250 |
-
|
| 251 |
card.innerHTML = `
|
| 252 |
<div class='visited-badge'>VISITED 💮</div>
|
| 253 |
<b style='font-size:18px;'>${{p.name}}</b>
|
| 254 |
-
<div style='color:var(--gold); font-size:11px;'>${{p.category}}</div>
|
| 255 |
-
<div style='font-size:13px; color:#bbb; margin-top:5px;'>${{desc}}</div>
|
| 256 |
<div class='card-actions'>
|
| 257 |
<button class='btn-action btn-ai' onclick='clickAction(${{idx}}, "ai")'>${{t.aiBtn}}</button>
|
| 258 |
<button class='btn-action btn-map' onclick='clickAction(${{idx}}, "map")'>${{t.mapLinkBtn}}</button>
|
|
@@ -262,8 +254,7 @@ html_code = f"""
|
|
| 262 |
}}
|
| 263 |
|
| 264 |
function clickAction(idx, type) {{
|
| 265 |
-
const p = currentFilteredList[idx];
|
| 266 |
-
if(!p) return;
|
| 267 |
if(type === 'ai') openDetail(p.name, selectedCountry);
|
| 268 |
else {{
|
| 269 |
const url = (selectedCountry.includes("Korea") || selectedCountry.includes("한국"))
|
|
@@ -273,29 +264,40 @@ html_code = f"""
|
|
| 273 |
}}
|
| 274 |
}}
|
| 275 |
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
if(p.lat && p.lon) {{
|
| 284 |
-
const key = mapIdCounter++;
|
| 285 |
-
mapCache[key] = {{ name: p.name, country: c }};
|
| 286 |
-
const html = `<div style='text-align:center;'><b>${{p.name}}</b><br><button onclick='clickMapDetail(${{key}})' style='background:var(--gold); border:none; margin-top:5px; padding:5px 10px; border-radius:4px; font-weight:bold; cursor:pointer;'>REVIEW</button></div>`;
|
| 287 |
-
L.marker([p.lat, p.lon]).bindPopup(html).addTo(worldMap);
|
| 288 |
-
}}
|
| 289 |
-
}}));
|
| 290 |
}}
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
}}
|
| 293 |
|
| 294 |
-
function
|
| 295 |
-
const
|
| 296 |
-
|
|
|
|
| 297 |
}}
|
| 298 |
|
|
|
|
| 299 |
async function openDetail(n, c) {{
|
| 300 |
const p = PLACE_DB[c].find(x => x.name === n); if(!p) return;
|
| 301 |
currentDetailPlace = {{ name: n, country: c }};
|
|
@@ -304,52 +306,71 @@ html_code = f"""
|
|
| 304 |
document.getElementById('loader').style.display='flex';
|
| 305 |
if(!miniMap) {{ miniMap = L.map('mini-map'); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap); }}
|
| 306 |
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
|
| 307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
document.getElementById('loader').style.display='none';
|
| 309 |
document.getElementById('repo-content').innerText = res;
|
| 310 |
}}
|
|
|
|
| 311 |
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
}}
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
}}
|
| 323 |
-
|
| 324 |
-
function openChat() {{ document.getElementById('chat-page').style.transform = 'translateY(0%)'; }}
|
| 325 |
-
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 326 |
-
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 327 |
-
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
| 328 |
-
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 329 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 330 |
|
| 331 |
function stampCurrentPlace() {{
|
| 332 |
-
|
| 333 |
-
if(stamps.find(s => s.name === currentDetailPlace.name)) return alert("Already
|
| 334 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 335 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 336 |
renderList(); alert("Stamped! 💮");
|
| 337 |
}}
|
| 338 |
-
|
|
|
|
| 339 |
function renderPassport() {{
|
| 340 |
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
| 341 |
-
|
| 342 |
-
stamps.forEach(s => {{
|
| 343 |
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 344 |
-
el.innerHTML = `<div class='stamp-mark'><div>${{s.country}}</div><div style='font-weight:bold;'>${{s.name}}</div><div
|
| 345 |
grid.appendChild(el);
|
| 346 |
}});
|
| 347 |
}}
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
const q = document.getElementById('map-search-input').value; if(!q) return;
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
if(data.length > 0) worldMap.flyTo([data[0].lat, data[0].lon], 12);
|
| 353 |
}}
|
| 354 |
function flyToUserLocation() {{ if(userLat) worldMap.flyTo([userLat, userLon], 14); }}
|
| 355 |
</script>
|
|
|
|
| 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 |
try:
|
| 32 |
if SHEET_URL:
|
| 33 |
response = requests.get(SHEET_URL)
|
| 34 |
+
response.encoding = 'utf-8'
|
| 35 |
response.raise_for_status()
|
|
|
|
| 36 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 37 |
|
|
|
|
| 38 |
for col in df.select_dtypes(include=['object']).columns:
|
| 39 |
df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '').str.replace("'", "")
|
| 40 |
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
st.error(f"데이터 로드 실패: {e}")
|
| 50 |
|
|
|
|
| 51 |
emily_base64 = ""
|
| 52 |
if os.path.exists('emily.jpg'):
|
| 53 |
try:
|
|
|
|
| 55 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 56 |
except: pass
|
| 57 |
|
|
|
|
| 58 |
db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 59 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 60 |
|
| 61 |
# ==========================================
|
| 62 |
+
# 3. 프론트엔드 (모든 기능 복구 버전)
|
| 63 |
# ==========================================
|
| 64 |
html_code = f"""
|
| 65 |
<!DOCTYPE html>
|
|
|
|
| 78 |
#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; }}
|
| 79 |
.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; }}
|
| 80 |
@keyframes bounce-float {{ 0%, 100% {{ transform: translateY(0); }} 50% {{ transform: translateY(-15px); }} }}
|
|
|
|
| 81 |
.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; }}
|
| 82 |
.lang-btn.active {{ background: var(--gold); color: black; border-color: var(--gold); font-weight: bold; }}
|
| 83 |
.brand-title {{ font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 4px; margin-top: 10px; text-transform: uppercase; }}
|
|
|
|
| 84 |
.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); }}
|
|
|
|
| 85 |
.country-select {{ width: 85%; max-width: 400px; padding: 14px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold); color: white; font-size: 16px; border-radius: 10px; outline: none; margin-bottom: 15px; }}
|
| 86 |
.type-filter-container {{ width: 100%; padding: 10px 20px; overflow-x: auto; display: flex; gap: 8px; scrollbar-width: none; }}
|
| 87 |
.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; }}
|
|
|
|
| 97 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 98 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 99 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 100 |
+
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; position: relative; }}
|
| 101 |
.msg.bot {{ align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }}
|
| 102 |
.msg.user {{ align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }}
|
| 103 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
|
|
|
| 113 |
#full-map {{ width: 100%; height: 100%; }}
|
| 114 |
.map-search-bar {{ position: absolute; top: 80px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; gap: 10px; background: rgba(0,0,0,0.85); padding: 10px 20px; border-radius: 30px; border: 1px solid var(--gold); }}
|
| 115 |
.search-input {{ background: transparent; border: none; color: white; outline: none; width: 180px; font-size: 15px; }}
|
|
|
|
| 116 |
.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; }}
|
| 117 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 118 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
|
|
| 120 |
</head>
|
| 121 |
<body>
|
| 122 |
<div id="main-page" class="page">
|
| 123 |
+
<div class="lang-switcher" style="position: absolute; top: 20px; right: 20px; z-index: 200; display: flex; gap: 8px;">
|
| 124 |
<div class="lang-btn active" onclick="setLanguage('KO', this)">🇰🇷</div>
|
| 125 |
<div class="lang-btn" onclick="setLanguage('EN', this)">🇺🇸</div>
|
| 126 |
<div class="lang-btn" onclick="setLanguage('JP', this)">🇯🇵</div>
|
|
|
|
| 128 |
</div>
|
| 129 |
<div style="text-align:center; padding:10px 0;">
|
| 130 |
<div class="brand-title">DRUNKEN PLANE</div>
|
| 131 |
+
<div id="app-subtitle" style="font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px;">GLOBAL ALCOHOL HERITAGE TOUR</div>
|
| 132 |
<button class="world-map-btn" onclick="openWorldMapPage()">🗺️ WORLD MAP EXPLORER</button>
|
| 133 |
+
<button class="passport-btn" onclick="openPassportPage()" style="margin: 10px auto; 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; display: flex; align-items: center; gap: 5px;">📘 MY PASSPORT</button>
|
| 134 |
</div>
|
| 135 |
<center><select id="country-select" class="country-select" onchange="selectCountry(this.value)"></select></center>
|
| 136 |
<div class="type-filter-container">
|
|
|
|
| 148 |
<div id="chat-page" class="page">
|
| 149 |
<div class="nav-bar" style="background:#111; padding:15px; display:flex; align-items:center;">
|
| 150 |
<button onclick="closeChat()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button>
|
| 151 |
+
<div id="emily-title-name" style="color:var(--gold); font-weight:bold; margin-left:15px;">에밀리 (Emily)</div>
|
| 152 |
</div>
|
| 153 |
<div id="chat-messages"></div>
|
| 154 |
<div class="chat-input-area">
|
| 155 |
+
<input type="text" id="chat-input" class="chat-input" placeholder="..." onkeydown="if(event.key === 'Enter') askBartender()">
|
| 156 |
+
<button onclick="askBartender()" style="background:var(--gold); border:none; padding:10px 20px; border-radius:8px; font-weight:bold; cursor:pointer;">SEND</button>
|
| 157 |
</div>
|
| 158 |
</div>
|
| 159 |
|
|
|
|
| 162 |
<div id="mini-map"></div>
|
| 163 |
<div style="flex:1; overflow-y:auto; padding:20px;">
|
| 164 |
<div id="repo-title" style="font-size:24px; color:var(--gold); font-weight:bold;"></div>
|
| 165 |
+
<div id="repo-content" style="margin-top:15px; line-height:1.8; white-space:pre-wrap; color:#ddd;"></div>
|
| 166 |
<button class="stamp-btn" onclick="stampCurrentPlace()">💮 Stamp This Place</button>
|
| 167 |
</div>
|
| 168 |
</div>
|
|
|
|
| 170 |
<div id="passport-page" class="page">
|
| 171 |
<div class="nav-bar" style="background:#2c0b0e; padding:15px;"><button onclick="closePassportPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button></div>
|
| 172 |
<div id="passport-grid" class="passport-grid"></div>
|
| 173 |
+
<div style="padding:15px; background:#111; display:flex; gap:10px; justify-content:center;">
|
| 174 |
+
<button onclick="exportData()" style="background:#333; color:white; border:none; padding:10px; border-radius:5px;">💾 Save</button>
|
| 175 |
+
<button onclick="document.getElementById('import-file').click()" style="background:#333; color:white; border:none; padding:10px; border-radius:5px;">📂 Load</button>
|
| 176 |
+
<input type="file" id="import-file" style="display:none" onchange="importData(this)">
|
| 177 |
+
</div>
|
| 178 |
</div>
|
| 179 |
|
| 180 |
<div id="world-map-page" class="page">
|
| 181 |
<div class="nav-bar" style="background:#000; padding:15px;"><button onclick="closeWorldMapPage()" style="background:none; border:none; color:var(--gold); font-size:18px;">🏠 HOME</button></div>
|
| 182 |
<div class="map-search-bar">
|
| 183 |
+
<input type="text" id="map-search-input" class="search-input" placeholder="Search Location...">
|
| 184 |
+
<button onclick="searchLocation()" style="background:var(--gold); border:none; border-radius:50%; width:30px; height:30px; cursor:pointer;">🔍</button>
|
| 185 |
</div>
|
| 186 |
+
<div id="full-map" style="flex:1;"></div>
|
|
|
|
| 187 |
</div>
|
| 188 |
|
| 189 |
+
<div id="loader" class="loading-screen"><div class="loader-ring"></div><div id="loader-msg" style="color:var(--gold); margin-top:15px;">AI 에밀리가 리포트를 작성 중입니다...</div></div>
|
| 190 |
|
| 191 |
<script>
|
|
|
|
| 192 |
function decodeUnicodeBase64(s) {{
|
| 193 |
return decodeURIComponent(Array.prototype.map.call(atob(s), function(c) {{
|
| 194 |
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
|
|
| 198 |
const PLACE_DB = JSON.parse(decodeUnicodeBase64("{db_base64}"));
|
| 199 |
let userLat=null, userLon=null, selectedCountry="", selectedType="All", currentLang="KO", chatInitialized=false;
|
| 200 |
let miniMap=null, worldMap=null, currentFilteredList=[], mapCache={{}}, mapIdCounter=0;
|
| 201 |
+
let chatHistory = [];
|
| 202 |
|
| 203 |
const TRANSLATIONS = {{
|
| 204 |
+
"KO": {{ "ai": "Korean", "aiBtn": "AI 리뷰", "mapLinkBtn": "지도", "greet": "안녕, 자기? 오늘 고생 많았어. 에밀리한테 뭐든 물어봐~", "emily": "에밀리 (Emily)" }},
|
| 205 |
+
"EN": {{ "ai": "English", "aiBtn": "AI REVIEW", "mapLinkBtn": "MAP", "greet": "Hey darling, rough day? Ask Emily anything.", "emily": "Emily" }},
|
| 206 |
+
"JP": {{ "ai": "Japanese", "aiBtn": "AI レビュー", "mapLinkBtn": "地図", "greet": "あら、ハニー。今日はお疲れ様。何でも聞いて?", "emily": "エミリー" }},
|
| 207 |
+
"CN": {{ "ai": "Chinese", "aiBtn": "AI 点评", "mapLinkBtn": "地图", "greet": "亲爱的,今天辛苦了。想聊点什么?", "emily": "艾米丽" }}
|
| 208 |
}};
|
| 209 |
|
| 210 |
window.onload = function() {{
|
|
|
|
| 222 |
el.classList.add('selected');
|
| 223 |
renderList();
|
| 224 |
}}
|
|
|
|
| 225 |
function setLanguage(lang, el) {{
|
| 226 |
currentLang = lang;
|
| 227 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
|
|
|
| 241 |
const card = document.createElement('div');
|
| 242 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 243 |
const t = TRANSLATIONS[currentLang];
|
|
|
|
|
|
|
| 244 |
card.innerHTML = `
|
| 245 |
<div class='visited-badge'>VISITED 💮</div>
|
| 246 |
<b style='font-size:18px;'>${{p.name}}</b>
|
| 247 |
+
<div style='color:var(--gold); font-size:11px; font-weight:bold;'>${{p.category.toUpperCase()}}</div>
|
|
|
|
| 248 |
<div class='card-actions'>
|
| 249 |
<button class='btn-action btn-ai' onclick='clickAction(${{idx}}, "ai")'>${{t.aiBtn}}</button>
|
| 250 |
<button class='btn-action btn-map' onclick='clickAction(${{idx}}, "map")'>${{t.mapLinkBtn}}</button>
|
|
|
|
| 254 |
}}
|
| 255 |
|
| 256 |
function clickAction(idx, type) {{
|
| 257 |
+
const p = currentFilteredList[idx]; if(!p) return;
|
|
|
|
| 258 |
if(type === 'ai') openDetail(p.name, selectedCountry);
|
| 259 |
else {{
|
| 260 |
const url = (selectedCountry.includes("Korea") || selectedCountry.includes("한국"))
|
|
|
|
| 264 |
}}
|
| 265 |
}}
|
| 266 |
|
| 267 |
+
// --- 채팅 기능 (에밀리의 영혼) ---
|
| 268 |
+
function openChat() {{
|
| 269 |
+
document.getElementById('chat-page').style.transform = 'translateY(0%)';
|
| 270 |
+
if(!chatInitialized) {{
|
| 271 |
+
addChatMessage(TRANSLATIONS[currentLang].greet, 'bot');
|
| 272 |
+
chatInitialized = true;
|
| 273 |
+
chatHistory.push({{ role: "system", content: "You are Emily, a chic and flirtatious blonde bartender. You help users find great places to drink. Be engaging and friendly. IMPORTANT: You must answer in " + TRANSLATIONS[currentLang].ai + "." }});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
}}
|
| 275 |
+
}}
|
| 276 |
+
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 277 |
+
|
| 278 |
+
async function askBartender() {{
|
| 279 |
+
const inp = document.getElementById('chat-input'); const msg = inp.value.trim(); if(!msg) return;
|
| 280 |
+
addChatMessage(msg, 'user'); inp.value = "";
|
| 281 |
+
chatHistory.push({{ role: "user", content: msg }});
|
| 282 |
+
|
| 283 |
+
// 로딩 표시용 가상 메시지
|
| 284 |
+
const loadingId = "msg-" + Date.now();
|
| 285 |
+
const box = document.getElementById('chat-messages');
|
| 286 |
+
const div = document.createElement('div'); div.className = "msg bot"; div.id = loadingId; div.innerText = "...";
|
| 287 |
+
box.appendChild(div); box.scrollTop = box.scrollHeight;
|
| 288 |
+
|
| 289 |
+
const res = await callGroq(chatHistory);
|
| 290 |
+
document.getElementById(loadingId).innerText = res;
|
| 291 |
+
chatHistory.push({{ role: "assistant", content: res }});
|
| 292 |
}}
|
| 293 |
|
| 294 |
+
function addChatMessage(t, s) {{
|
| 295 |
+
const box = document.getElementById('chat-messages');
|
| 296 |
+
const div = document.createElement('div'); div.className = "msg " + s; div.innerText = t;
|
| 297 |
+
box.appendChild(div); box.scrollTop = box.scrollHeight;
|
| 298 |
}}
|
| 299 |
|
| 300 |
+
// --- 상세 리포트 기능 ---
|
| 301 |
async function openDetail(n, c) {{
|
| 302 |
const p = PLACE_DB[c].find(x => x.name === n); if(!p) return;
|
| 303 |
currentDetailPlace = {{ name: n, country: c }};
|
|
|
|
| 306 |
document.getElementById('loader').style.display='flex';
|
| 307 |
if(!miniMap) {{ miniMap = L.map('mini-map'); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap); }}
|
| 308 |
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
|
| 309 |
+
|
| 310 |
+
const prompt = [
|
| 311 |
+
{{ role: "system", content: "Act as Emily. Write a detailed travel report for '" + n + "' in '" + c + "'. Include sections: 'Vibe & Atmosphere', 'Must Try Drinks/Food', 'Secret Tip'. Use Markdown. IMPORTANT: Write this report in " + TRANSLATIONS[currentLang].ai + " ONLY." }}
|
| 312 |
+
];
|
| 313 |
+
const res = await callGroq(prompt);
|
| 314 |
document.getElementById('loader').style.display='none';
|
| 315 |
document.getElementById('repo-content').innerText = res;
|
| 316 |
}}
|
| 317 |
+
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 318 |
|
| 319 |
+
// --- 월드맵 및 여권 기능 ---
|
| 320 |
+
function openWorldMapPage() {{
|
| 321 |
+
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 322 |
+
if(!worldMap) {{
|
| 323 |
+
worldMap = L.map('full-map').setView([20, 0], 2);
|
| 324 |
+
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 325 |
+
mapCache = {{}}; mapIdCounter = 0;
|
| 326 |
+
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 327 |
+
if(p.lat && p.lon) {{
|
| 328 |
+
const key = mapIdCounter++;
|
| 329 |
+
mapCache[key] = {{ name: p.name, country: c }};
|
| 330 |
+
const html = `<div style='text-align:center;'><b>${{p.name}}</b><br><button onclick='clickMapDetail(${{key}})' style='background:var(--gold); border:none; margin-top:5px; padding:5px 10px; border-radius:4px; font-weight:bold; cursor:pointer;'>REVIEW</button></div>`;
|
| 331 |
+
L.marker([p.lat, p.lon]).bindPopup(html).addTo(worldMap);
|
| 332 |
+
}}
|
| 333 |
+
}}));
|
| 334 |
+
}}
|
| 335 |
+
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 336 |
}}
|
| 337 |
+
function clickMapDetail(key) {{ const d = mapCache[key]; if(d) {{ closeWorldMapPage(); openDetail(d.name, d.country); }} }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 339 |
|
| 340 |
function stampCurrentPlace() {{
|
| 341 |
+
let stamps = JSON.parse(localStorage.getItem('drunk_passport') || '[]');
|
| 342 |
+
if(stamps.find(s => s.name === currentDetailPlace.name)) return alert("Already Stamped!");
|
| 343 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 344 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 345 |
renderList(); alert("Stamped! 💮");
|
| 346 |
}}
|
| 347 |
+
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
| 348 |
+
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 349 |
function renderPassport() {{
|
| 350 |
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
| 351 |
+
JSON.parse(localStorage.getItem('drunk_passport') || '[]').forEach(s => {{
|
|
|
|
| 352 |
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 353 |
+
el.innerHTML = `<div class='stamp-mark'><div>${{s.country}}</div><div style='font-weight:bold;'>${{s.name}}</div><div>${{s.date}}</div></div>`;
|
| 354 |
grid.appendChild(el);
|
| 355 |
}});
|
| 356 |
}}
|
| 357 |
+
function exportData() {{ const blob = new Blob([localStorage.getItem('drunk_passport')], {{type:'application/json'}}); const a=document.createElement('a'); a.href=URL.createObjectURL(blob); a.download='passport.json'; a.click(); }}
|
| 358 |
+
function importData(input) {{ const r = new FileReader(); r.onload = e => {{ localStorage.setItem('drunk_passport', e.target.result); renderList(); alert("Loaded!"); }}; r.readAsText(input.files[0]); }}
|
| 359 |
+
|
| 360 |
+
async function callGroq(msgs) {{
|
| 361 |
+
try {{
|
| 362 |
+
const r = await fetch("https://api.groq.com/openai/v1/chat/completions", {{
|
| 363 |
+
method: "POST",
|
| 364 |
+
headers: {{ "Content-Type": "application/json", "Authorization": "Bearer {GROQ_API_KEY}" }},
|
| 365 |
+
body: JSON.stringify({{ model: "llama-3.3-70b-versatile", messages: msgs }})
|
| 366 |
+
}});
|
| 367 |
+
const d = await r.json(); return d.choices[0].message.content;
|
| 368 |
+
}} catch(e) {{ return "Connection Error... 😢"; }}
|
| 369 |
+
}}
|
| 370 |
+
function searchLocation() {{
|
| 371 |
const q = document.getElementById('map-search-input').value; if(!q) return;
|
| 372 |
+
fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${{encodeURIComponent(q)}}`)
|
| 373 |
+
.then(r => r.json()).then(d => {{ if(d.length > 0) worldMap.flyTo([d[0].lat, d[0].lon], 12); }});
|
|
|
|
| 374 |
}}
|
| 375 |
function flyToUserLocation() {{ if(userLat) worldMap.flyTo([userLat, userLon], 14); }}
|
| 376 |
</script>
|