38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Slovenska abeceda
|
|
const alphabet = [
|
|
'A', 'B', 'C', 'Č', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'V', 'Z', 'Ž'
|
|
];
|
|
|
|
// Funkcija za naključno izbiro črke
|
|
function getRandomLetter() {
|
|
const randomIndex = Math.floor(Math.random() * alphabet.length);
|
|
return alphabet[randomIndex];
|
|
}
|
|
|
|
// Funkcija za zagon odštevalnika
|
|
function startTimer() {
|
|
let timeLeft = 60; // začetni čas (60 sekund)
|
|
|
|
const timerElement = document.getElementById('timer');
|
|
|
|
// Funkcija, ki posodablja preostali čas vsakih 1000 ms (1 sekunda)
|
|
const timerInterval = setInterval(function() {
|
|
timeLeft--;
|
|
timerElement.textContent = `Preostali čas: ${timeLeft}s`;
|
|
|
|
// Ko čas doseže 0, ustavimo odštevalnik
|
|
if (timeLeft <= 0) {
|
|
clearInterval(timerInterval);
|
|
timerElement.textContent = 'Čas je potekel!';
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
// Prikaz naključne črke na spletni strani
|
|
document.getElementById('letter').textContent = getRandomLetter();
|
|
|
|
// Zaženemo odštevalnik
|
|
startTimer();
|
|
|