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>