templates/learn/courseView.html.twig line 1
{% extends 'base.html.twig' %}
{% block title %}HYPA - Apprendre{% endblock %}
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset("css/reset.css") }}">
<link rel="stylesheet" href="{{ asset("css/learn/courseView.css") }}">
<style>
html {
font-family: HanMufa,sans-serif;
}
.character {
font-family: KaiTi,sans-serif;
}
</style>
{% endblock %}
{% block javascripts %}
<script src="https://kit.fontawesome.com/407f58a928.js" crossorigin="anonymous"></script>
<script>
document.addEventListener('DOMContentLoaded', principale);
function principale() {
console.log('js comportements chargé');
const playsoundButton = document.querySelector(".playsound")
playsoundButton.addEventListener('click', playsound)
let semaphore = 1;
function resetSemaphore(){
semaphore=1
}
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let automatic = urlParams.get("automatic")
console.log(automatic)
let volume = urlParams.get("volume")
let volumeSlider = document.getElementById('volume')
volumeSlider.addEventListener('input', changeVolume)
let audio = new Audio(playsoundButton.id)
function changeVolume(){
volume = volumeSlider.value
audio.volume = volume/100
}
if(Object.is(volume,null)||volume==='null'){
volumeSlider.value=50
audio.volume=50/100
} else {
audio.volume=volume/100
volumeSlider.value=volume
}
if(automatic==null) {
automatic = false;
}
if(automatic){
document.getElementById('auto').checked = true
playsound()
}
function playsound(evt){
if(semaphore) {
semaphore=0
// try{
// let audio = new Audio(playsoundButton.id)
// audio.addEventListener('error',stay)
// audio.addEventListener('loadeddata',stay)
// }
// catch (error){
// console.log("whesh je catch")
// console.log(error)
// }
if(!Boolean(playsoundButton.id)){
setTimeout(nextDiapo, 2000)
}
audio.play().catch((error)=>{
console.log(error)
}
)
audio.addEventListener('ended',resetSemaphore)
audio.addEventListener('ended',nextDiapo)
}
}
function nextDiapo(){
if(document.getElementById('auto').checked)
{
automatic=true
const nextPageButton = document.querySelector("#nextPageButton")
if (nextPageButton){
window.location.href = nextPageButton.href + "?automatic=" + automatic + "&volume=" + volume;
}
}
}
function stay(evt){
if (evt.type==="error"){
return null
}
else{
console.log("good")
nextDiapo()
}
}
}
</script>
{% endblock %}
{% block body %}
<header>
<a href="{{ path("app_menu") }}" id="menu"><img src="{{ asset("images/nav_indicators/learn.png") }}" alt=""></a>
<h1>HYPA - Cours</h1>
<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ"></a>
</header>
<section>
<ul>
<li>
{% if numberOfPage > 1%}
<a href="{{ path("app_course_view",{"page": numberOfPage - 1, "course": course.courseId}) }}"><</a>
{% endif %}
</li>
<li class = "picture">
{% if character %}
{% if character.course %}
{% if character.rcc %}
<div class="playsound" id="{{ asset("dictionary/sound/"~character.course.title~"_sons/"~character.rcc.shortcutPath~".m4a") }}">
<figure>
{% if character is not null %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~"-"~character.shortcutPath~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% else %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% endif %}
</figure>
</div>
{% else %}
<div class="playsound" id="{{ asset("dictionary/sound/"~character.course.title~"_sons/"~character.shortcutPath~".m4a") }}">
<figure>
{% if character is not null %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~"-"~character.shortcutPath~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% else %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% endif %}
</figure>
</div>
{% endif %}
{% endif %}
{% else %}
<div class="playsound" id="">
<figure>
{% if character is not null %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~"-"~character.shortcutPath~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% else %}
<img src="{{ asset("dictionary/fr_FR/pictures/"~course.title~"_png/P"~course.courseId~"-D"~numberOfPage~".png") }}" alt="{{ course.title }}">
<figcaption>future translation</figcaption>
{% endif %}
</figure>
</div>
{% endif %}
</li>
<li>
{% if numberOfPagesAvailable > numberOfPage%}
<a id="nextPageButton" href="{{ path("app_course_view",{"page": numberOfPage + 1, "course": course.courseId}) }}">></a>
{% endif %}
</li>
</ul>
<ul>
<li>
<label for="auto"><i class="fa-solid fa-robot"></i></label>
<input type="checkbox" name="auto" id="auto">
</li>
<li>
<label for="volume"><i class="fa-solid fa-volume-high"></i></label>
<input type="range" name="volume" id="volume" min="0" max="100">
</li>
<li>
<a href="{{ path("app_dictionary") }}"><i class="fa-solid fa-book"></i></a>
</li>
</ul>
</section>
{% endblock %}