Spaces:
Running
Running
File size: 7,390 Bytes
7c6c45d 7635790 7c6c45d |
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 |
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MBTI μ±κ²© μ ν ν
μ€νΈ</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<!-- μ§λ¬Έ μΉμ
-->
<div id="quiz-section">
<h1>MBTI μ±κ²© μ ν ν
μ€νΈ</h1>
<p>λ€μ μ§λ¬Έλ€μ λ΅ν΄μ£ΌμΈμ.</p>
<div id="question-container"></div>
<button id="next-button">λ€μ</button>
</div>
<!-- κ²°κ³Ό μΉμ
-->
<div id="result-section" class="hidden">
<h1>MBTI κ²°κ³Ό</h1>
<pre id="result-text"></pre>
<img id="result-image" src="" alt="μ ν μ΄λ―Έμ§">
<button id="restart-button">λ€μ ν
μ€νΈνκΈ°</button>
</div>
</div>
<script>
// μ§λ¬Έ 리μ€νΈ λ° MBTI λ°μ΄ν°
const questions = [
"λΉμ μ νΌμ μμ λ μλμ§λ₯Ό μ»λμ?",
"λΉμ μ κ³νμ μΈμ°λ κ²μ μ’μνλμ?",
"λΉμ μ μλ‘μ΄ μν©μ μ½κ² μ μνλμ?",
"λΉμ μ κ°μ 보λ€λ λ
Όλ¦¬μ λ μμ‘΄νλμ?",
"λΉμ μ λ€λ₯Έ μ¬λμ λλ κ²μ μ’μνλμ?",
"λΉμ μ μ¬κ΅μ μΈ μ±κ²©μ κ°μ§κ³ μλμ?",
"λΉμ μ μΌμ λλ΄κΈ° μ μ κ³νμ μΈμ°λ νΈμΈκ°μ?",
"λΉμ μ μ¬μ€κ³Ό λ°μ΄ν°λ₯Ό μ€μνλμ?",
"λΉμ μ κ°μ ννμ μ νλμ?",
"λΉμ μ λ¬Έμ λ₯Ό ν΄κ²°ν λ μ°½μμ μΈ λ°©λ²μ μ¬μ©νλμ?",
"λΉμ μ λ€λ₯Έ μ¬λλ€κ³Όμ νμ
μ μ νΈνλμ?",
"λΉμ μ κ²°μ μ λ΄λ¦΄ λ μ§κ°μ μ λ’°νλμ?",
"λΉμ μ κ·μΉκ³Ό μ μ°¨λ₯Ό λ°λ₯΄λ κ²μ μ’μνλμ?",
"λΉμ μ μ£Όλ³ νκ²½μ λ―Όκ°νκ² λ°μνλμ?",
"λΉμ μ μΌμ μ²λ¦¬ν λ ν¨μ¨μ±μ μ€μνλμ?",
"λΉμ μ λ¨λ€μ΄ μκ°νλ κ²μ λν΄ λ§μ΄ μ κ²½ μ°λμ?",
"λΉμ μ μμ°μ€λ½κ² 리λ μν μ λ§‘κ² λλμ?",
"λΉμ μ μλ‘μ΄ μμ΄λμ΄λ₯Ό μ μνλ κ²μ μ’μνλμ?",
"λΉμ μ λμΈ κ΄κ³μμ κ°λ±μ νΌνλ € νλμ?",
"λΉμ μ λͺ©νλ₯Ό μ€μ νκ³ μ΄λ₯Ό λ¬μ±νκΈ° μν΄ λ
Έλ ₯νλμ?"
];
const mbti_types = {
"INTJ": {
"μ±κ²©": "λ
μ°½μ μ΄κ³ μ λ΅μ μΈ μ¬κ³ λ₯Ό κ°μ§ μ‘°μ©ν 리λ",
"μ§μ
": "κ³Όνμ, μμ§λμ΄, λ°μ΄ν° λΆμκ°",
"κΆν©": ["ENFP", "ENTP"],
"λμ κΆν©": ["ESFP", "ESTP"],
"κΆν© μ€λͺ
": {
"ENFP": "ENFPλ INTJμ μ΄μμ£Όμλ₯Ό μκ·Ήνκ³ , μλ‘μ κ°μ κ³Ό μ½μ μ 보μν©λλ€.",
"ENTP": "ENTPλ INTJμ μ°½μμ±κ³Ό μ λ΅μ μ¬κ³ λ₯Ό μκ·Ήνμ¬ μμ°μ μΈ ννΈλμμ νμ±ν©λλ€."
},
"λμ κΆν© μ€λͺ
": {
"ESFP": "ESFPλ INTJμ μ λ°λμ μ±ν₯μ κ°μ§κ³ μμ΄ κ°λ±μ΄ μ¦μ μ μμ΅λλ€.",
"ESTP": "ESTPλ μ€μ©μ μΈ μ κ·Όμ μ νΈνλ λ°λ©΄, INTJλ μ₯κΈ°μ μΈ κ³νμ μ€μν©λλ€."
}
},
/* λ€λ₯Έ MBTI μ ν λ°μ΄ν° μλ΅: λμΌν κ΅¬μ‘°λ‘ μΆκ° */
};
// μλ΅ μ μ₯ λ°°μ΄
let responses = [];
let currentQuestionIndex = 0;
const questionsPerPage = 5;
const questionContainer = document.getElementById('question-container');
const nextButton = document.getElementById('next-button');
const resultSection = document.getElementById('result-section');
const quizSection = document.getElementById('quiz-section');
const resultText = document.getElementById('result-text');
const resultImage = document.getElementById('result-image');
const restartButton = document.getElementById('restart-button');
// λΌλμ€ λ²νΌ μ΅μ
const options = ["λ§€μ° κ·Έλ λ€", "κ·Έλ λ€", "보ν΅μ΄λ€", "μλλ€", "λ§€μ° μλλ€"];
function loadQuestions() {
questionContainer.innerHTML = '';
const end = Math.min(currentQuestionIndex + questionsPerPage, questions.length);
for(let i = currentQuestionIndex; i < end; i++) {
const qDiv = document.createElement('div');
qDiv.className = 'question-block';
const qText = document.createElement('p');
qText.textContent = questions[i];
qDiv.appendChild(qText);
options.forEach(option => {
const label = document.createElement('label');
const radio = document.createElement('input');
radio.type = 'radio';
radio.name = 'question' + i;
radio.value = option;
label.appendChild(radio);
label.appendChild(document.createTextNode(option));
qDiv.appendChild(label);
});
questionContainer.appendChild(qDiv);
}
}
function collectResponses() {
const end = Math.min(currentQuestionIndex + questionsPerPage, questions.length);
for(let i = currentQuestionIndex; i < end; i++) {
const radios = document.getElementsByName('question' + i);
let answered = false;
radios.forEach(radio => {
if(radio.checked) {
responses[i] = radio.value;
answered = true;
}
});
if(!answered) {
responses[i] = "보ν΅μ΄λ€"; // λ―Έμλ΅ μ κΈ°λ³Έκ° μ€μ
}
}
}
// MBTI κ²°κ³Ό κ³μ° (λ¨μνλ λ²μ )
function calculate_mbti_responses(responses) {
// λ³Έ μμ μμλ λ¨μνλ₯Ό μν΄ λ¬΄μμλ‘ MBTI μ ν μ ν
const types = Object.keys(mbti_types);
const randomIndex = Math.floor(Math.random() * types.length);
const best_match_type = types[randomIndex];
const percentage = 75 + Math.random() * 25;
return { type: best_match_type, percentage: percentage.toFixed(2) };
}
function displayResult() {
const result = calculate_mbti_responses(responses);
const details = mbti_types[result.type];
let output = `λΉμ μ MBTI μ νμ ${result.type}μ
λλ€. μ λ’°λ: ${result.percentage}%\n\n`;
output += `μ±κ²© μ€λͺ
: ${details.μ±κ²©}\nμΆμ² μ§μ
: ${details.μ§μ
}\n\nμ’μ κΆν©:\n`;
details.κΆν©.forEach(match => {
output += `- ${match}: ${details["κΆν© μ€λͺ
"][match]}\n`;
});
output += `\nλμ κΆν©:\n`;
details["λμ κΆν©"].forEach(match => {
output += `- ${match}: ${details["λμ κΆν© μ€λͺ
"][match]}\n`;
});
resultText.textContent = output;
resultImage.src = `./${result.type}.webp`; // μ΄λ―Έμ§ κ²½λ‘ μ€μ
}
nextButton.addEventListener('click', () => {
collectResponses();
currentQuestionIndex += questionsPerPage;
if(currentQuestionIndex < questions.length) {
loadQuestions();
} else {
// λͺ¨λ μ§λ¬Έ μλ£ ν κ²°κ³Ό νμ΄μ§λ‘ μ΄λ
quizSection.classList.add('hidden');
displayResult();
resultSection.classList.remove('hidden');
}
});
restartButton.addEventListener('click', () => {
// μ΄κΈ°ν ν ν
μ€νΈ μ¬μμ
responses = [];
currentQuestionIndex = 0;
loadQuestions();
resultSection.classList.add('hidden');
quizSection.classList.remove('hidden');
});
// μ΄κΈ° μ§λ¬Έ λ‘λ
loadQuestions();
</script>
</body>
</html>
|