Spaces:
Running
Running
<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> |