Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,13 +24,10 @@ 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)
|
|
@@ -41,9 +38,9 @@ try:
|
|
| 41 |
except:
|
| 42 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 43 |
|
| 44 |
-
# [ํต์ฌ] ์
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
df.columns = df.columns.str.strip()
|
| 49 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
|
@@ -51,10 +48,9 @@ try:
|
|
| 51 |
|
| 52 |
if 'Country' in df.columns:
|
| 53 |
for country, group in df.groupby('Country'):
|
| 54 |
-
|
| 55 |
-
PLACE_DB[country] = cleaned_group
|
| 56 |
else:
|
| 57 |
-
st.error("๐จ CSV
|
| 58 |
else:
|
| 59 |
if os.path.exists('places.json'):
|
| 60 |
with open('places.json', 'r', encoding='utf-8-sig') as f:
|
|
@@ -74,11 +70,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>
|
|
@@ -87,11 +84,9 @@ html_code = f"""
|
|
| 87 |
<meta charset="utf-8">
|
| 88 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
| 89 |
<title>Drunken Plane</title>
|
| 90 |
-
|
| 91 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
| 92 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 93 |
<link href="https://fonts.googleapis.com/css2?family=Special+Elite&display=swap" rel="stylesheet">
|
| 94 |
-
|
| 95 |
<style>
|
| 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; }}
|
|
@@ -159,13 +154,12 @@ html_code = f"""
|
|
| 159 |
</style>
|
| 160 |
</head>
|
| 161 |
<body>
|
| 162 |
-
|
| 163 |
<div id="main-page" class="page">
|
| 164 |
<div class="lang-switcher">
|
| 165 |
-
<div class="lang-btn active" onclick="setLanguage('KO', this)">๐ฐ๐ท</div>
|
| 166 |
-
<div class="lang-btn" onclick="setLanguage('EN', this)">๐บ๐ธ</div>
|
| 167 |
-
<div class="lang-btn" onclick="setLanguage('JP', this)">๐ฏ๐ต</div>
|
| 168 |
-
<div class="lang-btn" onclick="setLanguage('CN', this)">๐จ๐ณ</div>
|
| 169 |
</div>
|
| 170 |
<div style="text-align:center; padding:10px 0;">
|
| 171 |
<div class="brand-title">DRUNKEN PLANE</div>
|
|
@@ -189,7 +183,7 @@ html_code = f"""
|
|
| 189 |
<div id="chat-page" class="page">
|
| 190 |
<div class="nav-bar"><button onclick="closeChat()" style="background:none; border:none; color:var(--gold); font-size:24px;">โ</button><div id="emily-name" style="color:var(--gold); font-weight:bold;">์๋ฐ๋ฆฌ (Emily)</div><div></div></div>
|
| 191 |
<div id="chat-messages"></div>
|
| 192 |
-
<div class="chat-input-area"><input type="text" id="chat-input" class="chat-input" placeholder="
|
| 193 |
</div>
|
| 194 |
|
| 195 |
<div id="detail-page" class="page">
|
|
@@ -203,73 +197,46 @@ html_code = f"""
|
|
| 203 |
</div>
|
| 204 |
|
| 205 |
<div id="passport-page" class="page">
|
| 206 |
-
<div class="passport-cover">
|
| 207 |
-
<button onclick="closePassportPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">โ</button>
|
| 208 |
-
<div style="color:var(--gold); font-weight:bold; font-size: 18px;">DRUNKARD'S PASSPORT</div>
|
| 209 |
-
<div></div>
|
| 210 |
-
</div>
|
| 211 |
<div id="passport-grid" class="passport-grid"></div>
|
| 212 |
-
<div class="data-controls">
|
| 213 |
-
<button class="data-btn" onclick="exportData()">๐พ Save Game</button>
|
| 214 |
-
<button class="data-btn" onclick="document.getElementById('import-file').click()">๐ Load Game</button>
|
| 215 |
-
<input type="file" id="import-file" style="display:none" onchange="importData(this)">
|
| 216 |
-
</div>
|
| 217 |
</div>
|
| 218 |
|
| 219 |
-
<div id="world-map-page" class="page">
|
| 220 |
-
<div class="nav-bar"><button id="nav-home-btn" onclick="closeWorldMapPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">๐ HOME</button></div>
|
| 221 |
-
<div class="map-search-bar">
|
| 222 |
-
<input type="text" id="map-search-input" class="search-input" placeholder="Search (e.g. Gangnam)" onkeydown="if(event.key === 'Enter') searchLocation()">
|
| 223 |
-
<button class="search-btn" onclick="searchLocation()">๐</button>
|
| 224 |
-
</div>
|
| 225 |
-
<button class="map-gps-btn" onclick="flyToUserLocation()">๐ฏ</button>
|
| 226 |
-
<div id="full-map"></div>
|
| 227 |
-
</div>
|
| 228 |
-
|
| 229 |
<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>
|
| 230 |
|
| 231 |
<script>
|
|
|
|
| 232 |
function b64DecodeUnicode(str) {{
|
| 233 |
-
|
| 234 |
-
return
|
| 235 |
-
|
|
|
|
|
|
|
| 236 |
}}
|
| 237 |
|
|
|
|
| 238 |
const PLACE_DB = JSON.parse(b64DecodeUnicode("{db_base64}"));
|
| 239 |
let userLat = null, userLon = null, selectedCountry = "", selectedType = "All", currentLang = "KO", chatInitialized = false;
|
| 240 |
-
let miniMap = null, worldMap = null,
|
| 241 |
-
let
|
| 242 |
-
let
|
| 243 |
-
let currentFilteredList = [];
|
| 244 |
-
|
| 245 |
-
// [ํต์ฌ ๋ณ๊ฒฝ: ์ง๋ ๋ฐ์ดํฐ ์ ์ฅ์ (Key๋ฅผ ์ซ์๋ก ๊ด๋ฆฌ)]
|
| 246 |
-
let MAP_CACHE = {{}};
|
| 247 |
-
let mapKeyCounter = 0; // ์ ๋ํฌํ ์ซ์ ID ์์ฑ์ฉ
|
| 248 |
|
| 249 |
const TRANSLATIONS = {{
|
| 250 |
-
"KO": {{ "sub": "๊ธ๋ก๋ฒ ์ฃผ๋ฅ ํค๋ฆฌํฐ์ง ํฌ์ด", "ai": "Korean", "mapBtn": "๐บ๏ธ ์๋๋งต ํํ", "passBtn": "๐ ๋ด ์ฌ๊ถ", "filters": ["๐ ์ ์ฒด", "๐บ ์ ํต์ฃผ", "๐ฅ ์์คํค", "๐บ ๋งฅ์ฃผ", "๐ท ์์ธ", "๐น ๋ฐ"], "chatPlace": "์๋ฐ๋ฆฌ์๊ฒ ๋งํด๋ด
|
| 251 |
-
"EN": {{ "sub": "GLOBAL ALCOHOL HERITAGE TOUR", "ai": "English", "mapBtn": "๐บ๏ธ
|
| 252 |
-
"JP": {{ "sub": "ไธ็ใฎใ้
ใใชใใผใธใใขใผ", "ai": "Japanese", "mapBtn": "๐บ๏ธ
|
| 253 |
-
"CN": {{ "sub": "ๅ
จ็้
็ฑป้ไบงไนๆ
", "ai": "Chinese", "mapBtn": "๐บ๏ธ
|
| 254 |
}};
|
| 255 |
|
| 256 |
-
const GREETINGS = {{ "KO": "์๋
, ์๊ธฐ? ์ค๋ ์ ๋ง ๊ณ ์ ๋ง์์ด. ์๋ฐ๋ฆฌํํ
๋ญ๋ ๋ฌผ์ด๋ด~", "EN": "Hey darling, rough day? Let Emily pour you a drink.", "JP": "ใใใใใใผใไปๆฅใฏใ็ฒใๆงใใจใใชใผใซใชใใงใ่ใใฆ๏ผ", "CN": "ไบฒ็ฑ็๏ผไปๅคฉ่พ่ฆไบใๆไปไนๆณๅ็ๅ๏ผ" }};
|
| 257 |
-
const LOAD_MSGS = {{ "KO": ["์~ ์๊ธฐ๋ฅผ ์ํ ์ฑ์ง๊ฐ ์ด๋ ์๋๋ผ?", "๊ธ๋ฐ ๋จธ๋ฆฌ ์ข ์ ๋ฆฌํ๊ณ ์๋ ค์ค๊ฒ!"], "EN": ["Searching for your perfect spot...", "Fixing my hair, one sec!"], "JP": ["้ไธญใใฆใใ...", "้ซชใๆดใใฆใใใซๆใใใใญ"], "CN": ["ๆญฃๅจๅพๅฌ...", "ๆญฃๅจๆด็้ๅ..."] }};
|
| 258 |
-
const CAT_MAP = {{ "Traditional": 1, "Whiskey": 2, "Beer": 3, "Wine": 4, "Bar": 5 }};
|
| 259 |
-
const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
| 260 |
-
|
| 261 |
window.onload = function() {{
|
| 262 |
-
initCountryDropdown();
|
| 263 |
const keys = Object.keys(PLACE_DB).sort();
|
|
|
|
|
|
|
| 264 |
if(keys.length > 0) selectCountry(keys[0]);
|
| 265 |
-
navigator.geolocation.getCurrentPosition(p => {{ userLat = p.coords.latitude; userLon = p.coords.longitude; }},
|
| 266 |
}};
|
| 267 |
|
| 268 |
-
function initCountryDropdown() {{
|
| 269 |
-
const select = document.getElementById('country-select');
|
| 270 |
-
Object.keys(PLACE_DB).sort().forEach(c => {{ const opt = document.createElement('option'); opt.value = c; opt.text = c; select.appendChild(opt); }});
|
| 271 |
-
}}
|
| 272 |
-
|
| 273 |
function setLanguage(lang, el) {{
|
| 274 |
currentLang = lang;
|
| 275 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
|
@@ -291,202 +258,155 @@ html_code = f"""
|
|
| 291 |
function selectCountry(c) {{ selectedCountry = c; renderList(); }}
|
| 292 |
function filterType(t, el) {{ selectedType = t; document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected')); el.classList.add('selected'); renderList(); }}
|
| 293 |
|
| 294 |
-
|
| 295 |
-
if (country && (country.includes("Korea") || country.includes("ํ๊ตญ") || country === "๋ํ๋ฏผ๊ตญ")) {{ return "https://map.naver.com/p/search/" + encodeURIComponent(address ? address : name); }}
|
| 296 |
-
else {{ return "https://www.google.com/maps/search/" + encodeURIComponent(name) + "/@" + lat + "," + lon + ",18z"; }}
|
| 297 |
-
}}
|
| 298 |
-
|
| 299 |
-
function openMapLink(url) {{ window.open(url, '_blank'); }}
|
| 300 |
-
|
| 301 |
function renderList() {{
|
| 302 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 303 |
const stamps = getStamps();
|
| 304 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
| 305 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 306 |
-
currentFilteredList = filtered;
|
| 307 |
const t = TRANSLATIONS[currentLang];
|
| 308 |
|
| 309 |
filtered.forEach((p, idx) => {{
|
| 310 |
const card = document.createElement('div');
|
| 311 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 312 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 313 |
-
let desc = (currentLang === 'KO' ? p.desc_ko : (currentLang === 'EN' ? p.desc_en : (currentLang === 'JP' ? p.desc_jp : p.desc_cn))) || p.desc_en || "
|
| 314 |
|
| 315 |
-
//
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
card.innerHTML = "<div class='visited-badge'>VISITED ๐ฎ</div><b>" + safeName + "</b><div class='pc-cat'>" + translatedCat + "</div><div class='pc-desc'>" + safeDesc + "</div>" +
|
| 325 |
-
"<div class='card-actions'><button class='btn-action btn-ai' onclick='openDetailByIndex(" + idx + ")'>" + t.aiBtn + "</button>" +
|
| 326 |
-
"<button class='btn-action btn-map' onclick='openMapLink(\"" + safeMapLink + "\")'>" + t.mapLinkBtn + "</button></div>";
|
| 327 |
list.appendChild(card);
|
| 328 |
}});
|
| 329 |
}}
|
| 330 |
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
}}
|
| 335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
function stampCurrentPlace() {{
|
| 337 |
-
if(!currentDetailPlace)
|
| 338 |
const stamps = getStamps();
|
| 339 |
-
|
| 340 |
-
if(exists) {{ alert("Already Stamped! ๐ฎ"); return; }}
|
| 341 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 342 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 343 |
-
renderList();
|
| 344 |
-
alert("Stamped! ๐ฎ");
|
| 345 |
}}
|
| 346 |
|
| 347 |
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
| 348 |
function renderPassport() {{
|
| 349 |
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
if(!s || !s.name) return;
|
| 353 |
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
| 356 |
grid.appendChild(el);
|
| 357 |
}});
|
| 358 |
-
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>";
|
| 359 |
-
}}
|
| 360 |
-
|
| 361 |
-
function exportData() {{
|
| 362 |
-
const data = localStorage.getItem('drunk_passport');
|
| 363 |
-
const blob = new Blob([data], {{type: 'application/json'}});
|
| 364 |
-
const url = URL.createObjectURL(blob);
|
| 365 |
-
const a = document.createElement('a'); a.href = url; a.download = 'drunk_passport_save.json'; a.click();
|
| 366 |
-
}}
|
| 367 |
-
|
| 368 |
-
function importData(input) {{
|
| 369 |
-
const file = input.files[0]; if(!file) return;
|
| 370 |
-
const reader = new FileReader();
|
| 371 |
-
reader.onload = function(e) {{
|
| 372 |
-
try {{
|
| 373 |
-
const data = JSON.parse(e.target.result);
|
| 374 |
-
if(Array.isArray(data)) {{ localStorage.setItem('drunk_passport', JSON.stringify(data)); renderPassport(); renderList(); alert("Data Loaded!"); }}
|
| 375 |
-
else {{ alert("Invalid File"); }}
|
| 376 |
-
}} catch(err) {{ alert("File Error"); }}
|
| 377 |
-
}};
|
| 378 |
-
reader.readAsText(file);
|
| 379 |
-
}}
|
| 380 |
-
|
| 381 |
-
async function callGroq(messages) {{
|
| 382 |
-
const apiKey = "{GROQ_API_KEY}"; if(!apiKey || apiKey.length < 10) return "Error: API Key Missing";
|
| 383 |
-
const url = "https://api.groq.com/openai/v1/chat/completions";
|
| 384 |
-
const models = ["llama-3.3-70b-versatile", "llama-3.1-70b-versatile", "mixtral-8x7b-32768"];
|
| 385 |
-
for (const model of models) {{
|
| 386 |
-
try {{
|
| 387 |
-
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 }}) }});
|
| 388 |
-
if (!response.ok) throw new Error(response.statusText);
|
| 389 |
-
const data = await response.json(); return data.choices[0].message.content;
|
| 390 |
-
}} catch (error) {{ console.log(error); }}
|
| 391 |
-
}}
|
| 392 |
-
return "Connection Failed.";
|
| 393 |
}}
|
| 394 |
|
| 395 |
-
function
|
| 396 |
-
|
| 397 |
-
const input = document.getElementById('chat-input'); const msg = input.value.trim(); if(!msg) return;
|
| 398 |
-
addChatMessage(msg, 'user'); input.value = ""; chatHistory.push({{ role: "user", content: msg }});
|
| 399 |
-
const loadingMsg = addChatMessage(getRandom(LOAD_MSGS[currentLang]), 'bot');
|
| 400 |
-
|
| 401 |
-
let nearbyPlaces = [];
|
| 402 |
-
if(userLat && userLon) {{ Object.keys(PLACE_DB).forEach(c => {{ PLACE_DB[c].forEach(p => {{ if(p.lat && p.lon) nearbyPlaces.push({{ ...p, country: c }}); }}); }}); }}
|
| 403 |
-
if(nearbyPlaces.length === 0) nearbyPlaces = (PLACE_DB[selectedCountry] || []).map(p => ({{...p, country: selectedCountry}}));
|
| 404 |
-
const pool = nearbyPlaces.slice(0, 10).map(p => p.name).join(', ');
|
| 405 |
-
|
| 406 |
-
const res = await callGroq([...chatHistory, {{ role: "system", content: "You are Emily. Recommend from: [" + pool + "]. Lang: " + TRANSLATIONS[currentLang].ai }}]);
|
| 407 |
-
if(loadingMsg) loadingMsg.remove();
|
| 408 |
-
|
| 409 |
-
let finalMsg = res;
|
| 410 |
-
const match = res.match(/\[(.*?)\]/);
|
| 411 |
-
if(match) {{
|
| 412 |
-
const pName = match[1]; const found = nearbyPlaces.find(p => p.name.includes(pName));
|
| 413 |
-
if(found) {{
|
| 414 |
-
const mapUrl = getMapUrl(pName, found.country, found.lat, found.lon, "");
|
| 415 |
-
finalMsg += "<br><a href='" + mapUrl + "' target='_blank' class='reco-btn'>๐ MAP</a>";
|
| 416 |
-
}}
|
| 417 |
-
}}
|
| 418 |
-
addChatMessage(finalMsg, 'bot', true); chatHistory.push({{ role: "assistant", content: res }});
|
| 419 |
-
}}
|
| 420 |
|
| 421 |
-
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; }}
|
| 422 |
-
|
| 423 |
-
// [ํต์ฌ ๋ณ๊ฒฝ 4] ์๋๋งต ํ์
- ์ซ์ ID ์ฌ์ฉ (๋ฐ์ดํ ์ง์ฅ ํ์ถ)
|
| 424 |
function openWorldMapPage() {{
|
| 425 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 426 |
if(!worldMap) {{
|
| 427 |
-
worldMap = L.map('full-map').setView([20, 0], 2);
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 432 |
if(p.lat && p.lon) {{
|
| 433 |
-
|
| 434 |
-
const
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
|
| 439 |
-
//
|
| 440 |
-
const
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
L.marker([p.lat, p.lon]).bindPopup(
|
| 446 |
}}
|
| 447 |
}}));
|
| 448 |
}}
|
| 449 |
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 450 |
}}
|
| 451 |
-
|
| 452 |
-
// ๋งต ํด๋ฆญ ํธ๋ค๋ฌ (์ซ์๋ก ๋ฐ์ดํฐ ์ฐพ๊ธฐ)
|
| 453 |
-
function clickMapDetail(id) {{
|
| 454 |
-
const data = MAP_CACHE[id];
|
| 455 |
-
if(data) {{ closeWorldMapPage(); openDetail(data.name, data.country); }}
|
| 456 |
-
}}
|
| 457 |
-
|
| 458 |
-
function clickMapLink(id) {{
|
| 459 |
-
const data = MAP_CACHE[id];
|
| 460 |
-
if(data) window.open(data.url, '_blank');
|
| 461 |
-
}}
|
| 462 |
|
| 463 |
-
async function
|
| 464 |
-
const
|
| 465 |
-
try {{
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}}
|
| 469 |
|
| 470 |
-
function
|
| 471 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
|
| 473 |
-
function
|
| 474 |
-
function
|
| 475 |
async function openDetail(n, c) {{
|
| 476 |
-
const p =
|
| 477 |
currentDetailPlace = {{ name: n, country: c }};
|
| 478 |
-
document.getElementById('detail-page').style.transform = 'translateX(0%)';
|
| 479 |
-
document.getElementById('
|
|
|
|
| 480 |
if(!miniMap) {{ miniMap = L.map('mini-map'); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap); }}
|
| 481 |
-
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap)
|
| 482 |
-
const res = await callGroq([{{ role: "system", content: "
|
| 483 |
-
document.getElementById('loader').style.display='none';
|
|
|
|
| 484 |
}}
|
| 485 |
|
| 486 |
-
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 487 |
-
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 488 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 489 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
</script>
|
| 491 |
</body>
|
| 492 |
</html>
|
|
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
+
# 2. ๋ฐ์ดํฐ ๋ก๋ ๋ฐ "๊ฐ๋ ฅํ" ์ ์ (Anti-SyntaxError)
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
try:
|
| 32 |
if SHEET_URL:
|
| 33 |
response = requests.get(SHEET_URL)
|
|
|
|
| 38 |
except:
|
| 39 |
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 40 |
|
| 41 |
+
# [ํต์ฌ ์์ ] ๋ชจ๋ ๋ฌธ์์ด ์ปฌ๋ผ์์ JS ์๋ฌ๋ฅผ ์ ๋ฐํ๋ ๋ฌธ์๋ค(์ํฐ, ํญ, ๋ฐ์ดํ) ์ ๊ฑฐ
|
| 42 |
+
for col in df.select_dtypes(include=['object']).columns:
|
| 43 |
+
df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '').str.replace("'", "")
|
| 44 |
|
| 45 |
df.columns = df.columns.str.strip()
|
| 46 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
|
|
|
| 48 |
|
| 49 |
if 'Country' in df.columns:
|
| 50 |
for country, group in df.groupby('Country'):
|
| 51 |
+
PLACE_DB[country] = group.fillna("").to_dict(orient='records')
|
|
|
|
| 52 |
else:
|
| 53 |
+
st.error("๐จ CSV์ 'Country' ์ปฌ๋ผ์ด ์์ต๋๋ค.")
|
| 54 |
else:
|
| 55 |
if os.path.exists('places.json'):
|
| 56 |
with open('places.json', 'r', encoding='utf-8-sig') as f:
|
|
|
|
| 70 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 71 |
except: pass
|
| 72 |
|
| 73 |
+
# Base64๋ก ์ธ์ฝ๋ฉํ์ฌ JS ์ ๋ฌ (๋ฐ์ดํ ์ถฉ๋ ์์ฒ ๋ฐฉ์ง)
|
| 74 |
db_json_raw = json.dumps(PLACE_DB, ensure_ascii=False)
|
| 75 |
db_base64 = base64.b64encode(db_json_raw.encode('utf-8')).decode('utf-8')
|
| 76 |
|
| 77 |
# ==========================================
|
| 78 |
+
# 4. ํ๋ก ํธ์๋ (HTML/JS/CSS) - 100% ๊ฒ์ฆ ๋ฒ์
|
| 79 |
# ==========================================
|
| 80 |
html_code = f"""
|
| 81 |
<!DOCTYPE html>
|
|
|
|
| 84 |
<meta charset="utf-8">
|
| 85 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
| 86 |
<title>Drunken Plane</title>
|
|
|
|
| 87 |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
| 88 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 89 |
<link href="https://fonts.googleapis.com/css2?family=Special+Elite&display=swap" rel="stylesheet">
|
|
|
|
| 90 |
<style>
|
| 91 |
:root {{ --gold: #d4af37; --dark: #0a0a0a; --text: #e0e0e0; }}
|
| 92 |
body {{ margin: 0; padding: 0; background: var(--dark); color: var(--text); font-family: 'Segoe UI', sans-serif; overflow: hidden; }}
|
|
|
|
| 154 |
</style>
|
| 155 |
</head>
|
| 156 |
<body>
|
|
|
|
| 157 |
<div id="main-page" class="page">
|
| 158 |
<div class="lang-switcher">
|
| 159 |
+
<div class="lang-btn active" id="l-KO" onclick="setLanguage('KO', this)">๐ฐ๐ท</div>
|
| 160 |
+
<div class="lang-btn" id="l-EN" onclick="setLanguage('EN', this)">๐บ๐ธ</div>
|
| 161 |
+
<div class="lang-btn" id="l-JP" onclick="setLanguage('JP', this)">๐ฏ๐ต</div>
|
| 162 |
+
<div class="lang-btn" id="l-CN" onclick="setLanguage('CN', this)">๐จ๐ณ</div>
|
| 163 |
</div>
|
| 164 |
<div style="text-align:center; padding:10px 0;">
|
| 165 |
<div class="brand-title">DRUNKEN PLANE</div>
|
|
|
|
| 183 |
<div id="chat-page" class="page">
|
| 184 |
<div class="nav-bar"><button onclick="closeChat()" style="background:none; border:none; color:var(--gold); font-size:24px;">โ</button><div id="emily-name" style="color:var(--gold); font-weight:bold;">์๋ฐ๋ฆฌ (Emily)</div><div></div></div>
|
| 185 |
<div id="chat-messages"></div>
|
| 186 |
+
<div class="chat-input-area"><input type="text" id="chat-input" class="chat-input" placeholder="..." onkeydown="if(event.key === 'Enter') askBartender()"><button id="chat-send-btn" onclick="askBartender()" style="background:var(--gold); border:none; padding:10px 20px; border-radius:8px; font-weight:bold;">SEND</button></div>
|
| 187 |
</div>
|
| 188 |
|
| 189 |
<div id="detail-page" class="page">
|
|
|
|
| 197 |
</div>
|
| 198 |
|
| 199 |
<div id="passport-page" class="page">
|
| 200 |
+
<div class="passport-cover"><button onclick="closePassportPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">โ</button><div style="color:var(--gold); font-weight:bold; font-size: 18px;">DRUNKARD'S PASSPORT</div><div></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
<div id="passport-grid" class="passport-grid"></div>
|
| 202 |
+
<div class="data-controls"><button class="data-btn" onclick="exportData()">๐พ Save Game</button><button class="data-btn" onclick="document.getElementById('import-file').click()">๐ Load Game</button><input type="file" id="import-file" style="display:none" onchange="importData(this)"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
</div>
|
| 204 |
|
| 205 |
+
<div id="world-map-page" class="page"><div class="nav-bar"><button id="nav-home-btn" onclick="closeWorldMapPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">๐ HOME</button></div><div class="map-search-bar"><input type="text" id="map-search-input" class="search-input" placeholder="..." onkeydown="if(event.key === 'Enter') searchLocation()"><button class="search-btn" onclick="searchLocation()">๐</button></div><button class="map-gps-btn" onclick="flyToUserLocation()">๐ฏ</button><div id="full-map"></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
<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>
|
| 207 |
|
| 208 |
<script>
|
| 209 |
+
// ์์ ํ ๋ฐ์ดํฐ ๋์ฝ๋ฉ
|
| 210 |
function b64DecodeUnicode(str) {{
|
| 211 |
+
try {{
|
| 212 |
+
return decodeURIComponent(atob(str).split('').map(function(c) {{
|
| 213 |
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
| 214 |
+
}}).join(''));
|
| 215 |
+
}} catch(e) {{ return "{{}}"; }}
|
| 216 |
}}
|
| 217 |
|
| 218 |
+
// ์ ์ญ ๋ฐ์ดํฐ (์ด์ ์ญํ ์ ํ๋ ์ซ์ ID ํ์ฉ)
|
| 219 |
const PLACE_DB = JSON.parse(b64DecodeUnicode("{db_base64}"));
|
| 220 |
let userLat = null, userLon = null, selectedCountry = "", selectedType = "All", currentLang = "KO", chatInitialized = false;
|
| 221 |
+
let miniMap = null, worldMap = null, currentFilteredList = [];
|
| 222 |
+
let MAP_CACHE = {{}}; // ์ง๋์์ ํด๋ฆญ ์ ๋ฐ์ดํฐ ์กฐํ๋ฅผ ์ํ ์บ์
|
| 223 |
+
let mapIdCounter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
const TRANSLATIONS = {{
|
| 226 |
+
"KO": {{ "sub": "๊ธ๋ก๋ฒ ์ฃผ๋ฅ ํค๋ฆฌํฐ์ง ํฌ์ด", "ai": "Korean", "mapBtn": "๐บ๏ธ ์๋๋งต ํํ", "passBtn": "๐ ๋ด ์ฌ๊ถ", "filters": ["๐ ์ ์ฒด", "๐บ ์ ํต์ฃผ", "๐ฅ ์์คํค", "๐บ ๋งฅ์ฃผ", "๐ท ์์ธ", "๐น ๋ฐ"], "chatPlace": "์๋ฐ๋ฆฌ์๊ฒ ๋งํด๋ด...", "send": "์ ์ก", "home": "๐ ํ", "searchPlace": "์ฅ์ ๊ฒ์", "emilyName": "์๋ฐ๋ฆฌ", "reportHeader": "๋ฆฌํฌํธ", "aiBtn": "AI ๋ฆฌ๋ทฐ", "mapLinkBtn": "์ง๋" }},
|
| 227 |
+
"EN": {{ "sub": "GLOBAL ALCOHOL HERITAGE TOUR", "ai": "English", "mapBtn": "๐บ๏ธ EXPLORER", "passBtn": "๐ PASSPORT", "filters": ["๐ All", "๐บ Trad.", "๐ฅ Whiskey", "๐บ Beer", "๐ท Wine", "๐น Bar"], "chatPlace": "Talk to Emily...", "send": "SEND", "home": "๐ HOME", "searchPlace": "Search", "emilyName": "Emily", "reportHeader": "REPORT", "aiBtn": "AI REVIEW", "mapLinkBtn": "MAP" }},
|
| 228 |
+
"JP": {{ "sub": "ไธ็ใฎใ้
ใใชใใผใธใใขใผ", "ai": "Japanese", "mapBtn": "๐บ๏ธ ๅฐๅณๆข็ดข", "passBtn": "๐ ใ์คํฌํธ", "filters": ["๐ ๅ
จใฆ", "๐บ ไผ็ตฑ้
", "๐ฅ ใฆใคในใญใผ", "๐บ ใใผใซ", "๐ท ใฏใคใณ", "๐น ใใผ"], "chatPlace": "ใจใใชใผใซ่ฉฑใใฆ...", "send": "้ไฟก", "home": "๐ ใใผใ ", "searchPlace": "ๅ ดๆๆค็ดข", "emilyName": "ใจใใชใผ", "reportHeader": "ใฌใใผใ", "aiBtn": "AI ใฌใใฅใผ", "mapLinkBtn": "ๅฐๅณ" }},
|
| 229 |
+
"CN": {{ "sub": "ๅ
จ็้
็ฑป้ไบงไนๆ
", "ai": "Chinese", "mapBtn": "๐บ๏ธ ๆข็ดขๅฐๅพ", "passBtn": "๐ ๆ็ๆค็
ง", "filters": ["๐ ๅ
จ้จ", "๐บ ไผ ็ป้
", "๐ฅ ๅจๅฃซๅฟ", "๐บ ๅค้
", "๐ท ่ก่้
", "๐น ้
ๅง"], "chatPlace": "ๅ่พ็ฑณไธฝ่่...", "send": "ๅ้", "home": "๐ ไธป้กต", "searchPlace": "ๆ็ดข", "emilyName": "่พ็ฑณไธฝ", "reportHeader": "ๆฅๅ", "aiBtn": "AI ็น่ฏ", "mapLinkBtn": "ๅฐๅพ" }}
|
| 230 |
}};
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
window.onload = function() {{
|
|
|
|
| 233 |
const keys = Object.keys(PLACE_DB).sort();
|
| 234 |
+
const select = document.getElementById('country-select');
|
| 235 |
+
keys.forEach(k => {{ const opt = document.createElement('option'); opt.value = k; opt.text = k; select.appendChild(opt); }});
|
| 236 |
if(keys.length > 0) selectCountry(keys[0]);
|
| 237 |
+
navigator.geolocation.getCurrentPosition(p => {{ userLat = p.coords.latitude; userLon = p.coords.longitude; }}, e => console.log("GPS Off"));
|
| 238 |
}};
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
function setLanguage(lang, el) {{
|
| 241 |
currentLang = lang;
|
| 242 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
|
|
|
| 258 |
function selectCountry(c) {{ selectedCountry = c; renderList(); }}
|
| 259 |
function filterType(t, el) {{ selectedType = t; document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected')); el.classList.add('selected'); renderList(); }}
|
| 260 |
|
| 261 |
+
// ๋ฆฌ์คํธ ๋ ๋๋ง (์ซ์ ID ๊ธฐ๋ฐ ํด๋ฆญ ์ด๋ฒคํธ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
function renderList() {{
|
| 263 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 264 |
const stamps = getStamps();
|
| 265 |
const visitedSet = new Set(stamps.map(s => s ? s.name + '|' + s.country : ''));
|
| 266 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 267 |
+
currentFilteredList = filtered;
|
| 268 |
const t = TRANSLATIONS[currentLang];
|
| 269 |
|
| 270 |
filtered.forEach((p, idx) => {{
|
| 271 |
const card = document.createElement('div');
|
| 272 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 273 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
| 274 |
+
let desc = (currentLang === 'KO' ? p.desc_ko : (currentLang === 'EN' ? p.desc_en : (currentLang === 'JP' ? p.desc_jp : p.desc_cn))) || p.desc_en || "...";
|
| 275 |
|
| 276 |
+
// [์์ ] ํ
์คํธ์ ์ง์ ์ ๊ทผํ์ง ์๊ณ ์ซ์(idx)๋ง ๋๊น
|
| 277 |
+
card.innerHTML = `<div class='visited-badge'>VISITED ๐ฎ</div>
|
| 278 |
+
<b>${{p.name}}</b>
|
| 279 |
+
<div class='pc-cat'>${{p.category}}</div>
|
| 280 |
+
<div class='pc-desc'>${{desc}}</div>
|
| 281 |
+
<div class='card-actions'>
|
| 282 |
+
<button class='btn-action btn-ai' onclick='clickAction(${{idx}}, "ai")'>${{t.aiBtn}}</button>
|
| 283 |
+
<button class='btn-action btn-map' onclick='clickAction(${{idx}}, "map")'>${{t.mapLinkBtn}}</button>
|
| 284 |
+
</div>`;
|
|
|
|
|
|
|
|
|
|
| 285 |
list.appendChild(card);
|
| 286 |
}});
|
| 287 |
}}
|
| 288 |
|
| 289 |
+
// ์ซ์ ID๋ก ๋ฐ์ดํฐ ์ฐพ๊ธฐ (์๋ฌ ๋ฐฉ์ง 1์์)
|
| 290 |
+
function clickAction(idx, type) {{
|
| 291 |
+
const p = currentFilteredList[idx];
|
| 292 |
+
if(!p) return;
|
| 293 |
+
if(type === 'ai') openDetail(p.name, selectedCountry);
|
| 294 |
+
else {{
|
| 295 |
+
const url = (selectedCountry.includes("Korea") || selectedCountry.includes("ํ๊ตญ"))
|
| 296 |
+
? "https://map.naver.com/p/search/" + encodeURIComponent(p.address || p.name)
|
| 297 |
+
: "http://google.com/maps/search/" + encodeURIComponent(p.name + " " + selectedCountry);
|
| 298 |
+
window.open(url, '_blank');
|
| 299 |
+
}}
|
| 300 |
}}
|
| 301 |
|
| 302 |
+
// ์ง๋ ํ์
ํด๏ฟฝ๏ฟฝ๏ฟฝ ํธ๋ค๋ฌ (์ซ์ Key ํ์ฉ)
|
| 303 |
+
function clickMapAction(key, type) {{
|
| 304 |
+
const data = MAP_CACHE[key];
|
| 305 |
+
if(!data) return;
|
| 306 |
+
if(type === 'ai') {{ closeWorldMapPage(); openDetail(data.name, data.country); }}
|
| 307 |
+
else window.open(data.url, '_blank');
|
| 308 |
+
}}
|
| 309 |
+
|
| 310 |
+
function getStamps() {{ try {{ return JSON.parse(localStorage.getItem('drunk_passport') || '[]'); }} catch(e) {{ return []; }} }}
|
| 311 |
function stampCurrentPlace() {{
|
| 312 |
+
if(!currentDetailPlace) return;
|
| 313 |
const stamps = getStamps();
|
| 314 |
+
if(stamps.find(s => s.name === currentDetailPlace.name)) return alert("Already Stamped!");
|
|
|
|
| 315 |
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 316 |
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 317 |
+
renderList(); alert("Stamped! ๐ฎ");
|
|
|
|
| 318 |
}}
|
| 319 |
|
| 320 |
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
| 321 |
function renderPassport() {{
|
| 322 |
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
| 323 |
+
getStamps().forEach(s => {{
|
| 324 |
+
if(!s.name) return;
|
|
|
|
| 325 |
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 326 |
+
el.innerHTML = `<div class='stamp-mark' style='transform: rotate(${{Math.random()*20-10}}deg)'>
|
| 327 |
+
<div class='stamp-country'>${{s.country}}</div>
|
| 328 |
+
<div class='stamp-name'>${{s.name}}</div>
|
| 329 |
+
<div class='stamp-date'>${{s.date}}</div>
|
| 330 |
+
</div>`;
|
| 331 |
grid.appendChild(el);
|
| 332 |
}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
}}
|
| 334 |
|
| 335 |
+
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(); }}
|
| 336 |
+
function importData(input) {{ const reader = new FileReader(); reader.onload = e => {{ localStorage.setItem('drunk_passport', e.target.result); renderList(); alert("Loaded!"); }}; reader.readAsText(input.files[0]); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
|
|
|
|
|
|
|
|
|
| 338 |
function openWorldMapPage() {{
|
| 339 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 340 |
if(!worldMap) {{
|
| 341 |
+
worldMap = L.map('full-map').setView([20, 0], 2);
|
| 342 |
+
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 343 |
+
MAP_CACHE = {{}}; mapIdCounter = 0;
|
|
|
|
| 344 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 345 |
if(p.lat && p.lon) {{
|
| 346 |
+
const key = mapIdCounter++;
|
| 347 |
+
const mapUrl = (c.includes("Korea") || c.includes("ํ๊ตญ"))
|
| 348 |
+
? "https://map.naver.com/p/search/" + encodeURIComponent(p.address || p.name)
|
| 349 |
+
: "http://google.com/maps/search/" + encodeURIComponent(p.name + " " + c);
|
| 350 |
+
MAP_CACHE[key] = {{ name: p.name, country: c, url: mapUrl }};
|
| 351 |
|
| 352 |
+
// [์ค์] ํ์
๋ฒํผ์๋ ์ซ์ ID(key)๋ง ๋๊น
|
| 353 |
+
const popupHtml = `<div style='text-align:center'><b>${{p.name}}</b><br>
|
| 354 |
+
<div style='display:flex; gap:5px; margin-top:5px;'>
|
| 355 |
+
<button onclick='clickMapAction(${{key}}, "ai")' style='background:#d4af37; border:none; padding:4px 8px; border-radius:4px; font-size:11px; cursor:pointer;'>๐ค AI</button>
|
| 356 |
+
<button onclick='clickMapAction(${{key}}, "map")' style='background:#333; color:white; border:none; padding:4px 8px; border-radius:4px; font-size:11px; cursor:pointer;'>๐บ๏ธ MAP</button>
|
| 357 |
+
</div></div>`;
|
| 358 |
+
L.marker([p.lat, p.lon]).bindPopup(popupHtml).addTo(worldMap);
|
| 359 |
}}
|
| 360 |
}}));
|
| 361 |
}}
|
| 362 |
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 363 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
|
| 365 |
+
async function callGroq(messages) {{
|
| 366 |
+
const url = "https://api.groq.com/openai/v1/chat/completions";
|
| 367 |
+
try {{
|
| 368 |
+
const res = await fetch(url, {{
|
| 369 |
+
method: 'POST',
|
| 370 |
+
headers: {{ 'Content-Type': 'application/json', 'Authorization': 'Bearer {GROQ_API_KEY}' }},
|
| 371 |
+
body: JSON.stringify({{ model: "llama-3.3-70b-versatile", messages: messages, temperature: 0.7 }})
|
| 372 |
+
}});
|
| 373 |
+
const data = await res.json(); return data.choices[0].message.content;
|
| 374 |
+
}} catch(e) {{ return "Error..."; }}
|
| 375 |
}}
|
| 376 |
|
| 377 |
+
function openChat() {{ document.getElementById('chat-page').style.transform = 'translateY(0%)'; }}
|
| 378 |
+
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 379 |
+
async function askBartender() {{
|
| 380 |
+
const inp = document.getElementById('chat-input'); const msg = inp.value.trim(); if(!msg) return;
|
| 381 |
+
addChatMessage(msg, 'user'); inp.value = "";
|
| 382 |
+
const res = await callGroq([{{ role: "system", content: "You are Emily. Act flirtatious. In " + TRANSLATIONS[currentLang].ai }}, {{ role: "user", content: msg }}]);
|
| 383 |
+
addChatMessage(res, 'bot');
|
| 384 |
+
}}
|
| 385 |
|
| 386 |
+
function addChatMessage(t, s) {{ const box = document.getElementById('chat-messages'); const div = document.createElement('div'); div.className = "msg " + s; div.innerText = t; box.appendChild(div); box.scrollTop = box.scrollHeight; }}
|
| 387 |
+
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 388 |
async function openDetail(n, c) {{
|
| 389 |
+
const p = PLACE_DB[c].find(x => x.name === n); if(!p) return;
|
| 390 |
currentDetailPlace = {{ name: n, country: c }};
|
| 391 |
+
document.getElementById('detail-page').style.transform = 'translateX(0%)';
|
| 392 |
+
document.getElementById('repo-title').innerText = n;
|
| 393 |
+
document.getElementById('loader').style.display='flex';
|
| 394 |
if(!miniMap) {{ miniMap = L.map('mini-map'); L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap); }}
|
| 395 |
+
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
|
| 396 |
+
const res = await callGroq([{{ role: "system", content: "Write a travel report in " + TRANSLATIONS[currentLang].ai }}, {{ role: "user", content: "Report for " + n }}]);
|
| 397 |
+
document.getElementById('loader').style.display='none';
|
| 398 |
+
document.getElementById('repo-content').innerText = res;
|
| 399 |
}}
|
| 400 |
|
|
|
|
|
|
|
| 401 |
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 402 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 403 |
+
async function searchLocation() {{
|
| 404 |
+
const q = document.getElementById('map-search-input').value; if(!q) return;
|
| 405 |
+
const res = await fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${{encodeURIComponent(q)}}`);
|
| 406 |
+
const data = await res.json();
|
| 407 |
+
if(data.length > 0) worldMap.flyTo([data[0].lat, data[0].lon], 12);
|
| 408 |
+
}}
|
| 409 |
+
function flyToUserLocation() {{ if(userLat) worldMap.flyTo([userLat, userLon], 14); }}
|
| 410 |
</script>
|
| 411 |
</body>
|
| 412 |
</html>
|