funkcionalita db
This commit is contained in:
parent
e1d400c217
commit
99b6bb8ecf
@ -4,16 +4,15 @@ const translateWordsBtn = document.getElementById('translateWordsBtn');
|
|||||||
const translateLettersBtn = document.getElementById('translateLettersBtn');
|
const translateLettersBtn = document.getElementById('translateLettersBtn');
|
||||||
const prevBtn = document.getElementById('prevBtn');
|
const prevBtn = document.getElementById('prevBtn');
|
||||||
const nextBtn = document.getElementById('nextBtn');
|
const nextBtn = document.getElementById('nextBtn');
|
||||||
const translateBtn = document.getElementById('translateBtn'); // Prelož button
|
const translateBtn = document.getElementById('translateBtn');
|
||||||
|
|
||||||
let videoSequence = [];
|
let videoSequence = [];
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let autoPlayEnabled = true;
|
let autoPlayEnabled = true;
|
||||||
|
|
||||||
// Variable to track the current translation method
|
let currentTranslationMode = 'words';
|
||||||
let currentTranslationMode = 'words'; // Default mode
|
|
||||||
|
|
||||||
// Function to check if video exists
|
|
||||||
async function videoExists(src) {
|
async function videoExists(src) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
@ -23,7 +22,7 @@ async function videoExists(src) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to load video sequence by words
|
|
||||||
async function loadVideoSequenceByWords() {
|
async function loadVideoSequenceByWords() {
|
||||||
const words = inputText.value.trim().split(' ');
|
const words = inputText.value.trim().split(' ');
|
||||||
videoSequence = [];
|
videoSequence = [];
|
||||||
@ -37,7 +36,7 @@ async function loadVideoSequenceByWords() {
|
|||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to load video sequence by letters
|
|
||||||
async function loadVideoSequenceByLetters() {
|
async function loadVideoSequenceByLetters() {
|
||||||
const characters = inputText.value.trim().split('');
|
const characters = inputText.value.trim().split('');
|
||||||
videoSequence = [];
|
videoSequence = [];
|
||||||
@ -53,7 +52,7 @@ async function loadVideoSequenceByLetters() {
|
|||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to play video at a specific index
|
|
||||||
function playVideoAtIndex(index) {
|
function playVideoAtIndex(index) {
|
||||||
if (index < 0 || index >= videoSequence.length) return;
|
if (index < 0 || index >= videoSequence.length) return;
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ function playVideoAtIndex(index) {
|
|||||||
videoPlayer.play();
|
videoPlayer.play();
|
||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
|
|
||||||
// Update the title with the current letter or word
|
|
||||||
const currentChar = videoSequence[index].split('/').pop().split('.')[0];
|
const currentChar = videoSequence[index].split('/').pop().split('.')[0];
|
||||||
document.getElementById('currentLetter').innerText = currentChar.toUpperCase();
|
document.getElementById('currentLetter').innerText = currentChar.toUpperCase();
|
||||||
|
|
||||||
@ -79,11 +78,11 @@ function playVideoAtIndex(index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event listener for "Prelož" button (Translate button)
|
|
||||||
translateBtn.addEventListener('click', async () => {
|
translateBtn.addEventListener('click', async () => {
|
||||||
autoPlayEnabled = true;
|
autoPlayEnabled = true;
|
||||||
|
|
||||||
// Based on current mode, load the correct video sequence
|
|
||||||
if (currentTranslationMode === 'words') {
|
if (currentTranslationMode === 'words') {
|
||||||
await loadVideoSequenceByWords();
|
await loadVideoSequenceByWords();
|
||||||
} else if (currentTranslationMode === 'letters') {
|
} else if (currentTranslationMode === 'letters') {
|
||||||
@ -95,21 +94,21 @@ translateBtn.addEventListener('click', async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listener for "Preložiť po slovách" button
|
|
||||||
translateWordsBtn.addEventListener('click', () => {
|
translateWordsBtn.addEventListener('click', () => {
|
||||||
currentTranslationMode = 'words'; // Set to words mode
|
currentTranslationMode = 'words';
|
||||||
translateWordsBtn.classList.add('active'); // Optionally add active class
|
translateWordsBtn.classList.add('active');
|
||||||
translateLettersBtn.classList.remove('active');
|
translateLettersBtn.classList.remove('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listener for "Preložiť po písmenách" button
|
|
||||||
translateLettersBtn.addEventListener('click', () => {
|
translateLettersBtn.addEventListener('click', () => {
|
||||||
currentTranslationMode = 'letters'; // Set to letters mode
|
currentTranslationMode = 'letters';
|
||||||
translateLettersBtn.classList.add('active'); // Optionally add active class
|
translateLettersBtn.classList.add('active');
|
||||||
translateWordsBtn.classList.remove('active');
|
translateWordsBtn.classList.remove('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listeners for prev and next buttons to navigate video sequence
|
|
||||||
prevBtn.addEventListener('click', () => {
|
prevBtn.addEventListener('click', () => {
|
||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
autoPlayEnabled = false;
|
autoPlayEnabled = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user