Added progress bar.

This commit is contained in:
doncr 2021-09-30 19:26:37 +01:00
parent 9113878947
commit d6ebdc5a95
3 changed files with 27 additions and 0 deletions

View File

@ -316,3 +316,14 @@ div.halfSpeed {
font-size: 50%; font-size: 50%;
text-align: center; text-align: center;
} }
.progressContainer {
width: 100vw;
height: 5px;
background: black;
}
.progressBar {
height: 5px;
background: white;
}

View File

@ -218,6 +218,11 @@
<div id="quizSection"> <div id="quizSection">
<div class="progressContainer">
<div class="progressBar" style="width: 0%">
</div>
</div>
<div class="questionOuter"> <div class="questionOuter">
<div id="question"> <div id="question">
<div id="questionFirstHalf"></div> <div id="questionFirstHalf"></div>

View File

@ -557,6 +557,11 @@ function processAnswer() {
"correct": correct "correct": correct
}); });
var totalQuestions = $('#numQuestions').val();
var answeredQuestions = log.history.length;
updateProgressBar(answeredQuestions / totalQuestions * 100);
$('#answer').val(""); $('#answer').val("");
$('#responseButton').prop('class', klass).text(response); $('#responseButton').prop('class', klass).text(response);
@ -652,6 +657,10 @@ function updateHistoryView(log) {
$('#scoreSectionTitleWide').text(resultString); $('#scoreSectionTitleWide').text(resultString);
} }
function updateProgressBar(progress) {
$('.progressBar').attr('style', 'width: ' + progress + '%');
}
function proceed() { function proceed() {
if (log.history.length == $('#numQuestions').val()) { if (log.history.length == $('#numQuestions').val()) {
endQuiz(); endQuiz();
@ -681,6 +690,8 @@ function startQuiz() {
voiceSelectError.style.display = "none"; voiceSelectError.style.display = "none";
} }
updateProgressBar(0);
$('#splash').hide(); $('#splash').hide();
$('#quizSection').show(); $('#quizSection').show();
$('#scoreSection').hide(); $('#scoreSection').hide();