-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (98 loc) · 2.59 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Chord Sequence</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
#chord-display {
font-size: 2em;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div>
<label for="num-players">Number of Players: </label><br />
<input
type="number"
id="num-players"
min="1"
max="7"
value="2" />
</div>
<div id="player-display">Player: All</div>
<div id="chord-display">Click to start</div>
<button id="next-chord-btn">Commit</button>
<script>
const sequence = [
'Dm',
'C',
'Eb',
'Dm',
'Em',
'F',
'EM',
'F',
'G',
'Am',
'Bb',
'Dm',
'Dmadd2',
'Dm',
'C',
'Eb',
'D',
'Em',
'F',
'Em',
'F',
'G',
'Am',
'Bb',
'Dm',
];
let currentChordIndex = 0;
let previousPlayerIndex = -1;
document
.getElementById('next-chord-btn')
.addEventListener('click', () => {
const chordDisplay = document.getElementById('chord-display');
const playerDisplay = document.getElementById('player-display');
const numPlayers = parseInt(
document.getElementById('num-players').value,
10,
);
if (currentChordIndex < sequence.length) {
chordDisplay.textContent = sequence[currentChordIndex];
let randomPlayerIndex;
if (numPlayers === 1) {
randomPlayerIndex = 0; // If there's only one player, always choose player 1
} else {
do {
randomPlayerIndex = Math.floor(Math.random() * numPlayers);
} while (randomPlayerIndex === previousPlayerIndex);
}
previousPlayerIndex = randomPlayerIndex;
playerDisplay.textContent = `Player: ${randomPlayerIndex + 1}`;
currentChordIndex++;
} else {
chordDisplay.textContent = 'All chords have been displayed';
playerDisplay.textContent = 'Player: -';
currentChordIndex = 0; // Reset to start over if needed
previousPlayerIndex = -1;
}
});
</script>
</body>
</html>