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