-
Notifications
You must be signed in to change notification settings - Fork 0
/
music.js
160 lines (133 loc) · 4.28 KB
/
music.js
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
// Questions will be asked
const Questions = [{
id: 0,
q: "The popular BTS band belongs to which country?",
a: [{ text: "North Korea", isCorrect: false },
{ text: "China", isCorrect: false },
{ text: "South Korea", isCorrect: true },
{ text: "Germany", isCorrect: false }
]
},
{
id: 1,
q: "The famous Indian singer , composer who left too early?",
a: [{ text: "Shekhar Suman", isCorrect: false, isSelected: false },
{ text: "Vishal", isCorrect: false },
{ text: "Bappi Lahiri", isCorrect: true },
{ text: "Andy Murray", isCorrect: false }
]
},
{
id: 2,
q: "Nightingale of India?",
a: [{ text: "Shreya Ghoshal", isCorrect: false },
{ text: "Neha Kakkar", isCorrect: false },
{ text: "Lata Mangeshkar", isCorrect: true },
{ text: "Alka Yagnik", isCorrect: false }
]
},
{
id: 3,
q: "The patriotic song 'Maa Tujhe Salaam' was sung by?",
a: [{ text: "Shaan", isCorrect: false },
{ text: "A.R.Rehman", isCorrect: true },
{ text: "Kailash Kher", isCorrect: false },
{ text: "Shankar Mahadevan", isCorrect: false }
]
},
{
id: 4,
q: "The song 'Manike Mage Hithe' is written in which language?",
a: [{ text: "Tamil", isCorrect: false },
{ text: "Kannada", isCorrect: false },
{ text: "Telugu", isCorrect:false },
{ text: "Sri Lankan", isCorrect: true }
]
}
];
// Set start
var start = true;
// Iterate
function iterate(id) {
// Getting the result display section
var result = document.getElementsByClassName("result");
result[0].innerText = "";
// Getting the question
const question = document.getElementById("question");
// Setting the question text
question.innerText = Questions[id].q;
// Getting the options
const op1 = document.getElementById('op1');
const op2 = document.getElementById('op2');
const op3 = document.getElementById('op3');
const op4 = document.getElementById('op4');
// Providing option text
op1.innerText = Questions[id].a[0].text;
op2.innerText = Questions[id].a[1].text;
op3.innerText = Questions[id].a[2].text;
op4.innerText = Questions[id].a[3].text;
// Providing the true or false value to the options
op1.value = Questions[id].a[0].isCorrect;
op2.value = Questions[id].a[1].isCorrect;
op3.value = Questions[id].a[2].isCorrect;
op4.value = Questions[id].a[3].isCorrect;
var selected = "";
// Show selection for op1
op1.addEventListener("click", () => {
op1.style.backgroundColor = "lightgoldenrodyellow";
op2.style.backgroundColor = "lightskyblue";
op3.style.backgroundColor = "lightskyblue";
op4.style.backgroundColor = "lightskyblue";
selected = op1.value;
});
// Show selection for op2
op2.addEventListener("click", () => {
op1.style.backgroundColor = "lightskyblue";
op2.style.backgroundColor = "lightgoldenrodyellow";
op3.style.backgroundColor = "lightskyblue";
op4.style.backgroundColor = "lightskyblue";
selected = op2.value;
});
// Show selection for op3
op3.addEventListener("click", () => {
op1.style.backgroundColor = "lightskyblue";
op2.style.backgroundColor = "lightskyblue";
op3.style.backgroundColor = "lightgoldenrodyellow";
op4.style.backgroundColor = "lightskyblue";
selected = op3.value;
});
// Show selection for op4
op4.addEventListener("click", () => {
op1.style.backgroundColor = "lightskyblue";
op2.style.backgroundColor = "lightskyblue";
op3.style.backgroundColor = "lightskyblue";
op4.style.backgroundColor = "lightgoldenrodyellow";
selected = op4.value;
});
// Grabbing the evaluate button
const evaluate = document.getElementsByClassName("evaluate");
// Evaluate method
evaluate[0].addEventListener("click", () => {
if (selected == "true") {
result[0].innerHTML = "True";
result[0].style.color = "green";
} else {
result[0].innerHTML = "False";
result[0].style.color = "red";
}
});
}
if (start) {
iterate("0");
}
// Next button and method
const next = document.getElementsByClassName('next')[0];
var id = 0;
next.addEventListener("click", () => {
start = false;
if (id < 5) {
id++;
iterate(id);
console.log(id);
}
});