Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,10 @@ 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")
|
| 15 |
|
| 16 |
st.set_page_config(page_title="Drunken Plane", page_icon="✈️", layout="wide")
|
| 17 |
|
|
@@ -24,7 +24,7 @@ st.markdown("""
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
-
# 2. 데이터 로드 및
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
|
@@ -32,15 +32,11 @@ try:
|
|
| 32 |
if SHEET_URL:
|
| 33 |
response = requests.get(SHEET_URL)
|
| 34 |
response.raise_for_status()
|
| 35 |
-
|
| 36 |
-
try:
|
| 37 |
-
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 38 |
-
except:
|
| 39 |
-
df = pd.read_csv(io.StringIO(response.text), engine='python', on_bad_lines='skip')
|
| 40 |
|
| 41 |
-
# [
|
| 42 |
for col in df.select_dtypes(include=['object']).columns:
|
| 43 |
-
df[col] = df[col].astype(str).
|
| 44 |
|
| 45 |
df.columns = df.columns.str.strip()
|
| 46 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
|
@@ -49,20 +45,10 @@ try:
|
|
| 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:
|
| 57 |
-
PLACE_DB = json.load(f)
|
| 58 |
-
|
| 59 |
except Exception as e:
|
| 60 |
-
st.error(f"
|
| 61 |
-
PLACE_DB = {}
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
# 3. 데이터 인코딩
|
| 65 |
-
# ==========================================
|
| 66 |
emily_base64 = ""
|
| 67 |
if os.path.exists('emily.jpg'):
|
| 68 |
try:
|
|
@@ -70,12 +56,11 @@ if os.path.exists('emily.jpg'):
|
|
| 70 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 71 |
except: pass
|
| 72 |
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
db_base64 = base64.b64encode(db_json_raw.encode('utf-8')).decode('utf-8')
|
| 76 |
|
| 77 |
# ==========================================
|
| 78 |
-
#
|
| 79 |
# ==========================================
|
| 80 |
html_code = f"""
|
| 81 |
<!DOCTYPE html>
|
|
@@ -101,53 +86,38 @@ html_code = f"""
|
|
| 101 |
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px; }}
|
| 102 |
.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); }}
|
| 103 |
.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; }}
|
| 104 |
-
.country-select
|
| 105 |
-
.country-select {{ width: 100%; padding: 14px; background: rgba(30,30,30,0.9); border: 1px solid var(--gold); color: white; font-size: 16px; border-radius: 10px; outline: none; }}
|
| 106 |
.type-filter-container {{ width: 100%; padding: 10px 20px; overflow-x: auto; display: flex; gap: 8px; scrollbar-width: none; }}
|
| 107 |
.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; }}
|
| 108 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 109 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 110 |
-
.place-card {{ background: rgba(30,30,30,0.6); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); border-radius: 15px; padding: 18px; margin-bottom: 15px; position: relative;
|
| 111 |
-
.place-card.visited {{ background: linear-gradient(135deg, rgba(40,10,10,0.9), rgba(20,20,20,0.9));
|
| 112 |
.visited-badge {{ position: absolute; top: 10px; right: 10px; background: var(--gold); color: black; font-size: 10px; font-weight: bold; padding: 3px 8px; border-radius: 10px; display: none; }}
|
| 113 |
.place-card.visited .visited-badge {{ display: block; }}
|
| 114 |
-
.pc-name {{ font-size: 18px; font-weight: bold; color: white; }}
|
| 115 |
-
.place-card.visited .pc-name {{ color: var(--gold); }}
|
| 116 |
-
.pc-cat {{ font-size: 11px; color: var(--gold); font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }}
|
| 117 |
-
.pc-desc {{ font-size: 13px; color: #bbb; line-height: 1.5; margin-top: 5px; }}
|
| 118 |
.card-actions {{ display: flex; gap: 10px; margin-top: 15px; }}
|
| 119 |
.btn-action {{ flex: 1; padding: 12px; border-radius: 8px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; }}
|
| 120 |
.btn-ai {{ background: var(--gold); color: black; }}
|
| 121 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 122 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 123 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 124 |
-
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6;
|
| 125 |
.msg.bot {{ align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }}
|
| 126 |
.msg.user {{ align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }}
|
| 127 |
-
.reco-btn {{ display: inline-block; margin-top: 10px; padding: 12px 20px; background: var(--gold); color: black !important; border-radius: 20px; font-weight: 900; text-decoration: none; font-size: 13px; text-align: center; border: none; cursor: pointer; }}
|
| 128 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
| 129 |
.chat-input {{ flex: 1; background: #222; border: 1px solid #444; color: white; padding: 14px; border-radius: 10px; outline: none; }}
|
| 130 |
#detail-page {{ background: #111; z-index: 300; transform: translateX(100%); display: flex; flex-direction: column; }}
|
| 131 |
-
.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; }}
|
| 132 |
#mini-map {{ width: 100%; height: 35%; border-bottom: 2px solid var(--gold); }}
|
| 133 |
-
.stamp-btn {{ width: 100%; background: #4a1c1c; color: #ffcc00; border: 2px dashed #ffcc00; padding: 15px; margin-top: 20px; border-radius: 10px; font-weight: bold; cursor: pointer;
|
| 134 |
-
.stamp-btn:hover {{ background: #ffcc00; color: #4a1c1c; border-style: solid; }}
|
| 135 |
#passport-page {{ background: #1a1a1a; z-index: 400; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 136 |
-
.passport-
|
| 137 |
-
.passport-grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px; padding: 25px; overflow-y: auto; flex: 1; background-image: radial-gradient(#333 15%, transparent 16%), radial-gradient(#333 15%, transparent 16%); background-size: 20px 20px; }}
|
| 138 |
.stamp-card {{ aspect-ratio: 1/1; display: flex; justify-content: center; align-items: center; position: relative; }}
|
| 139 |
-
.stamp-mark {{ width: 110px; height: 110px; border: 3px double #d42222; border-radius: 50%; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #d42222; font-family: 'Special Elite', cursive; transform: rotate(-12deg); background: rgba(212, 34, 34, 0.05);
|
| 140 |
-
.stamp-country {{ font-size: 10px; letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid #d42222; margin-bottom: 5px; }}
|
| 141 |
-
.stamp-name {{ font-size: 13px; font-weight: bold; line-height: 1.2; margin-bottom: 5px; }}
|
| 142 |
-
.stamp-date {{ font-size: 10px; font-family: monospace; }}
|
| 143 |
-
.data-controls {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; justify-content: center; }}
|
| 144 |
-
.data-btn {{ background: #333; border: 1px solid #555; color: #ccc; padding: 10px 15px; border-radius: 5px; cursor: pointer; font-size: 12px; }}
|
| 145 |
#world-map-page {{ background: #111; z-index: 200; transform: translateY(100%); }}
|
| 146 |
#full-map {{ width: 100%; height: 100%; }}
|
| 147 |
-
.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);
|
| 148 |
.search-input {{ background: transparent; border: none; color: white; outline: none; width: 180px; font-size: 15px; }}
|
| 149 |
-
.
|
| 150 |
-
.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; box-shadow: 0 4px 15px rgba(212, 175, 55, 0.6); display: flex; justify-content: center; align-items: center; animation: bounce-float 3s ease-in-out infinite; }}
|
| 151 |
.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; }}
|
| 152 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 153 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
@@ -156,18 +126,18 @@ html_code = f"""
|
|
| 156 |
<body>
|
| 157 |
<div id="main-page" class="page">
|
| 158 |
<div class="lang-switcher">
|
| 159 |
-
<div class="lang-btn active"
|
| 160 |
-
<div class="lang-btn"
|
| 161 |
-
<div class="lang-btn"
|
| 162 |
-
<div class="lang-btn"
|
| 163 |
</div>
|
| 164 |
<div style="text-align:center; padding:10px 0;">
|
| 165 |
<div class="brand-title">DRUNKEN PLANE</div>
|
| 166 |
<div id="app-subtitle" class="brand-subtitle">GLOBAL ALCOHOL HERITAGE TOUR</div>
|
| 167 |
-
<button
|
| 168 |
-
<button
|
| 169 |
</div>
|
| 170 |
-
<
|
| 171 |
<div class="type-filter-container">
|
| 172 |
<div class="type-btn selected" id="f-btn-0" onclick="filterType('All', this)">🌐 All</div>
|
| 173 |
<div class="type-btn" id="f-btn-1" onclick="filterType('Traditional', this)">🏺 Trad.</div>
|
|
@@ -181,52 +151,63 @@ html_code = f"""
|
|
| 181 |
</div>
|
| 182 |
|
| 183 |
<div id="chat-page" class="page">
|
| 184 |
-
<div class="nav-bar"
|
|
|
|
|
|
|
|
|
|
| 185 |
<div id="chat-messages"></div>
|
| 186 |
-
<div class="chat-input-area">
|
|
|
|
|
|
|
|
|
|
| 187 |
</div>
|
| 188 |
|
| 189 |
<div id="detail-page" class="page">
|
| 190 |
-
<div class="nav-bar"
|
|
|
|
|
|
|
| 191 |
<div id="mini-map"></div>
|
| 192 |
-
<div
|
| 193 |
-
<div id="repo-title" style="font-size:24px; color:var(--gold); font-weight:bold;
|
| 194 |
-
<div id="repo-content" style="
|
| 195 |
<button class="stamp-btn" onclick="stampCurrentPlace()">💮 Stamp This Place</button>
|
| 196 |
</div>
|
| 197 |
</div>
|
| 198 |
|
| 199 |
<div id="passport-page" class="page">
|
| 200 |
-
<div class="
|
|
|
|
|
|
|
| 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">
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
<script>
|
| 209 |
-
// 안전
|
| 210 |
-
|
| 211 |
-
|
| 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 |
-
|
| 219 |
-
|
| 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": {{ "
|
| 227 |
-
"EN": {{ "
|
| 228 |
-
"JP": {{ "
|
| 229 |
-
"CN": {{ "
|
| 230 |
}};
|
| 231 |
|
| 232 |
window.onload = function() {{
|
|
@@ -237,176 +218,139 @@ html_code = f"""
|
|
| 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'));
|
| 243 |
el.classList.add('active');
|
| 244 |
-
const t = TRANSLATIONS[currentLang];
|
| 245 |
-
document.getElementById('app-subtitle').innerText = t.sub;
|
| 246 |
-
document.getElementById('world-map-btn').innerText = t.mapBtn;
|
| 247 |
-
document.getElementById('passport-btn').innerText = t.passBtn;
|
| 248 |
-
document.getElementById('chat-input').placeholder = t.chatPlace;
|
| 249 |
-
document.getElementById('chat-send-btn').innerText = t.send;
|
| 250 |
-
document.getElementById('nav-home-btn').innerText = t.home;
|
| 251 |
-
document.getElementById('map-search-input').placeholder = t.searchPlace;
|
| 252 |
-
document.getElementById('emily-name').innerText = t.emilyName;
|
| 253 |
-
document.getElementById('repo-header').innerText = t.reportHeader;
|
| 254 |
-
for(let i=0; i<6; i++) {{ document.getElementById('f-btn-' + i).innerText = t.filters[i]; }}
|
| 255 |
renderList();
|
| 256 |
}}
|
| 257 |
|
| 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 =
|
| 265 |
-
const visitedSet = new Set(stamps.map(s => s
|
| 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 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 297 |
-
|
| 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 |
-
|
| 344 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 345 |
if(p.lat && p.lon) {{
|
| 346 |
const key = mapIdCounter++;
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 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 |
-
|
| 366 |
-
const
|
| 367 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
|
| 396 |
-
|
|
|
|
| 397 |
document.getElementById('loader').style.display='none';
|
| 398 |
document.getElementById('repo-content').innerText = res;
|
| 399 |
}}
|
| 400 |
|
| 401 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
const
|
| 407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
}}
|
| 409 |
-
function flyToUserLocation() {{ if(userLat) worldMap.flyTo([userLat, userLon], 14); }}
|
| 410 |
</script>
|
| 411 |
</body>
|
| 412 |
</html>
|
|
|
|
| 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", "")
|
| 15 |
|
| 16 |
st.set_page_config(page_title="Drunken Plane", page_icon="✈️", layout="wide")
|
| 17 |
|
|
|
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
| 26 |
# ==========================================
|
| 27 |
+
# 2. 데이터 로드 및 정제 (JS 에러 원천 봉쇄)
|
| 28 |
# ==========================================
|
| 29 |
PLACE_DB = {}
|
| 30 |
|
|
|
|
| 32 |
if SHEET_URL:
|
| 33 |
response = requests.get(SHEET_URL)
|
| 34 |
response.raise_for_status()
|
| 35 |
+
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
# [방어막] 모든 문자열에서 따옴표, 역슬래시, 줄바꿈 제거 (에러의 주범들)
|
| 38 |
for col in df.select_dtypes(include=['object']).columns:
|
| 39 |
+
df[col] = df[col].astype(str).replace({r'["\\'']': '', r'[\r\n\t]+': ' '}, regex=True)
|
| 40 |
|
| 41 |
df.columns = df.columns.str.strip()
|
| 42 |
col_mapping = {col: 'Country' for col in df.columns if col.lower() == 'country'}
|
|
|
|
| 45 |
if 'Country' in df.columns:
|
| 46 |
for country, group in df.groupby('Country'):
|
| 47 |
PLACE_DB[country] = group.fillna("").to_dict(orient='records')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
+
st.error(f"데이터 로드 실패: {e}")
|
|
|
|
| 50 |
|
| 51 |
+
# 에밀리 이미지
|
|
|
|
|
|
|
| 52 |
emily_base64 = ""
|
| 53 |
if os.path.exists('emily.jpg'):
|
| 54 |
try:
|
|
|
|
| 56 |
emily_base64 = base64.b64encode(f.read()).decode()
|
| 57 |
except: pass
|
| 58 |
|
| 59 |
+
# JS에 넘길 데이터 인코딩
|
| 60 |
+
db_json_encoded = base64.b64encode(json.dumps(PLACE_DB, ensure_ascii=False).encode('utf-8')).decode('utf-8')
|
|
|
|
| 61 |
|
| 62 |
# ==========================================
|
| 63 |
+
# 3. 프론트엔드 (f-string 중괄호 완벽 보호)
|
| 64 |
# ==========================================
|
| 65 |
html_code = f"""
|
| 66 |
<!DOCTYPE html>
|
|
|
|
| 86 |
.brand-subtitle {{ font-size: 11px; color: #ccc; letter-spacing: 2px; margin-bottom: 15px; }}
|
| 87 |
.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); }}
|
| 88 |
.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; }}
|
| 89 |
+
.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; }}
|
|
|
|
| 90 |
.type-filter-container {{ width: 100%; padding: 10px 20px; overflow-x: auto; display: flex; gap: 8px; scrollbar-width: none; }}
|
| 91 |
.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; }}
|
| 92 |
.type-btn.selected {{ background: var(--gold); color: black; border-color: var(--gold); }}
|
| 93 |
.place-list-container {{ width: 100%; max-width: 600px; flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; box-sizing: border-box; }}
|
| 94 |
+
.place-card {{ background: rgba(30,30,30,0.6); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); border-radius: 15px; padding: 18px; margin-bottom: 15px; position: relative; }}
|
| 95 |
+
.place-card.visited {{ border: 1px solid var(--gold); background: linear-gradient(135deg, rgba(40,10,10,0.9), rgba(20,20,20,0.9)); }}
|
| 96 |
.visited-badge {{ position: absolute; top: 10px; right: 10px; background: var(--gold); color: black; font-size: 10px; font-weight: bold; padding: 3px 8px; border-radius: 10px; display: none; }}
|
| 97 |
.place-card.visited .visited-badge {{ display: block; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
.card-actions {{ display: flex; gap: 10px; margin-top: 15px; }}
|
| 99 |
.btn-action {{ flex: 1; padding: 12px; border-radius: 8px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; }}
|
| 100 |
.btn-ai {{ background: var(--gold); color: black; }}
|
| 101 |
.btn-map {{ background: #333; color: white; border: 1px solid #555; }}
|
| 102 |
#chat-page {{ background: var(--dark); z-index: 1000; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 103 |
#chat-messages {{ flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 15px; }}
|
| 104 |
+
.msg {{ max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; }}
|
| 105 |
.msg.bot {{ align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }}
|
| 106 |
.msg.user {{ align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }}
|
|
|
|
| 107 |
.chat-input-area {{ padding: 15px; background: #111; border-top: 1px solid #333; display: flex; gap: 10px; }}
|
| 108 |
.chat-input {{ flex: 1; background: #222; border: 1px solid #444; color: white; padding: 14px; border-radius: 10px; outline: none; }}
|
| 109 |
#detail-page {{ background: #111; z-index: 300; transform: translateX(100%); display: flex; flex-direction: column; }}
|
|
|
|
| 110 |
#mini-map {{ width: 100%; height: 35%; border-bottom: 2px solid var(--gold); }}
|
| 111 |
+
.stamp-btn {{ width: 100%; background: #4a1c1c; color: #ffcc00; border: 2px dashed #ffcc00; padding: 15px; margin-top: 20px; border-radius: 10px; font-weight: bold; cursor: pointer; }}
|
|
|
|
| 112 |
#passport-page {{ background: #1a1a1a; z-index: 400; transform: translateY(100%); display: flex; flex-direction: column; }}
|
| 113 |
+
.passport-grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px; padding: 25px; overflow-y: auto; flex: 1; }}
|
|
|
|
| 114 |
.stamp-card {{ aspect-ratio: 1/1; display: flex; justify-content: center; align-items: center; position: relative; }}
|
| 115 |
+
.stamp-mark {{ width: 110px; height: 110px; border: 3px double #d42222; border-radius: 50%; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #d42222; font-family: 'Special Elite', cursive; transform: rotate(-12deg); background: rgba(212, 34, 34, 0.05); text-align: center; padding: 10px; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
#world-map-page {{ background: #111; z-index: 200; transform: translateY(100%); }}
|
| 117 |
#full-map {{ width: 100%; height: 100%; }}
|
| 118 |
+
.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); }}
|
| 119 |
.search-input {{ background: transparent; border: none; color: white; outline: none; width: 180px; font-size: 15px; }}
|
| 120 |
+
.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; }}
|
|
|
|
| 121 |
.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; }}
|
| 122 |
.loader-ring {{ width: 45px; height: 45px; border: 4px solid #333; border-top: 4px solid var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }}
|
| 123 |
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
|
|
|
| 126 |
<body>
|
| 127 |
<div id="main-page" class="page">
|
| 128 |
<div class="lang-switcher">
|
| 129 |
+
<div class="lang-btn active" onclick="setLanguage('KO', this)">🇰🇷</div>
|
| 130 |
+
<div class="lang-btn" onclick="setLanguage('EN', this)">🇺🇸</div>
|
| 131 |
+
<div class="lang-btn" onclick="setLanguage('JP', this)">🇯🇵</div>
|
| 132 |
+
<div class="lang-btn" onclick="setLanguage('CN', this)">🇨🇳</div>
|
| 133 |
</div>
|
| 134 |
<div style="text-align:center; padding:10px 0;">
|
| 135 |
<div class="brand-title">DRUNKEN PLANE</div>
|
| 136 |
<div id="app-subtitle" class="brand-subtitle">GLOBAL ALCOHOL HERITAGE TOUR</div>
|
| 137 |
+
<button class="world-map-btn" onclick="openWorldMapPage()">🗺️ WORLD MAP EXPLORER</button>
|
| 138 |
+
<button class="passport-btn" onclick="openPassportPage()" style="margin: 10px auto;">📘 MY PASSPORT</button>
|
| 139 |
</div>
|
| 140 |
+
<center><select id="country-select" class="country-select" onchange="selectCountry(this.value)"></select></center>
|
| 141 |
<div class="type-filter-container">
|
| 142 |
<div class="type-btn selected" id="f-btn-0" onclick="filterType('All', this)">🌐 All</div>
|
| 143 |
<div class="type-btn" id="f-btn-1" onclick="filterType('Traditional', this)">🏺 Trad.</div>
|
|
|
|
| 151 |
</div>
|
| 152 |
|
| 153 |
<div id="chat-page" class="page">
|
| 154 |
+
<div class="nav-bar" style="background:#111; padding:15px; display:flex; align-items:center;">
|
| 155 |
+
<button onclick="closeChat()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button>
|
| 156 |
+
<div id="emily-name" style="color:var(--gold); font-weight:bold; margin-left:15px;">에밀리</div>
|
| 157 |
+
</div>
|
| 158 |
<div id="chat-messages"></div>
|
| 159 |
+
<div class="chat-input-area">
|
| 160 |
+
<input type="text" id="chat-input" class="chat-input" placeholder="..." onkeydown="if(event.key === 'Enter') askBartender()">
|
| 161 |
+
<button onclick="askBartender()" style="background:var(--gold); border:none; padding:10px 20px; border-radius:8px; font-weight:bold;">SEND</button>
|
| 162 |
+
</div>
|
| 163 |
</div>
|
| 164 |
|
| 165 |
<div id="detail-page" class="page">
|
| 166 |
+
<div class="nav-bar" style="background:#000; padding:15px;">
|
| 167 |
+
<button onclick="closeDetail()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button>
|
| 168 |
+
</div>
|
| 169 |
<div id="mini-map"></div>
|
| 170 |
+
<div style="flex:1; overflow-y:auto; padding:20px;">
|
| 171 |
+
<div id="repo-title" style="font-size:24px; color:var(--gold); font-weight:bold;"></div>
|
| 172 |
+
<div id="repo-content" style="margin-top:15px; line-height:1.8; white-space:pre-wrap;"></div>
|
| 173 |
<button class="stamp-btn" onclick="stampCurrentPlace()">💮 Stamp This Place</button>
|
| 174 |
</div>
|
| 175 |
</div>
|
| 176 |
|
| 177 |
<div id="passport-page" class="page">
|
| 178 |
+
<div class="nav-bar" style="background:#2c0b0e; padding:15px;">
|
| 179 |
+
<button onclick="closePassportPage()" style="background:none; border:none; color:var(--gold); font-size:24px;">←</button>
|
| 180 |
+
</div>
|
| 181 |
<div id="passport-grid" class="passport-grid"></div>
|
|
|
|
| 182 |
</div>
|
| 183 |
|
| 184 |
+
<div id="world-map-page" class="page">
|
| 185 |
+
<div class="nav-bar" style="background:#000; padding:15px;">
|
| 186 |
+
<button onclick="closeWorldMapPage()" style="background:none; border:none; color:var(--gold); font-size:18px;">🏠 HOME</button>
|
| 187 |
+
</div>
|
| 188 |
+
<div class="map-search-bar">
|
| 189 |
+
<input type="text" id="map-search-input" class="search-input" placeholder="..." onkeydown="if(event.key === 'Enter') searchLocation()">
|
| 190 |
+
<button onclick="searchLocation()" style="background:var(--gold); border:none; border-radius:50%; width:30px; height:30px;">🔍</button>
|
| 191 |
+
</div>
|
| 192 |
+
<button class="map-gps-btn" onclick="flyToUserLocation()">🎯</button>
|
| 193 |
+
<div id="full-map"></div>
|
| 194 |
+
</div>
|
| 195 |
+
|
| 196 |
+
<div id="loader" class="loading-screen"><div class="loader-ring"></div><div id="loader-msg" style="color:var(--gold); margin-top:15px;"></div></div>
|
| 197 |
|
| 198 |
<script>
|
| 199 |
+
// [안전장치] Base64로 데이터를 받아 파싱 (문자열 깨짐 방지)
|
| 200 |
+
const RAW_DATA = "{db_json_encoded}";
|
| 201 |
+
const PLACE_DB = JSON.parse(decodeURIComponent(escape(atob(RAW_DATA))));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
+
let userLat=null, userLon=null, selectedCountry="", selectedType="All", currentLang="KO", chatInitialized=false;
|
| 204 |
+
let miniMap=null, worldMap=null, currentFilteredList=[], mapCache={{}}, mapIdCounter=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
const TRANSLATIONS = {{
|
| 207 |
+
"KO": {{ "ai": "Korean", "aiBtn": "AI 리뷰", "mapLinkBtn": "지도" }},
|
| 208 |
+
"EN": {{ "ai": "English", "aiBtn": "AI REVIEW", "mapLinkBtn": "MAP" }},
|
| 209 |
+
"JP": {{ "ai": "Japanese", "aiBtn": "AI レビュー", "mapLinkBtn": "地図" }},
|
| 210 |
+
"CN": {{ "ai": "Chinese", "aiBtn": "AI 点评", "mapLinkBtn": "地图" }}
|
| 211 |
}};
|
| 212 |
|
| 213 |
window.onload = function() {{
|
|
|
|
| 218 |
navigator.geolocation.getCurrentPosition(p => {{ userLat = p.coords.latitude; userLon = p.coords.longitude; }}, e => console.log("GPS Off"));
|
| 219 |
}};
|
| 220 |
|
| 221 |
+
function selectCountry(c) {{ selectedCountry = c; renderList(); }}
|
| 222 |
+
function filterType(t, el) {{
|
| 223 |
+
selectedType = t;
|
| 224 |
+
document.querySelectorAll('.type-btn').forEach(b => b.classList.remove('selected'));
|
| 225 |
+
el.classList.add('selected');
|
| 226 |
+
renderList();
|
| 227 |
+
}}
|
| 228 |
+
|
| 229 |
function setLanguage(lang, el) {{
|
| 230 |
currentLang = lang;
|
| 231 |
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
| 232 |
el.classList.add('active');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
renderList();
|
| 234 |
}}
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
function renderList() {{
|
| 237 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 238 |
+
const stamps = JSON.parse(localStorage.getItem('drunk_passport') || '[]');
|
| 239 |
+
const visitedSet = new Set(stamps.map(s => s.name + '|' + s.country));
|
| 240 |
const filtered = (PLACE_DB[selectedCountry] || []).filter(p => selectedType === "All" || p.category === selectedType);
|
| 241 |
currentFilteredList = filtered;
|
|
|
|
| 242 |
|
| 243 |
filtered.forEach((p, idx) => {{
|
|
|
|
| 244 |
const isVisited = visitedSet.has(p.name + '|' + selectedCountry);
|
| 245 |
+
const card = document.createElement('div');
|
| 246 |
card.className = isVisited ? 'place-card visited' : 'place-card';
|
|
|
|
| 247 |
|
| 248 |
+
const t = TRANSLATIONS[currentLang];
|
| 249 |
+
const desc = p['desc_' + currentLang.toLowerCase()] || p.desc_en || "...";
|
| 250 |
+
|
| 251 |
+
// [안전] 숫자로만 버튼 이벤트 연결
|
| 252 |
+
card.innerHTML = `
|
| 253 |
+
<div class='visited-badge'>VISITED 💮</div>
|
| 254 |
+
<b style='font-size:18px;'>${{p.name}}</b>
|
| 255 |
+
<div style='color:var(--gold); font-size:11px;'>${{p.category}}</div>
|
| 256 |
+
<div style='font-size:13px; color:#bbb; margin-top:5px;'>${{desc}}</div>
|
| 257 |
+
<div class='card-actions'>
|
| 258 |
+
<button class='btn-action btn-ai' onclick='clickAction(${{idx}}, "ai")'>${{t.aiBtn}}</button>
|
| 259 |
+
<button class='btn-action btn-map' onclick='clickAction(${{idx}}, "map")'>${{t.mapLinkBtn}}</button>
|
| 260 |
+
</div>
|
| 261 |
+
`;
|
| 262 |
list.appendChild(card);
|
| 263 |
}});
|
| 264 |
}}
|
| 265 |
|
|
|
|
| 266 |
function clickAction(idx, type) {{
|
| 267 |
const p = currentFilteredList[idx];
|
| 268 |
if(!p) return;
|
| 269 |
if(type === 'ai') openDetail(p.name, selectedCountry);
|
| 270 |
else {{
|
| 271 |
+
const url = (selectedCountry.includes("Korea") || selectedCountry.includes("한국"))
|
| 272 |
+
? "https://map.naver.com/p/search/" + encodeURIComponent(p.address || p.name)
|
| 273 |
+
: "https://www.google.com/maps/search/" + encodeURIComponent(p.name + " " + selectedCountry);
|
| 274 |
window.open(url, '_blank');
|
| 275 |
}}
|
| 276 |
}}
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
function openWorldMapPage() {{
|
| 279 |
document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 280 |
if(!worldMap) {{
|
| 281 |
worldMap = L.map('full-map').setView([20, 0], 2);
|
| 282 |
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(worldMap);
|
| 283 |
+
mapCache = {{}}; mapIdCounter = 0;
|
| 284 |
Object.keys(PLACE_DB).forEach(c => PLACE_DB[c].forEach(p => {{
|
| 285 |
if(p.lat && p.lon) {{
|
| 286 |
const key = mapIdCounter++;
|
| 287 |
+
mapCache[key] = {{ name: p.name, country: c }};
|
| 288 |
+
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>`;
|
| 289 |
+
L.marker([p.lat, p.lon]).bindPopup(html).addTo(worldMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
}}
|
| 291 |
}}));
|
| 292 |
}}
|
| 293 |
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 294 |
}}
|
| 295 |
|
| 296 |
+
function clickMapDetail(key) {{
|
| 297 |
+
const data = mapCache[key];
|
| 298 |
+
if(data) {{ closeWorldMapPage(); openDetail(data.name, data.country); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 }};
|
| 304 |
document.getElementById('detail-page').style.transform = 'translateX(0%)';
|
| 305 |
document.getElementById('repo-title').innerText = n;
|
| 306 |
document.getElementById('loader').style.display='flex';
|
| 307 |
+
|
| 308 |
+
if(!miniMap) {{
|
| 309 |
+
miniMap = L.map('mini-map');
|
| 310 |
+
L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap);
|
| 311 |
+
}}
|
| 312 |
setTimeout(() => {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
|
| 313 |
+
|
| 314 |
+
const res = await callGroq([{{ role: "system", content: "You are Emily. Write a report." }}, {{ role: "user", content: "Review " + n + " in " + c }}]);
|
| 315 |
document.getElementById('loader').style.display='none';
|
| 316 |
document.getElementById('repo-content').innerText = res;
|
| 317 |
}}
|
| 318 |
|
| 319 |
+
async function callGroq(msgs) {{
|
| 320 |
+
try {{
|
| 321 |
+
const res = await fetch("https://api.groq.com/openai/v1/chat/completions", {{
|
| 322 |
+
method: "POST",
|
| 323 |
+
headers: {{ "Content-Type": "application/json", "Authorization": "Bearer {GROQ_API_KEY}" }},
|
| 324 |
+
body: JSON.stringify({{ model: "llama-3.3-70b-versatile", messages: msgs }})
|
| 325 |
+
}});
|
| 326 |
+
const data = await res.json();
|
| 327 |
+
return data.choices[0].message.content;
|
| 328 |
+
}} catch(e) {{ return "Error..."; }}
|
| 329 |
+
}}
|
| 330 |
+
|
| 331 |
+
function openChat() {{ document.getElementById('chat-page').style.transform = 'translateY(0%)'; }}
|
| 332 |
+
function closeChat() {{ document.getElementById('chat-page').style.transform = 'translateY(100%)'; }}
|
| 333 |
+
function closeDetail() {{ document.getElementById('detail-page').style.transform = 'translateX(100%)'; }}
|
| 334 |
+
function openPassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(0%)'; renderPassport(); }}
|
| 335 |
function closePassportPage() {{ document.getElementById('passport-page').style.transform = 'translateY(100%)'; }}
|
| 336 |
+
function closeWorldMapPage() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
|
| 337 |
+
|
| 338 |
+
function stampCurrentPlace() {{
|
| 339 |
+
const stamps = JSON.parse(localStorage.getItem('drunk_passport') || '[]');
|
| 340 |
+
stamps.push({{ name: currentDetailPlace.name, country: currentDetailPlace.country, date: new Date().toLocaleDateString() }});
|
| 341 |
+
localStorage.setItem('drunk_passport', JSON.stringify(stamps));
|
| 342 |
+
renderList(); alert("Stamped! 💮");
|
| 343 |
+
}}
|
| 344 |
+
|
| 345 |
+
function renderPassport() {{
|
| 346 |
+
const grid = document.getElementById('passport-grid'); grid.innerHTML = "";
|
| 347 |
+
const stamps = JSON.parse(localStorage.getItem('drunk_passport') || '[]');
|
| 348 |
+
stamps.forEach(s => {{
|
| 349 |
+
const el = document.createElement('div'); el.className = 'stamp-card';
|
| 350 |
+
el.innerHTML = `<div class='stamp-mark'><div>${{s.country}}</div><div style='font-weight:bold;'>${{s.name}}</div><div style='font-size:10px;'>${{s.date}}</div></div>`;
|
| 351 |
+
grid.appendChild(el);
|
| 352 |
+
}});
|
| 353 |
}}
|
|
|
|
| 354 |
</script>
|
| 355 |
</body>
|
| 356 |
</html>
|