Skip to content

Commit

Permalink
Merge pull request #13 from falvojr/falvojr-patch-2
Browse files Browse the repository at this point in the history
Transcrição em Português como a Padrão e Remoção do Botão de Ocultar
  • Loading branch information
falvojr authored Jul 12, 2024
2 parents 80f33ab + 19f88ef commit 1a1f9bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
2 changes: 0 additions & 2 deletions docs/player/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
<div class="right col-5 col-s-4">
<div class="carousel-controllers"></div>
<div class="aside">
<!-- Botões de idioma -->
<div class="text-area">
<p id="resume-text"></p>
</div>
<button class="border-btn ocultar-resumo" id="btn-show-resume">Ocultar transcrição</button>
</div>

<!-- Ícone do VLibras para acessibilidade -->
Expand Down
37 changes: 8 additions & 29 deletions docs/player/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,9 @@ const elements = {
resumoButtons: {}, // será preenchido dinamicamente
resumoText: getById('resume-text'),
titleText: getById('title-text'),
descriptionText: getById('description-text'),
btnShowResume: getById('btn-show-resume'),
descriptionText: getById('description-text')
};

// Função para exibir ou ocultar o botão 'btn-show-resume' com base na transcrição selecionada
function toggleBtnShowResumeVisibility() {
// Verificar se há texto na transcrição
const hasTranscription = elements.resumoText.textContent.trim().length > 0;

// Exibir ou ocultar o botão com base na presença de transcrição
elements.btnShowResume.style.display = hasTranscription ? 'block' : 'none';
}

// Função para ocultar a transcrição e o botão 'btn-show-resume'
function hideTranscription() {
elements.resumoText.innerHTML = ''; // Limpar o conteúdo da transcrição

elements.btnShowResume.style.display = 'none'; // Ocultar o botão 'btn-show-resume'
}

// Carregar video a partir do retorno da api
async function loadVideo(videoElement) {
const sourceElement = document.createElement('source');
Expand Down Expand Up @@ -102,8 +85,6 @@ function carregarResumo(idioma) {
pElement.textContent = paragrafo;
elements.resumoText.appendChild(pElement);
});

toggleBtnShowResumeVisibility();
})
.catch((error) => {
console.error(`Erro ao carregar resumo em ${idioma}:`, error);
Expand Down Expand Up @@ -132,20 +113,16 @@ document.addEventListener('DOMContentLoaded', async () => {

// Criar dinamicamente os controles de idioma
for (const langCode in apiModel.metadata.localizations) {
addLanguageButton(langCode);
const buttonTranscript = addLanguageButton(langCode);
if (langCode == 'pt-BR') {
buttonTranscript.click();
}
}

// Ocultar botão transcrição
elements.btnShowResume.style.display = 'none';

} catch (error) {
console.error('There has been a problem with your fetch operation:', error);
}
});

// Eventos para carregar o resumo quando o botão "Ver Resumo" for clicado.
elements.btnShowResume.addEventListener('click', () => {hideTranscription(); toggleBtnShowResumeVisibility();});

// Função para criar e adicionar elementos de botão de idioma
function addLanguageButton(langCode) {
const carouselControllers = getFirstByClass('carousel-controllers');
Expand Down Expand Up @@ -176,6 +153,8 @@ function addLanguageButton(langCode) {
resetControllers();
this.parentElement.classList.add('active');
});

return button;
}

// Função para resetar todas as classes para a cor padrão
Expand All @@ -185,4 +164,4 @@ function resetControllers() {
controller.classList.remove('active');
});
}


0 comments on commit 1a1f9bb

Please sign in to comment.