Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,12 +32,9 @@ try:
|
|
| 32 |
response = requests.get(SHEET_URL)
|
| 33 |
response.encoding = 'utf-8'
|
| 34 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
| 35 |
-
|
| 36 |
-
# 컬λΌλͺ
μ 리 λ° ν
μ€νΈ ν΄λ μ§ (JS μ€λ₯ λ°©μ§)
|
| 37 |
df.columns = df.columns.str.strip()
|
| 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 |
-
|
| 41 |
if 'Country' in df.columns:
|
| 42 |
for country, group in df.groupby('Country'):
|
| 43 |
PLACE_DB[country] = group.fillna("").to_dict(orient='records')
|
|
@@ -53,7 +50,7 @@ db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
|
|
| 53 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 54 |
|
| 55 |
# ==========================================
|
| 56 |
-
# 3. ν΅ν© νλ‘ νΈμλ
|
| 57 |
# ==========================================
|
| 58 |
html_template = """
|
| 59 |
<!DOCTYPE html>
|
|
@@ -80,7 +77,7 @@ html_template = """
|
|
| 80 |
.type-btn { padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: bold; background: #1a1a1a; color: #777; border: 1px solid #333; white-space: nowrap; cursor: pointer; }
|
| 81 |
.type-btn.selected { background: var(--gold); color: black; border-color: var(--gold); }
|
| 82 |
|
| 83 |
-
/*
|
| 84 |
.place-list-container { flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; }
|
| 85 |
.place-card { background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 20px; margin-bottom: 15px; position: relative; }
|
| 86 |
.pc-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
|
@@ -89,28 +86,25 @@ html_template = """
|
|
| 89 |
.pc-desc { font-size: 13.5px; color: #aaa; line-height: 1.6; margin: 12px 0; }
|
| 90 |
.btn-action { flex: 1; padding: 12px; border-radius: 10px; border: none; font-weight: bold; cursor: pointer; font-size: 12px; }
|
| 91 |
|
| 92 |
-
/*
|
| 93 |
.bartender-btn { position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%; background-image: url('IMAGE_DATA'); background-size: cover; border: 3px solid var(--gold); z-index: 999; box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); cursor: pointer; }
|
| 94 |
|
| 95 |
/* νμ΄μ§ μ ν */
|
| 96 |
#world-map-page, #passport-page, #chat-page { background: #000; z-index: 2000; transform: translateY(100%); }
|
| 97 |
#passport-page { transform: translateX(-100%); background: #0f0f1b; }
|
| 98 |
#detail-page { background: #0a0a0a; z-index: 4000; transform: translateX(100%); }
|
| 99 |
-
.nav-bar { height: 60px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #222; background: #111; }
|
| 100 |
|
| 101 |
-
|
| 102 |
.msg { max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
|
| 103 |
.msg.bot { align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }
|
| 104 |
.msg.user { align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
/*
|
| 107 |
-
.reco-btn { display: inline-block; margin-top: 10px; padding: 10px 15px; background: var(--gold); color: black !important; border-radius: 15px; font-weight: bold; text-decoration: none; font-size: 12px; cursor: pointer; border:none; width: 100%; }
|
| 108 |
-
|
| 109 |
-
/* νμ
λ²νΌ */
|
| 110 |
.popup-btn { background: var(--gold); color: black; border: none; padding: 5px 10px; border-radius: 5px; font-weight: bold; font-size: 11px; cursor: pointer; margin-top: 5px; width: 100%; }
|
| 111 |
.leaflet-popup-content-wrapper { background: #1a1a1a; color: white; border: 1px solid var(--gold); }
|
| 112 |
-
|
| 113 |
-
/* μ¬κΆ */
|
| 114 |
.stamp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 20px; }
|
| 115 |
.stamp { height: 90px; border-radius: 15px; border: 2px dashed #333; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: #444; background: #161625; }
|
| 116 |
.stamp.active { border: 2px solid var(--gold); color: var(--gold); background: rgba(212,175,55,0.05); }
|
|
@@ -127,21 +121,17 @@ html_template = """
|
|
| 127 |
<div class="lang-btn" id="btn-CN" onclick="setLanguage('CN', this)">π¨π³</div>
|
| 128 |
</div>
|
| 129 |
</div>
|
| 130 |
-
|
| 131 |
<div style="text-align:center; padding: 5px 0 15px 0;">
|
| 132 |
<div style="color:var(--gold); font-size: 26px; font-weight: 900; letter-spacing: 4px;">DRUNKEN PLANE</div>
|
| 133 |
-
<button onclick="openMap()" style="margin-top:10px; padding:
|
| 134 |
</div>
|
| 135 |
-
|
| 136 |
<center><select id="country-select" style="width:85%; max-width:400px; padding:12px; background:#111; border:1px solid var(--gold); color:white; border-radius:10px;" onchange="selectCountry(this.value)"></select></center>
|
| 137 |
-
|
| 138 |
<div class="type-filter-container" id="filter-box"></div>
|
| 139 |
<div class="place-list-container" id="place-list"></div>
|
| 140 |
<div class="bartender-btn" onclick="openChat()"></div>
|
| 141 |
</div>
|
| 142 |
|
| 143 |
<div id="passport-page" class="page"><div class="nav-bar"><button onclick="closePassport()">β</button> MY PASSPORT</div><div id="stamp-grid" class="stamp-grid" style="overflow-y:auto;"></div></div>
|
| 144 |
-
|
| 145 |
<div id="world-map-page" class="page"><div class="nav-bar"><button onclick="closeMap()">π HOME</button></div><div id="full-map" style="width:100%; height:100%;"></div></div>
|
| 146 |
|
| 147 |
<div id="chat-page" class="page">
|
|
@@ -152,7 +142,7 @@ html_template = """
|
|
| 152 |
<button onclick="sendChat()" style="padding:10px 25px; background:var(--gold); border:none; border-radius:10px; font-weight:bold;">SEND</button>
|
| 153 |
</div>
|
| 154 |
</div>
|
| 155 |
-
|
| 156 |
<div id="detail-page" class="page"><div class="nav-bar"><button onclick="closeDetail()">β</button> Review</div><div id="repo-content" style="padding:20px; white-space:pre-wrap; color:#ddd; line-height:1.7;"></div></div>
|
| 157 |
|
| 158 |
<script>
|
|
@@ -162,20 +152,15 @@ html_template = """
|
|
| 162 |
let visitedPlaces = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
|
| 163 |
|
| 164 |
const TRANSLATIONS = {
|
| 165 |
-
"KO": { "ai": "Korean", "
|
| 166 |
-
"EN": { "ai": "English", "
|
| 167 |
-
"JP": { "ai": "Japanese", "
|
| 168 |
-
"CN": { "ai": "Chinese", "
|
| 169 |
};
|
| 170 |
|
| 171 |
-
// [μ€μ] νκ΅ λ€μ΄λ²λ§΅, ν΄μΈ ꡬκΈλ§΅ λΆκΈ° λ‘μ§
|
| 172 |
function getMapUrl(p, country) {
|
| 173 |
-
if (country.includes("Korea") || country.includes("νκ΅"))
|
| 174 |
-
|
| 175 |
-
return "https://map.naver.com/p/search/" + encodeURIComponent(query);
|
| 176 |
-
} else {
|
| 177 |
-
return "https://www.google.com/maps/search/" + encodeURIComponent(p.name) + "/@" + p.lat + "," + p.lon + ",17z";
|
| 178 |
-
}
|
| 179 |
}
|
| 180 |
|
| 181 |
window.onload = function() {
|
|
@@ -186,61 +171,46 @@ html_template = """
|
|
| 186 |
renderFilters();
|
| 187 |
};
|
| 188 |
|
| 189 |
-
function setLanguage(l, el) {
|
| 190 |
-
currentLang = l;
|
| 191 |
-
document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active'));
|
| 192 |
-
el.classList.add('active');
|
| 193 |
-
renderFilters(); renderList();
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
function renderFilters() {
|
| 197 |
const box = document.getElementById('filter-box'); box.innerHTML = "";
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
btn.innerText = f; btn.onclick = () => { selectedType = t.types[i]; renderFilters(); renderList(); };
|
| 202 |
box.appendChild(btn);
|
| 203 |
});
|
| 204 |
}
|
| 205 |
-
|
| 206 |
function selectCountry(c) { selectedCountry = c; renderList(); }
|
| 207 |
|
| 208 |
function renderList() {
|
| 209 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 210 |
const countryPlaces = PLACE_DB[selectedCountry] || [];
|
| 211 |
const filtered = countryPlaces.filter(p => selectedType === "All" || (p.category && p.category.includes(selectedType)));
|
| 212 |
-
const t = TRANSLATIONS[currentLang];
|
| 213 |
|
| 214 |
filtered.forEach(p => {
|
| 215 |
const card = document.createElement('div'); card.className = 'place-card';
|
| 216 |
-
// Lμ΄
|
| 217 |
const displayLabel = p.label || p.category || "";
|
| 218 |
-
const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_ko || "
|
| 219 |
-
|
| 220 |
card.innerHTML = `
|
| 221 |
-
<div class="pc-header">
|
| 222 |
-
<div class="pc-name">${p.name}</div>
|
| 223 |
-
<div class="pc-label">${displayLabel}</div>
|
| 224 |
-
</div>
|
| 225 |
<div class="pc-desc">${desc}</div>
|
| 226 |
<div style="display:flex; gap:10px; margin-top:15px;">
|
| 227 |
-
<button class="btn-action" style="background:var(--gold); color:black;" onclick="
|
| 228 |
-
<button class="btn-action" style="background:#333; color:white;" onclick="markVisited('${p.name}'); window.open('${getMapUrl(p, selectedCountry)}', '_blank')">${
|
| 229 |
</div>`;
|
| 230 |
list.appendChild(card);
|
| 231 |
});
|
| 232 |
}
|
| 233 |
|
| 234 |
-
// --- μλ°λ¦¬ μλ΄ & μΆμ² λ‘μ§ (μ¬κΈ°κ° ν΅μ¬) ---
|
| 235 |
async function callGroq(msgs) {
|
| 236 |
try {
|
| 237 |
const r = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
| 238 |
-
method: "POST",
|
| 239 |
-
headers: { "Content-Type": "application/json", "Authorization": "Bearer GROQ_KEY" },
|
| 240 |
body: JSON.stringify({ model: "llama-3.3-70b-versatile", messages: msgs, temperature: 0.7 })
|
| 241 |
});
|
| 242 |
const d = await r.json(); return d.choices[0].message.content;
|
| 243 |
-
} catch(e) { return "Emily is busy
|
| 244 |
}
|
| 245 |
|
| 246 |
async function sendChat() {
|
|
@@ -248,24 +218,24 @@ html_template = """
|
|
| 248 |
addChatMessage(msg, 'user'); inp.value = "";
|
| 249 |
chatHistory.push({ role: "user", content: msg });
|
| 250 |
|
| 251 |
-
//
|
| 252 |
-
const sysPrompt = "You are Emily, a bartender. Speak ONLY in " + TRANSLATIONS[currentLang].ai + ". IMPORTANT: If
|
|
|
|
| 253 |
const botMsg = await callGroq([{ role: "system", content: sysPrompt }, ...chatHistory]);
|
| 254 |
|
| 255 |
-
// [
|
| 256 |
-
const match = botMsg.match(/\\[(.*?)\\]/);
|
| 257 |
let finalHtml = botMsg;
|
|
|
|
|
|
|
| 258 |
|
| 259 |
-
|
| 260 |
const pName = match[1];
|
| 261 |
let found = null; let fCountry = "";
|
| 262 |
-
// DBμμ μ₯μ κ²μ
|
| 263 |
for(let c in PLACE_DB) {
|
| 264 |
found = PLACE_DB[c].find(p => p.name.includes(pName));
|
| 265 |
if(found) { fCountry = c; break; }
|
| 266 |
}
|
| 267 |
if(found) {
|
| 268 |
-
// μ§λ λ§ν¬ μμ± (νκ΅μ΄λ©΄ λ€μ΄λ², μλλ©΄ ꡬκΈ)
|
| 269 |
const mapUrl = getMapUrl(found, fCountry);
|
| 270 |
finalHtml += `<br><button class="reco-btn" onclick="markVisited('${found.name}'); window.open('${mapUrl}', '_blank')">π ${TRANSLATIONS[currentLang].mapBtn}: ${pName}</button>`;
|
| 271 |
}
|
|
@@ -282,7 +252,6 @@ html_template = """
|
|
| 282 |
box.appendChild(div); box.scrollTop = box.scrollHeight;
|
| 283 |
}
|
| 284 |
|
| 285 |
-
// --- κΈ°ν κΈ°λ₯ (μ¬κΆ, λ§΅ λ±) ---
|
| 286 |
function markVisited(name) {
|
| 287 |
if(!visitedPlaces.includes(name)) { visitedPlaces.push(name); localStorage.setItem('visitedPlaces', JSON.stringify(visitedPlaces)); }
|
| 288 |
}
|
|
@@ -298,36 +267,19 @@ html_template = """
|
|
| 298 |
});
|
| 299 |
}
|
| 300 |
}
|
| 301 |
-
function
|
| 302 |
|
| 303 |
-
|
| 304 |
-
|
|
|
|
| 305 |
if(!worldMap) {
|
| 306 |
-
worldMap = L.map('full-map').setView([20,
|
| 307 |
-
|
| 308 |
-
for(let c in PLACE_DB) {
|
| 309 |
-
PLACE_DB[c].forEach(p => {
|
| 310 |
-
if(p.lat && p.lon) {
|
| 311 |
-
const mapUrl = getMapUrl(p, c);
|
| 312 |
-
const popupHtml = `<div style="text-align:center;"><b style="color:var(--gold);">${p.name}</b><br><small>${p.label||""}</small><br><button class="popup-btn" onclick="closeMap(); openReview('${p.name.replace(/'/g, "\\\\'")}', '${c}')">π€ REVIEW</button><button class="popup-btn" style="background:#333; color:white;" onclick="markVisited('${p.name}'); window.open('${mapUrl}', '_blank')">π MAP</button></div>`;
|
| 313 |
-
L.marker([p.lat, p.lon]).addTo(worldMap).bindPopup(popupHtml);
|
| 314 |
-
}
|
| 315 |
-
});
|
| 316 |
-
}
|
| 317 |
}
|
| 318 |
-
setTimeout(() => worldMap.invalidateSize(), 400);
|
| 319 |
}
|
| 320 |
-
|
| 321 |
function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }
|
| 322 |
function openChat() { document.getElementById('chat-page').style.transform = 'translateY(0%)'; if(chatHistory.length===0) addChatMessage(TRANSLATIONS[currentLang].greet, 'bot'); }
|
| 323 |
function closeChat() { document.getElementById('chat-page').style.transform = 'translateY(100%)'; }
|
| 324 |
-
|
| 325 |
-
async function openReview(n, c) {
|
| 326 |
-
document.getElementById('detail-page').style.transform = 'translateX(0%)';
|
| 327 |
-
document.getElementById('repo-content').innerText = "Emily is thinking...";
|
| 328 |
-
const res = await callGroq([{ role: "system", content: "Act as Emily. Review " + n + " in " + c + ". Speak " + TRANSLATIONS[currentLang].ai }]);
|
| 329 |
-
document.getElementById('repo-content').innerText = res;
|
| 330 |
-
}
|
| 331 |
function closeDetail() { document.getElementById('detail-page').style.transform = 'translateX(100%)'; }
|
| 332 |
</script>
|
| 333 |
</body>
|
|
|
|
| 32 |
response = requests.get(SHEET_URL)
|
| 33 |
response.encoding = 'utf-8'
|
| 34 |
df = pd.read_csv(io.StringIO(response.text), on_bad_lines='skip')
|
|
|
|
|
|
|
| 35 |
df.columns = df.columns.str.strip()
|
| 36 |
for col in df.select_dtypes(include=['object']).columns:
|
| 37 |
df[col] = df[col].astype(str).str.replace(r'[\r\n\t]+', ' ', regex=True).str.replace('"', '\\"').str.replace("'", "\\'")
|
|
|
|
| 38 |
if 'Country' in df.columns:
|
| 39 |
for country, group in df.groupby('Country'):
|
| 40 |
PLACE_DB[country] = group.fillna("").to_dict(orient='records')
|
|
|
|
| 50 |
db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
|
| 51 |
|
| 52 |
# ==========================================
|
| 53 |
+
# 3. ν΅ν© νλ‘ νΈμλ
|
| 54 |
# ==========================================
|
| 55 |
html_template = """
|
| 56 |
<!DOCTYPE html>
|
|
|
|
| 77 |
.type-btn { padding: 8px 16px; border-radius: 20px; font-size: 11px; font-weight: bold; background: #1a1a1a; color: #777; border: 1px solid #333; white-space: nowrap; cursor: pointer; }
|
| 78 |
.type-btn.selected { background: var(--gold); color: black; border-color: var(--gold); }
|
| 79 |
|
| 80 |
+
/* 리μ€νΈ λ° μΉ΄λ */
|
| 81 |
.place-list-container { flex: 1; overflow-y: auto; padding: 0 20px 120px 20px; }
|
| 82 |
.place-card { background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 20px; margin-bottom: 15px; position: relative; }
|
| 83 |
.pc-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
|
|
|
| 86 |
.pc-desc { font-size: 13.5px; color: #aaa; line-height: 1.6; margin: 12px 0; }
|
| 87 |
.btn-action { flex: 1; padding: 12px; border-radius: 10px; border: none; font-weight: bold; cursor: pointer; font-size: 12px; }
|
| 88 |
|
| 89 |
+
/* λ°ν
λ λ²νΌ */
|
| 90 |
.bartender-btn { position: fixed; bottom: 30%; right: 20px; width: 85px; height: 85px; border-radius: 50%; background-image: url('IMAGE_DATA'); background-size: cover; border: 3px solid var(--gold); z-index: 999; box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); cursor: pointer; }
|
| 91 |
|
| 92 |
/* νμ΄μ§ μ ν */
|
| 93 |
#world-map-page, #passport-page, #chat-page { background: #000; z-index: 2000; transform: translateY(100%); }
|
| 94 |
#passport-page { transform: translateX(-100%); background: #0f0f1b; }
|
| 95 |
#detail-page { background: #0a0a0a; z-index: 4000; transform: translateX(100%); }
|
|
|
|
| 96 |
|
| 97 |
+
.nav-bar { height: 60px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #222; background: #111; }
|
| 98 |
.msg { max-width: 85%; padding: 12px 18px; border-radius: 15px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
|
| 99 |
.msg.bot { align-self: flex-start; background: #222; color: #eee; border: 1px solid #333; }
|
| 100 |
.msg.user { align-self: flex-end; background: var(--gold); color: black; font-weight: bold; }
|
| 101 |
+
|
| 102 |
+
/* μΆμ² λ§ν¬ λ²νΌ */
|
| 103 |
+
.reco-btn { display: block; margin-top: 8px; padding: 10px; background: var(--gold); color: black !important; border-radius: 10px; font-weight: bold; text-decoration: none; font-size: 12px; cursor: pointer; border:none; width: 100%; text-align: center; }
|
| 104 |
|
| 105 |
+
/* νμ
λ± */
|
|
|
|
|
|
|
|
|
|
| 106 |
.popup-btn { background: var(--gold); color: black; border: none; padding: 5px 10px; border-radius: 5px; font-weight: bold; font-size: 11px; cursor: pointer; margin-top: 5px; width: 100%; }
|
| 107 |
.leaflet-popup-content-wrapper { background: #1a1a1a; color: white; border: 1px solid var(--gold); }
|
|
|
|
|
|
|
| 108 |
.stamp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 20px; }
|
| 109 |
.stamp { height: 90px; border-radius: 15px; border: 2px dashed #333; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: #444; background: #161625; }
|
| 110 |
.stamp.active { border: 2px solid var(--gold); color: var(--gold); background: rgba(212,175,55,0.05); }
|
|
|
|
| 121 |
<div class="lang-btn" id="btn-CN" onclick="setLanguage('CN', this)">π¨π³</div>
|
| 122 |
</div>
|
| 123 |
</div>
|
|
|
|
| 124 |
<div style="text-align:center; padding: 5px 0 15px 0;">
|
| 125 |
<div style="color:var(--gold); font-size: 26px; font-weight: 900; letter-spacing: 4px;">DRUNKEN PLANE</div>
|
| 126 |
+
<button onclick="openMap()" style="margin-top:10px; padding:10px 25px; background:var(--gold); border:none; border-radius:30px; font-weight:bold; cursor:pointer;">πΊοΈ EXPLORE WORLD MAP</button>
|
| 127 |
</div>
|
|
|
|
| 128 |
<center><select id="country-select" style="width:85%; max-width:400px; padding:12px; background:#111; border:1px solid var(--gold); color:white; border-radius:10px;" onchange="selectCountry(this.value)"></select></center>
|
|
|
|
| 129 |
<div class="type-filter-container" id="filter-box"></div>
|
| 130 |
<div class="place-list-container" id="place-list"></div>
|
| 131 |
<div class="bartender-btn" onclick="openChat()"></div>
|
| 132 |
</div>
|
| 133 |
|
| 134 |
<div id="passport-page" class="page"><div class="nav-bar"><button onclick="closePassport()">β</button> MY PASSPORT</div><div id="stamp-grid" class="stamp-grid" style="overflow-y:auto;"></div></div>
|
|
|
|
| 135 |
<div id="world-map-page" class="page"><div class="nav-bar"><button onclick="closeMap()">π HOME</button></div><div id="full-map" style="width:100%; height:100%;"></div></div>
|
| 136 |
|
| 137 |
<div id="chat-page" class="page">
|
|
|
|
| 142 |
<button onclick="sendChat()" style="padding:10px 25px; background:var(--gold); border:none; border-radius:10px; font-weight:bold;">SEND</button>
|
| 143 |
</div>
|
| 144 |
</div>
|
| 145 |
+
|
| 146 |
<div id="detail-page" class="page"><div class="nav-bar"><button onclick="closeDetail()">β</button> Review</div><div id="repo-content" style="padding:20px; white-space:pre-wrap; color:#ddd; line-height:1.7;"></div></div>
|
| 147 |
|
| 148 |
<script>
|
|
|
|
| 152 |
let visitedPlaces = JSON.parse(localStorage.getItem('visitedPlaces') || '[]');
|
| 153 |
|
| 154 |
const TRANSLATIONS = {
|
| 155 |
+
"KO": { "ai": "Korean", "aiBtn": "AI 리뷰", "mapBtn": "μ§λ", "filters": ["π μ 체", "πΊ μ ν΅μ£Ό", "π₯ μμ€ν€", "πΊ λ§₯μ£Ό", "π· μμΈ", "πΉ λ°"], "types": ["All", "Traditional", "Whiskey", "Beer", "Wine", "Bar"] },
|
| 156 |
+
"EN": { "ai": "English", "aiBtn": "AI REVIEW", "mapBtn": "MAP", "filters": ["π All", "πΊ Trad.", "π₯ Whiskey", "πΊ Beer", "π· Wine", "πΉ Bar"], "types": ["All", "Traditional", "Whiskey", "Beer", "Wine", "Bar"] },
|
| 157 |
+
"JP": { "ai": "Japanese", "aiBtn": "AI γ¬γγ₯γΌ", "mapBtn": "ε°ε³", "filters": ["π ε
¨ι¨", "πΊ δΌη΅±ι
", "π₯ γ¦γ€γΉγγΌ", "πΊ γγΌγ«", "π· γ―γ€γ³", "πΉ γγΌ"], "types": ["All", "Traditional", "Whiskey", "Beer", "Wine", "Bar"] },
|
| 158 |
+
"CN": { "ai": "Chinese", "aiBtn": "AI ηΉθ―", "mapBtn": "ε°εΎ", "filters": ["π ε
¨ι¨", "πΊ δΌ η»ι
", "π₯ ε¨ε£«εΏ", "πΊ ε€ι
", "π· θ‘θι
", "πΉ ι
ε§"], "types": ["All", "Traditional", "Whiskey", "Beer", "Wine", "Bar"] }
|
| 159 |
};
|
| 160 |
|
|
|
|
| 161 |
function getMapUrl(p, country) {
|
| 162 |
+
if (country.includes("Korea") || country.includes("νκ΅")) return "https://map.naver.com/p/search/" + encodeURIComponent(p.address || p.name);
|
| 163 |
+
return "https://www.google.com/maps/search/" + encodeURIComponent(p.name) + "/@" + p.lat + "," + p.lon + ",17z";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
window.onload = function() {
|
|
|
|
| 171 |
renderFilters();
|
| 172 |
};
|
| 173 |
|
| 174 |
+
function setLanguage(l, el) { currentLang = l; document.querySelectorAll('.lang-btn').forEach(b => b.classList.remove('active')); el.classList.add('active'); renderFilters(); renderList(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
function renderFilters() {
|
| 176 |
const box = document.getElementById('filter-box'); box.innerHTML = "";
|
| 177 |
+
TRANSLATIONS[currentLang].filters.forEach((f, i) => {
|
| 178 |
+
const btn = document.createElement('div'); btn.className = 'type-btn' + (selectedType === TRANSLATIONS[currentLang].types[i] ? ' selected' : '');
|
| 179 |
+
btn.innerText = f; btn.onclick = () => { selectedType = TRANSLATIONS[currentLang].types[i]; renderFilters(); renderList(); };
|
|
|
|
| 180 |
box.appendChild(btn);
|
| 181 |
});
|
| 182 |
}
|
|
|
|
| 183 |
function selectCountry(c) { selectedCountry = c; renderList(); }
|
| 184 |
|
| 185 |
function renderList() {
|
| 186 |
const list = document.getElementById('place-list'); list.innerHTML = "";
|
| 187 |
const countryPlaces = PLACE_DB[selectedCountry] || [];
|
| 188 |
const filtered = countryPlaces.filter(p => selectedType === "All" || (p.category && p.category.includes(selectedType)));
|
|
|
|
| 189 |
|
| 190 |
filtered.forEach(p => {
|
| 191 |
const card = document.createElement('div'); card.className = 'place-card';
|
| 192 |
+
// Lμ΄ λΌλ²¨ μ¬μ©
|
| 193 |
const displayLabel = p.label || p.category || "";
|
| 194 |
+
const desc = p['desc_'+currentLang.toLowerCase()] || p.desc_ko || "";
|
|
|
|
| 195 |
card.innerHTML = `
|
| 196 |
+
<div class="pc-header"><div class="pc-name">${p.name}</div><div class="pc-label">${displayLabel}</div></div>
|
|
|
|
|
|
|
|
|
|
| 197 |
<div class="pc-desc">${desc}</div>
|
| 198 |
<div style="display:flex; gap:10px; margin-top:15px;">
|
| 199 |
+
<button class="btn-action" style="background:var(--gold); color:black;" onclick="openReview('${p.name.replace(/'/g, "\\\\'")}', '${selectedCountry}')">${TRANSLATIONS[currentLang].aiBtn}</button>
|
| 200 |
+
<button class="btn-action" style="background:#333; color:white;" onclick="markVisited('${p.name}'); window.open('${getMapUrl(p, selectedCountry)}', '_blank')">${TRANSLATIONS[currentLang].mapBtn}</button>
|
| 201 |
</div>`;
|
| 202 |
list.appendChild(card);
|
| 203 |
});
|
| 204 |
}
|
| 205 |
|
|
|
|
| 206 |
async function callGroq(msgs) {
|
| 207 |
try {
|
| 208 |
const r = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
| 209 |
+
method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer GROQ_KEY" },
|
|
|
|
| 210 |
body: JSON.stringify({ model: "llama-3.3-70b-versatile", messages: msgs, temperature: 0.7 })
|
| 211 |
});
|
| 212 |
const d = await r.json(); return d.choices[0].message.content;
|
| 213 |
+
} catch(e) { return "Emily is busy."; }
|
| 214 |
}
|
| 215 |
|
| 216 |
async function sendChat() {
|
|
|
|
| 218 |
addChatMessage(msg, 'user'); inp.value = "";
|
| 219 |
chatHistory.push({ role: "user", content: msg });
|
| 220 |
|
| 221 |
+
// [μ€μ] μλ°λ¦¬μκ² λκ΄νΈ μ¬μ©μ 'μΈλ'μν€λ ν둬ννΈ
|
| 222 |
+
const sysPrompt = "You are Emily, a bartender. Speak ONLY in " + TRANSLATIONS[currentLang].ai + ". IMPORTANT: If you recommend a place from the list, you MUST write the EXACT name inside square brackets like [Place Name]. Do not bold it, just brackets. Example: You should try [Zest].";
|
| 223 |
+
|
| 224 |
const botMsg = await callGroq([{ role: "system", content: sysPrompt }, ...chatHistory]);
|
| 225 |
|
| 226 |
+
// [μ€μ] λ€μ€ μΆμ² κ°μ§ λ° λ²νΌ μμ±
|
|
|
|
| 227 |
let finalHtml = botMsg;
|
| 228 |
+
const regex = /\\[(.*?)\\]/g;
|
| 229 |
+
let match;
|
| 230 |
|
| 231 |
+
while ((match = regex.exec(botMsg)) !== null) {
|
| 232 |
const pName = match[1];
|
| 233 |
let found = null; let fCountry = "";
|
|
|
|
| 234 |
for(let c in PLACE_DB) {
|
| 235 |
found = PLACE_DB[c].find(p => p.name.includes(pName));
|
| 236 |
if(found) { fCountry = c; break; }
|
| 237 |
}
|
| 238 |
if(found) {
|
|
|
|
| 239 |
const mapUrl = getMapUrl(found, fCountry);
|
| 240 |
finalHtml += `<br><button class="reco-btn" onclick="markVisited('${found.name}'); window.open('${mapUrl}', '_blank')">π ${TRANSLATIONS[currentLang].mapBtn}: ${pName}</button>`;
|
| 241 |
}
|
|
|
|
| 252 |
box.appendChild(div); box.scrollTop = box.scrollHeight;
|
| 253 |
}
|
| 254 |
|
|
|
|
| 255 |
function markVisited(name) {
|
| 256 |
if(!visitedPlaces.includes(name)) { visitedPlaces.push(name); localStorage.setItem('visitedPlaces', JSON.stringify(visitedPlaces)); }
|
| 257 |
}
|
|
|
|
| 267 |
});
|
| 268 |
}
|
| 269 |
}
|
| 270 |
+
function openReview(n, c) { document.getElementById('detail-page').style.transform = 'translateX(0%)'; document.getElementById('repo-content').innerText = "Loading..."; callGroq([{role:"system",content:"Review "+n+" in "+c+" in "+TRANSLATIONS[currentLang].ai}]).then(res => document.getElementById('repo-content').innerText = res); }
|
| 271 |
|
| 272 |
+
// UI μ μ΄ ν¨μ
|
| 273 |
+
function closePassport() { document.getElementById('passport-page').style.transform = 'translateX(-100%)'; }
|
| 274 |
+
function openMap() { document.getElementById('world-map-page').style.transform = 'translateY(0%)';
|
| 275 |
if(!worldMap) {
|
| 276 |
+
worldMap = L.map('full-map').setView([20,0],2); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(worldMap);
|
| 277 |
+
for(let c in PLACE_DB) PLACE_DB[c].forEach(p => { if(p.lat && p.lon) L.marker([p.lat,p.lon]).addTo(worldMap).bindPopup(`<b>${p.name}</b><br><button class='popup-btn' onclick='window.open("${getMapUrl(p,c)}","_blank")'>MAP</button>`); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
}
|
|
|
|
| 279 |
}
|
|
|
|
| 280 |
function closeMap() { document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }
|
| 281 |
function openChat() { document.getElementById('chat-page').style.transform = 'translateY(0%)'; if(chatHistory.length===0) addChatMessage(TRANSLATIONS[currentLang].greet, 'bot'); }
|
| 282 |
function closeChat() { document.getElementById('chat-page').style.transform = 'translateY(100%)'; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
function closeDetail() { document.getElementById('detail-page').style.transform = 'translateX(100%)'; }
|
| 284 |
</script>
|
| 285 |
</body>
|