-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.js
50 lines (40 loc) · 1.82 KB
/
ui.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
function UI() {
this.btn_start = document.querySelector('.btn_start'),
this.btn_next = document.querySelector(".next_btn"),
this.btn_replay = document.querySelector(".btn_replay"),
this.btn_quit = document.querySelector(".btn_quit"),
this.quiz_box = document.querySelector('.quiz_box'),
this.score_box = document.querySelector('.score_box'),
this.option_list = document.querySelector(".option_list"),
this.correctIcon = '<div class="icon"><i class="fas fa-check"></i></div>',
this.incorrectIcon = '<div class="icon"><i class="fas fa-times"></i></div>',
this.time_text = document.querySelector(".time_text"),
this.time_second = document.querySelector(".time_second"),
this.time_line = document.querySelector(".time_line")
}
UI.prototype.soruGoster = function(soru) {
let question = `<span>${soru.soruMetni}</span>`;
let option = '';
for(let cevap in soru.cevapSecenekleri) {
option +=
`
<div class="option">
<span><b>${cevap}</b>: ${soru.cevapSecenekleri[cevap]}</span>
</div>
`;
}
document.querySelector(".question_text").innerHTML = question;
this.option_list.innerHTML = option;
const options =this.option_list.querySelectorAll(".option");
for(let opt of options) {
opt.setAttribute("onclick", "optionSelected(this)")
}
}
UI.prototype.soruSayisiniGoster = function(soruSirasi,toplamSoru) {
let tag = `<span class="badge bg-warning">${soruSirasi} / ${toplamSoru}</span>`;
document.querySelector(".quiz_box .question_index").innerHTML = tag;
}
UI.prototype.scoruGoster = function(toplamSoru,dogruCevap) {
let tag = `Toplam ${toplamSoru} sorudan ${dogruCevap} doğru cevap verdiniz.`
document.querySelector(".score_box .score_text").innerHTML = tag
}