forked from kmssuper/web_suhang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (46 loc) · 1.75 KB
/
Copy pathscript.js
File metadata and controls
50 lines (46 loc) · 1.75 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
let currentMatchup = 0;
const matchups = [
{
option1: { img: 'image1.jpg', text: '옵션 1 설명' },
option2: { img: 'image2.jpg', text: '옵션 2 설명' },
},
{
option1: { img: 'image3.jpg', text: '옵션 3 설명' },
option2: { img: 'image4.jpg', text: '옵션 4 설명' },
},
// 필요한 만큼 더 추가
];
function loadMatchup() {
const matchup = matchups[currentMatchup];
document.getElementById('option1').querySelector('img').src = matchup.option1.img;
document.getElementById('option1').querySelector('p').innerText = matchup.option1.text;
document.getElementById('option2').querySelector('img').src = matchup.option2.img;
document.getElementById('option2').querySelector('p').innerText = matchup.option2.text;
}
document.querySelectorAll('.select-btn').forEach(btn => {
btn.addEventListener('click', function() {
const selectedOption = this.parentElement;
selectedOption.style.border = '2px solid #4CAF50';
document.querySelectorAll('.select-btn').forEach(button => {
button.disabled = true;
});
document.getElementById('nextRound').classList.remove('hidden');
});
});
document.getElementById('nextRound').addEventListener('click', function() {
currentMatchup++;
if (currentMatchup < matchups.length) {
loadMatchup();
this.classList.add('hidden');
document.querySelectorAll('.option').forEach(option => {
option.style.border = '2px solid #ddd';
});
document.querySelectorAll('.select-btn').forEach(button => {
button.disabled = false;
});
} else {
alert('게임이 종료되었습니다!');
}
});
// 첫 번째 라운드 로드
loadMatchup();