mirror of
https://github.com/olehomelchenko/minivlat-local-ua.git
synced 2025-12-21 21:22:24 +00:00
Refactor quiz layout and timer functionality for improved responsiveness and clarity
This commit is contained in:
@@ -72,6 +72,7 @@ form button {
|
|||||||
|
|
||||||
#quiz {
|
#quiz {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chart {
|
#chart {
|
||||||
@@ -79,6 +80,17 @@ form button {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
#quiz {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chart {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#question-text, #options {
|
#question-text, #options {
|
||||||
@@ -106,6 +118,13 @@ form button {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#timer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
let currentQuestionIndex = 0;
|
let currentQuestionIndex = 0;
|
||||||
let score = 0;
|
let score = 0;
|
||||||
let quizResults = [];
|
let quizResults = [];
|
||||||
let timeLeft = 25000; // 25 seconds in milliseconds
|
const initialTimeLeft = 250000; // 25 seconds in milliseconds
|
||||||
|
let timeLeft = initialTimeLeft;
|
||||||
let timer;
|
let timer;
|
||||||
let startTime = new Date().toISOString();
|
let startTime = new Date().toISOString();
|
||||||
|
|
||||||
@@ -62,8 +63,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
// Complete timer reset
|
// Complete timer reset
|
||||||
stopTimer();
|
stopTimer();
|
||||||
timeLeft = 25000; // 25 seconds in milliseconds
|
timeLeft = initialTimeLeft; // Reset to initial time
|
||||||
timerDisplay.textContent = (timeLeft / 1000).toFixed(1); // Display in seconds
|
timerDisplay.textContent = Math.ceil(timeLeft / 1000); // Display in whole seconds
|
||||||
|
|
||||||
const question = questions[currentQuestionIndex];
|
const question = questions[currentQuestionIndex];
|
||||||
const chartFile = `charts/${question.chart}-${version}.vl.json`;
|
const chartFile = `charts/${question.chart}-${version}.vl.json`;
|
||||||
@@ -116,11 +117,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
stopTimer();
|
stopTimer();
|
||||||
|
|
||||||
// Ensure display shows starting value
|
// Ensure display shows starting value
|
||||||
timerDisplay.textContent = (timeLeft / 1000).toFixed(1); // Display in seconds
|
timerDisplay.textContent = Math.ceil(timeLeft / 1000); // Display in whole seconds
|
||||||
|
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
timeLeft -= 100; // Decrease by 100 milliseconds
|
timeLeft -= 100; // Decrease by 100 milliseconds
|
||||||
timerDisplay.textContent = (timeLeft / 1000).toFixed(1); // Display in seconds
|
timerDisplay.textContent = Math.ceil(timeLeft / 1000); // Display in whole seconds
|
||||||
|
|
||||||
if (timeLeft <= 0) {
|
if (timeLeft <= 0) {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
@@ -183,7 +184,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
currentQuestionIndex++;
|
currentQuestionIndex++;
|
||||||
// Reset timer state before showing next question
|
// Reset timer state before showing next question
|
||||||
timeLeft = 25000; // 25 seconds in milliseconds
|
timeLeft = initialTimeLeft; // Reset to initial time
|
||||||
displayQuestion();
|
displayQuestion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user