Spaces:
Running
Running
File size: 10,505 Bytes
c8d0139 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
<!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> |