travel / index.html
kimhyunwoo's picture
Update index.html
c8d0139 verified
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>λ‚˜μ—κ²Œ μ–΄μšΈλ¦¬λŠ” μ—¬ν–‰μ§€ μ°ΎκΈ° ✈️</title>
<style>
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
background-color: #f4f4f4;
color: #333;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.quiz-container {
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
max-width: 600px;
width: 100%;
text-align: center;
}
h1 {
color: #0056b3;
margin-bottom: 20px;
}
.question-container {
margin-bottom: 20px;
}
.question-container p {
font-size: 1.2em;
margin-bottom: 15px;
font-weight: bold;
}
.options button {
display: block;
width: 100%;
padding: 12px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #eee;
font-size: 1em;
cursor: pointer;
transition: background-color 0.3s ease;
}
.options button:hover {
background-color: #ddd;
}
.options button:active {
background-color: #ccc;
}
.result-container {
display: none; /* μ΄ˆκΈ°μ—λŠ” μˆ¨κΉ€ */
text-align: center;
}
.result-container h2 {
color: #28a745;
margin-bottom: 15px;
}
.result-container p {
font-size: 1.1em;
margin-bottom: 20px;
}
.result-container a {
display: inline-block;
background-color: #ff5722; /* 쿠팑 μ˜€λ Œμ§€μƒ‰ λŠλ‚Œ */
color: white;
padding: 12px 25px;
border-radius: 5px;
text-decoration: none;
font-size: 1.1em;
transition: background-color 0.3s ease;
}
.result-container a:hover {
background-color: #e64a19;
}
/* 질문 숨기기/보이기 μ• λ‹ˆλ©”μ΄μ…˜ */
.question-container.hidden {
display: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.question-container.visible {
display: block;
opacity: 1;
transition: opacity 0.5s ease;
}
</style>
</head>
<body>
<div class="quiz-container">
<h1>λ‚˜μ—κ²Œ μ–΄μšΈλ¦¬λŠ” μ—¬ν–‰μ§€ μ°ΎκΈ° ✈️</h1>
<div id="intro" class="question-container visible">
<p>λͺ‡ κ°€μ§€ μ§ˆλ¬Έμ— λ‹΅ν•˜κ³  λ‹Ήμ‹ μ—κ²Œ λ”± λ§žλŠ” μ—¬ν–‰μ§€λ₯Ό μ°Ύμ•„λ³΄μ„Έμš”!</p>
<div class="options">
<button onclick="startQuiz()">ν€΄μ¦ˆ μ‹œμž‘ν•˜κΈ°</button>
</div>
</div>
<div id="question1" class="question-container hidden">
<p>1. μ–΄λ–€ μ’…λ₯˜μ˜ 여행을 κ°€μž₯ μ’‹μ•„ν•˜μ‹œλ‚˜μš”?</p>
<div class="options">
<button onclick="answerQuestion(1, 'relax')">ν‘Ή μ‰¬λŠ” νœ΄μ–‘ μ—¬ν–‰ πŸ–οΈ</button>
<button onclick="answerQuestion(1, 'activity')">μ‹ λ‚˜λŠ” μ•‘ν‹°λΉ„ν‹° μ—¬ν–‰ πŸ§—β€β™€οΈ</button>
<button onclick="answerQuestion(1, 'culture')">λ‹€μ–‘ν•œ λ¬Έν™”λ₯Ό κ²½ν—˜ν•˜λŠ” μ—¬ν–‰ πŸ›οΈ</button>
</div>
</div>
<div id="question2" class="question-container hidden">
<p>2. μ—¬ν–‰μ§€μ—μ„œ κ°€μž₯ μ€‘μš”ν•˜κ²Œ μƒκ°ν•˜λŠ” 것은?</p>
<div class="options">
<button onclick="answerQuestion(2, 'nature')">μ•„λ¦„λ‹€μš΄ μžμ—° κ²½κ΄€ 🏞️</button>
<button onclick="answerQuestion(2, 'food')">λ§›μžˆλŠ” ν˜„μ§€ μŒμ‹ 🍲</button>
<button onclick="answerQuestion(2, 'shopping')">λ‹€μ–‘ν•œ μ‡Όν•‘ 기회 πŸ›οΈ</button>
</div>
</div>
<div id="question3" class="question-container hidden">
<p>3. μ—¬ν–‰ μ˜ˆμ‚°μ€ μ–΄λŠ 정도 μƒκ°ν•˜μ‹œλ‚˜μš”?</p>
<div class="options">
<button onclick="answerQuestion(3, 'low')">μ €λ ΄ν•˜κ²Œ μ¦κΈ°λŠ” μ—¬ν–‰ πŸ’°</button>
<button onclick="answerQuestion(3, 'medium')">μ λ‹Ήνžˆ νˆ¬μžν•˜λŠ” μ—¬ν–‰ πŸ˜‰</button>
<button onclick="answerQuestion(3, 'high')">μ˜ˆμ‚° 상관없이 μ¦κΈ°λŠ” μ—¬ν–‰ λŸ­μ…”λ¦¬ν•˜κ²Œ ✨</button>
</div>
</div>
<div id="question4" class="question-container hidden">
<p>4. λˆ„κ΅¬μ™€ ν•¨κ»˜ μ—¬ν–‰ν•˜λŠ” 것을 μ„ ν˜Έν•˜μ‹œλ‚˜μš”?</p>
<div class="options">
<button onclick="answerQuestion(4, 'alone')">혼자만의 μ‹œκ°„ 즐기기 🚢</button>
<button onclick="answerQuestion(4, 'friends')">친ꡬ λ˜λŠ” 연인과 ν•¨κ»˜ πŸ‘«</button>
<button onclick="answerQuestion(4, 'family')">κ°€μ‘±κ³Ό μ†Œμ€‘ν•œ μΆ”μ–΅ λ§Œλ“€κΈ° πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦</button>
</div>
</div>
<div id="result" class="result-container">
<h2>λ‹Ήμ‹ μ—κ²Œ μ–΄μšΈλ¦¬λŠ” μ—¬ν–‰μ§€λŠ”...</h2>
<p id="result-text"></p>
<a id="coupang-link" href="#" target="_blank">μΏ νŒ‘μ—μ„œ κ΄€λ ¨ μ—¬ν–‰ μƒν’ˆ 찾아보기 ✈️</a>
</div>
</div>
<script>
let currentQuestion = 0;
const questions = ['intro', 'question1', 'question2', 'question3', 'question4']; // 질문 ID λͺ©λ‘
const answers = {}; // μ‚¬μš©μžμ˜ 닡변을 μ €μž₯ν•  객체
function startQuiz() {
document.getElementById('intro').classList.remove('visible');
document.getElementById('intro').classList.add('hidden');
currentQuestion++;
showQuestion(currentQuestion);
}
function showQuestion(index) {
if (index > questions.length - 1) {
showResult();
return;
}
// 이전 질문 숨기기 (λ§Œμ•½ μžˆλ‹€λ©΄)
if (currentQuestion > 0) {
const prevQuestionId = questions[currentQuestion - 1];
const prevQuestionElement = document.getElementById(prevQuestionId);
if (prevQuestionElement) {
prevQuestionElement.classList.remove('visible');
prevQuestionElement.classList.add('hidden');
}
}
const currentQuestionId = questions[index];
const currentQuestionElement = document.getElementById(currentQuestionId);
if (currentQuestionElement) {
currentQuestionElement.classList.remove('hidden');
currentQuestionElement.classList.add('visible');
}
}
function answerQuestion(questionNumber, answer) {
answers[questionNumber] = answer; // λ‹΅λ³€ μ €μž₯
currentQuestion++;
showQuestion(currentQuestion); // λ‹€μŒ 질문으둜 이동
}
function showResult() {
// λͺ¨λ“  μ§ˆλ¬Έμ„ μˆ¨κΉλ‹ˆλ‹€.
questions.forEach(id => {
const element = document.getElementById(id);
if (element) {
element.classList.remove('visible');
element.classList.add('hidden');
}
});
const resultElement = document.getElementById('result');
const resultTextElement = document.getElementById('result-text');
const coupangLinkElement = document.getElementById('coupang-link');
let result = "";
let coupangLink = "#"; // κΈ°λ³Έ 쿠팑 링크 (λ‚˜μ€‘μ— μ‹€μ œ 링크둜 λ³€κ²½ ν•„μš”)
// κ°„λ‹¨ν•œ 둜직으둜 κ²°κ³Ό κ²°μ • (각 λ‹΅λ³€μ˜ 쑰합에 따라 λ‹€λ₯Έ κ²°κ³Ό λ„μΆœ)
// 이 뢀뢄은 더 λ³΅μž‘ν•œ 둜직으둜 λ°œμ „μ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€.
if (answers[1] === 'relax' && answers[2] === 'nature') {
result = "μ•„λ¦„λ‹€μš΄ ν•΄λ³€κ°€ νœ΄μ–‘μ§€ πŸ–οΈ";
coupangLink = "https://www.coupang.com/np/search?q=%ED%95%B4%EB%B3%80%EA%B0%80+%ED%9C%B4%EC%96%91&channel=user&component=list_vertical&source=user_component"; // 쿠팑 ν•΄λ³€κ°€ νœ΄μ–‘ 검색 링크 (μ˜ˆμ‹œ)
} else if (answers[1] === 'activity' && answers[3] === 'medium') {
result = "μ‹ λ‚˜λŠ” μ•‘ν‹°λΉ„ν‹° λ„μ‹œ μ—¬ν–‰ πŸ™οΈ";
coupangLink = "https://www.coupang.com/np/search?q=%EB%8F%84%EC%8B%9C+%EC%97%AC%ED%96%89+%EC%95%A1%ED%8B%B0%EB%B9%84%ED%8B%B0&channel=user&component=list_vertical&source=user_component"; // 쿠팑 λ„μ‹œ μ—¬ν–‰ μ•‘ν‹°λΉ„ν‹° 검색 링크 (μ˜ˆμ‹œ)
} else if (answers[1] === 'culture' && answers[4] === 'alone') {
result = "역사와 λ¬Έν™”κ°€ μ‚΄μ•„ μˆ¨μ‰¬λŠ” κ³³ πŸ›οΈ";
coupangLink = "https://www.coupang.com/np/search?q=%EB%AC%B8%ED%99%94+%EC%97%AC%ED%96%89&channel=user&component=list_vertical&source=user_component"; // 쿠팑 λ¬Έν™” μ—¬ν–‰ 검색 링크 (μ˜ˆμ‹œ)
} else if (answers[3] === 'low' && answers[4] === 'friends') {
result = "μ €λ ΄ν•˜κ²Œ μ¦κΈ°λŠ” λ°°λ‚­μ—¬ν–‰ λͺ…μ†Œ πŸŽ’";
coupangLink = "https://www.coupang.com/np/search?q=%EB%B0%B0%EB%82%AD%EC%97%AC%ED%96%85+%EB%AA%85%EC%86%8C&channel=user&component=list_vertical&source=user_component"; // 쿠팑 λ°°λ‚­μ—¬ν–‰ λͺ…μ†Œ 검색 링크 (μ˜ˆμ‹œ)
}
// 더 λ‹€μ–‘ν•œ κ²°κ³Ό 쑰합을 μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
else {
result = "λ‹Ήμ‹ μ—κ²ŒλŠ” λ‹€μ±„λ‘œμš΄ κ²½ν—˜μ΄ κ°€λ“ν•œ 여행이 μ–΄μšΈλ¦½λ‹ˆλ‹€! 🌍";
coupangLink = "https://www.coupang.com/np/search?q=%ED%95%B4%EC%99%B8%EC%97%AC%ED%96%85&channel=user&component=list_vertical&source=user_component"; // 쿠팑 ν•΄μ™Έμ—¬ν–‰ μΉ΄ν…Œκ³ λ¦¬ 링크 (μ˜ˆμ‹œ)
}
resultTextElement.innerText = result;
coupangLinkElement.href = coupangLink; // 쿠팑 링크 μ„€μ •
resultElement.style.display = 'block'; // κ²°κ³Ό μ»¨ν…Œμ΄λ„ˆ ν‘œμ‹œ
}
</script>
</body>
</html>