-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
230 lines (202 loc) · 7.31 KB
/
index.html
File metadata and controls
230 lines (202 loc) · 7.31 KB
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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MBTI 선택하고 게임 추천받기</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<main>
<header>
<h1>MBTI 선택하고 게임 추천받기</h1>
<p>4가지 지표를 선택해 나에게 딱 맞는 게임 추천을 받아보세요.</p>
</header>
<div id="selection-display" aria-live="polite">
<span id="mbti-core">_ _ _ _</span>
</div>
<div class="step-indicator" id="step-indicator" aria-hidden="true"></div>
<section id="question">
<h2 id="question-title"></h2>
<p id="question-description"></p>
</section>
<div class="choice-buttons">
<button class="choice-button" id="choice-left"></button>
<button class="choice-button" id="choice-right"></button>
</div>
<p id="description"></p>
<div class="navigation">
<button type="button" id="next-button" disabled>다음</button>
</div>
<div class="reset-area">
<button type="button" id="reset-button">처음으로 돌아가기</button>
</div>
</main>
<script>
const dichotomies = [
{
code: 'EI',
title: '외향과 내향 (E vs I)',
description: '새로운 사람들과의 만남에서 에너지를 얻나요, 아니면 혼자 있는 시간이 더 편안한가요?',
options: [
{
value: 'E',
label: 'E - 외향 (Extraversion)',
helper: '뭐든 다른 사람과 같이 하면 더 재미있죠.'
},
{
value: 'I',
label: 'I - 내향 (Introversion)',
helper: '혼자 몰입할 수 있는 시간을 더 선호해요.'
}
]
},
{
code: 'NS',
title: '직관과 감각 (N vs S)',
description: '상상력과 가능성에 끌리나요, 아니면 지금 눈앞의 사실이 더 중요한가요?',
options: [
{
value: 'N',
label: 'N - 직관 (Intuition)',
helper: '상상력을 자극하는 이야기와 세계관을 좋아해요.'
},
{
value: 'S',
label: 'S - 감각 (Sensing)',
helper: '현실성 있는 구체적인 경험을 중시해요.'
}
]
},
{
code: 'FT',
title: '감정과 사고 (F vs T)',
description: '결정을 내릴 때 감정을 중시하나요, 아니면 논리를 우선하나요?',
options: [
{
value: 'F',
label: 'F - 감정 (Feeling)',
helper: '선택의 과정과 결과에서 느껴지는 감정과 분위기가 중요해요.'
},
{
value: 'T',
label: 'T - 사고 (Thinking)',
helper: '전략적인 판단, 논리적인 선택과 결과를 중시해요.'
}
]
},
{
code: 'JP',
title: '판단과 인식 (J vs P)',
description: '계획적으로 진행하는 것을 선호하나요, 아니면 유연하게 흐름을 즐기나요?',
options: [
{
value: 'J',
label: 'J - 판단 (Judging)',
helper: '이 다음엔 어떤일이 생길지를 생각하면서 선택을 계획해요.'
},
{
value: 'P',
label: 'P - 인식 (Perceiving)',
helper: '알 수 없는 미래보다 그 순간의 재미와 문제해결을 위해 선택해요.'
}
]
}
];
const selected = [];
let stepIndex = 0;
const stepIndicator = document.getElementById('step-indicator');
const questionTitle = document.getElementById('question-title');
const questionDescription = document.getElementById('question-description');
const description = document.getElementById('description');
const leftButton = document.getElementById('choice-left');
const rightButton = document.getElementById('choice-right');
const nextButton = document.getElementById('next-button');
const resetButton = document.getElementById('reset-button');
const coreDisplay = document.getElementById('mbti-core');
function updateIndicators() {
stepIndicator.innerHTML = '';
dichotomies.forEach((_, index) => {
const span = document.createElement('span');
if (index <= stepIndex - 1) {
span.classList.add('active');
}
stepIndicator.appendChild(span);
});
}
function updateDisplay() {
const filled = ['_', '_', '_', '_'];
selected.forEach((value, index) => {
if (index < 4) {
filled[index] = value;
}
});
coreDisplay.textContent = filled.join(' ');
}
function showStep() {
if (stepIndex >= dichotomies.length) {
const mbtiType = selected.slice(0, 4).join('');
if (mbtiType.length === 4) {
window.location.href = `results/${mbtiType}.html`;
}
return;
}
const step = dichotomies[stepIndex];
questionTitle.textContent = step.title;
questionDescription.textContent = step.description;
leftButton.textContent = step.options[0].label;
leftButton.setAttribute('data-value', step.options[0].value);
leftButton.setAttribute('data-helper', step.options[0].helper);
rightButton.textContent = step.options[1].label;
rightButton.setAttribute('data-value', step.options[1].value);
rightButton.setAttribute('data-helper', step.options[1].helper);
description.textContent = '';
updateIndicators();
updateDisplay();
updateChoiceButtons();
nextButton.disabled = !selected[stepIndex];
nextButton.textContent = stepIndex === dichotomies.length - 1 ? '결과 보기' : '다음';
}
function handleChoice(event) {
const value = event.currentTarget.getAttribute('data-value');
const helper = event.currentTarget.getAttribute('data-helper');
selected[stepIndex] = value;
description.textContent = helper;
updateDisplay();
updateIndicators();
updateChoiceButtons();
nextButton.disabled = false;
}
function updateChoiceButtons() {
const currentValue = selected[stepIndex];
[leftButton, rightButton].forEach(button => {
if (button.getAttribute('data-value') === currentValue) {
button.classList.add('selected');
} else {
button.classList.remove('selected');
}
});
}
function goToNextStep() {
if (!selected[stepIndex]) {
return;
}
stepIndex += 1;
updateIndicators();
showStep();
}
function resetSelection() {
selected.length = 0;
stepIndex = 0;
description.textContent = '';
nextButton.disabled = true;
showStep();
}
leftButton.addEventListener('click', handleChoice);
rightButton.addEventListener('click', handleChoice);
nextButton.addEventListener('click', goToNextStep);
resetButton.addEventListener('click', resetSelection);
showStep();
</script>
</body>
</html>