Compare commits

..

4 Commits

Author SHA1 Message Date
28468a596f funguje 2024-11-23 14:59:41 +00:00
d68e0f14c7 Update scripts/videoplayer.js 2024-11-23 14:16:39 +00:00
0a1286a905 Update styles/style.css 2024-11-23 14:13:07 +00:00
39bfe5dcfe #24 2024-11-23 14:12:28 +00:00
3 changed files with 34 additions and 36 deletions

View File

@ -53,7 +53,6 @@ async function fetchVideoUrl(word) {
return data.video_url;
}
// Function to load video sequence by words using Supabase
async function loadVideoSequenceByWords() {
const words = inputText.value.trim().split(' ');
@ -104,6 +103,29 @@ async function loadVideoSequenceByLetters() {
currentIndex = 0;
}
// Function to highlight the current word or letter in the textarea
function highlightCurrentText(index) {
let wordsOrLetters = currentTranslationMode === 'words' ? inputText.value.trim().split(' ') : inputText.value.trim().split('');
// Reset the highlighted text in the textarea
inputText.value = '';
inputText.setSelectionRange(0, 0);
let startIndex = 0;
wordsOrLetters.forEach((item, i) => {
if (i < index) {
startIndex += item.length + (currentTranslationMode === 'words' ? 1 : 0);
}
});
let endIndex = startIndex + wordsOrLetters[index].length;
inputText.value = wordsOrLetters.join(currentTranslationMode === 'words' ? ' ' : '');
// Highlight the current word or letter
inputText.setSelectionRange(startIndex, endIndex);
inputText.focus();
}
// Function to play video at a specific index
function playVideoAtIndex(index) {
if (index < 0 || index >= videoSequence.length) return;
@ -112,6 +134,9 @@ function playVideoAtIndex(index) {
videoPlayer.play();
currentIndex = index;
// Highlight the current word or letter
highlightCurrentText(currentIndex);
// Update the title with the current word or letter
const currentLabel = videoSequence[index].split('/').pop().split('.')[0];
document.getElementById('currentLetter').innerText = currentLabel.toUpperCase();
@ -194,4 +219,4 @@ inputText.addEventListener('input', () => {
} else {
translateBtn.disabled = true; // Disable the translate button if the text is empty
}
});
});

View File

@ -1,34 +0,0 @@
from supabase import create_client, Client
# RLS policy permissions required:
# buckets table permissions: select
# objects table permissions: none
url: str = ""
key: str = ""
supabase: Client = create_client(url, key)
# List all objects in the 'video' bucket
# .from("bucket_name")
# .list("folder_name")
response = supabase.storage.from_("video").list("",{"limit": 1000})
for video in response:
video_name = video['name'].replace('.mp4', '')
video_url = f"{url}/storage/v1/object/public/video/{video_name}.mp4"
# print the video name and url with tabs
print(video_name, video_url, sep="\t")
response = (
# .table("table_name")
# .insert({"column_name": value})
# .execute SQL query
supabase.table("Videa")
.insert({"label": video_name, "video_url": video_url})
.execute()
)
# print(response)

View File

@ -153,6 +153,13 @@ h1 {
background-color: #357ae8;
}
/* Zvýraznenie pre aktuálne slovo/písmeno */
.highlight {
background-color: #ffeb3b; /* Svetložltá farba na zvýraznenie */
font-weight: bold;
color: #333;
}
.video {
position: relative;
width: 45%;