Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pédagogies Multimodales
Phonographe
Commits
8fc4ff14
Commit
8fc4ff14
authored
Jan 09, 2023
by
Sylvain Coulange
🌼
Browse files
serie Englishrandom proto
parent
e832507b
Changes
15
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
8fc4ff14
temp
Pipfile
Pipfile.lock
\ No newline at end of file
clavier/models.py
View file @
8fc4ff14
...
...
@@ -9,6 +9,7 @@ class Serie(models.Model):
code
=
models
.
CharField
(
default
=
'nouvelle_serie'
,
max_length
=
100
)
description
=
models
.
TextField
(
blank
=
True
,
max_length
=
500
)
auteur
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
PROTECT
)
lang
=
models
.
CharField
(
default
=
'fr'
,
max_length
=
5
)
panneau
=
models
.
CharField
(
default
=
'phonoFrDo'
,
max_length
=
50
)
fidel
=
models
.
CharField
(
default
=
'fidelDo'
,
max_length
=
50
)
...
...
clavier/views.py
View file @
8fc4ff14
...
...
@@ -138,6 +138,9 @@ def infoSerie(request, pk):
"description"
:
s
.
description
,
"auteur"
:
s
.
auteur
.
username
,
"auteurIm"
:
s
.
auteur
.
profile
.
image
.
url
,
"lang"
:
s
.
lang
if
hasattr
(
s
,
'lang'
)
else
'fr'
,
"audioDeb"
:
s
.
audioDeb
,
"imageDeb"
:
s
.
imageDeb
,
"videoDeb"
:
s
.
videoDeb
,
...
...
@@ -168,6 +171,9 @@ def openPlayerPhono(request, pk):
"code"
:
s
.
code
,
"description"
:
s
.
description
,
"auteur"
:
s
.
auteur
.
username
,
"lang"
:
s
.
lang
if
hasattr
(
s
,
'lang'
)
else
'fr'
,
"audioDeb"
:
s
.
audioDeb
,
"imageDeb"
:
s
.
imageDeb
,
"videoDeb"
:
s
.
videoDeb
,
...
...
@@ -233,4 +239,66 @@ def playIpa(request):
"audio"
:
audioBytes
}
return
JsonResponse
(
data
)
import
urllib.request
as
urlreq
import
urllib.parse
as
urlparse
import
requests
import
re
def
getWikiAudio
(
request
):
colis
=
json
.
loads
(
request
.
body
)
mot
=
colis
[
'inText'
]
lang
=
colis
[
'lang'
]
data
=
{
"urls"
:
[]
}
mot
=
urlparse
.
quote
(
mot
)
wikiPath
=
f
'https://
{
lang
}
.wiktionary.org/wiki/'
+
mot
print
(
"Tentative d'accès à"
,
wikiPath
)
req
=
requests
.
get
(
wikiPath
)
if
req
.
status_code
==
200
:
# si le site est accessible
webContent
=
urlreq
.
urlopen
(
wikiPath
)
trouvAudio
=
False
# passe à True si audio trouvé dans Prononciation
balisePron
=
False
# pour ne récupérer que les balises audio dans la partie "Prononciation"
for
line
in
webContent
:
line
=
line
.
decode
(
"utf8"
)
if
lang
==
"fr"
:
search
=
re
.
search
(
r
'<h3><span class=\"mw\-headline\" id=\"Prononciation\">'
,
line
)
else
:
search
=
re
.
search
(
r
'//upload.wikimedia.org/.*?\.(mp3|ogg)'
,
line
)
if
search
:
balisePron
=
True
if
balisePron
:
source
=
re
.
search
(
r
'<source src=\"([^\"]*)\"'
,
line
)
if
source
:
regSearch
=
re
.
search
(
r
'[Ee]n-(\w\w)-'
,
source
.
group
(
1
))
if
regSearch
:
reg
=
regSearch
.
group
(
1
).
lower
()
else
:
reg
=
'en'
link
=
'https:{}'
.
format
(
source
.
group
(
1
))
data
[
'urls'
].
append
([
reg
,
link
])
trouvAudio
=
True
search
=
re
.
search
(
r
'<\/ul>'
,
line
)
if
search
:
balisePron
=
False
break
# if not trouvAudio:
# print('Aucun enregistrement trouvé.')
return
JsonResponse
(
data
)
\ No newline at end of file
clavierPhono/urls.py
View file @
8fc4ff14
...
...
@@ -64,6 +64,8 @@ urlpatterns = [
path
(
'player/serie-<str:pk>/edit'
,
user_views
.
editSerie
,
name
=
'serie-edit'
),
path
(
'player/serie-<str:pk>/copy'
,
user_views
.
copySerie
,
name
=
'serie-copy'
),
path
(
'player/getWikiAudio/'
,
csrf_exempt
(
clavier_views
.
getWikiAudio
),
name
=
'getWikiAudio'
),
path
(
'_delSerie/'
,
csrf_exempt
(
user_views
.
delSerie
)),
path
(
'_delFile/'
,
csrf_exempt
(
user_views
.
removeFile
)),
path
(
'_saveTrace/'
,
csrf_exempt
(
user_views
.
saveTrace
)),
...
...
static/js/clavier.js
View file @
8fc4ff14
...
...
@@ -160,7 +160,35 @@ let hamzah = [
"
ٔ
"
]
var
diphtonguesCorrespondance
=
{
"
rect_i_majschwa
"
:
"
rect_i_majarobase
"
,
"
rect_eschwi
"
:
"
rect_ei_maj
"
,
"
rect_eschwa
"
:
"
rect_earobase
"
,
"
rect_aschwi
"
:
"
rect_ai_maj
"
,
"
rect_aschwu
"
:
"
rect_au_maj
"
,
"
rect_o_majschwi
"
:
"
rect_o_maji_maj
"
,
"
rect_arobaseschwu
"
:
"
rect_arobaseu_maj
"
,
"
rect_u_majschwa
"
:
"
rect_u_majarobase
"
}
function
recupPhon
(
identifiant
){
console
.
log
(
"
IDENTI
"
,
identifiant
)
// Debug temporaire anglais diphtongues
if
(
thisPageLang
==
"
en
"
)
{
if
([
"
rect_i_majschwa
"
,
"
rect_eschwi
"
,
"
rect_eschwa
"
,
"
rect_aschwi
"
,
"
rect_aschwu
"
,
"
rect_o_majschwi
"
,
"
rect_arobaseschwu
"
,
"
rect_u_majschwa
"
].
includes
(
identifiant
))
{
identifiant
=
diphtonguesCorrespondance
[
identifiant
]
}
}
if
(
!
modeGraphies
)
{
//////////////////////////////
//// IF NOT modeGraphies
...
...
static/js/clavierCalques.js
View file @
8fc4ff14
...
...
@@ -63,5 +63,5 @@ function agrandirPanneau() {
function
showPanneau
()
{
document
.
getElementById
(
'
doCalques
'
).
style
=
''
document
.
getElementById
(
'
cachePanneau
'
).
style
.
display
=
'
none
'
document
.
getElementById
(
'
cachePanneau
'
)
?
document
.
getElementById
(
'
cachePanneau
'
).
style
.
display
=
'
none
'
:
"
do nothing
"
}
\ No newline at end of file
static/js/editSerie.js
View file @
8fc4ff14
...
...
@@ -540,7 +540,7 @@ function appendPhonCard(phonId, targetDiv) {
var
newCarte
=
document
.
createElement
(
'
div
'
);
newCarte
.
classList
=
"
createSerieCarte
"
;
newCarte
.
style
.
backgroundImage
=
`url('../../../media/phonocartes/do_bouches/`
+
phonId
+
`.png')`
;
// `url('/static/cartes/bouch
es/`+ phonId + `.
j
pg')`; //
"url('/static/bouches/pochoirs_bouches/"+ phonId +".png')";
newCarte
.
style
.
backgroundImage
=
`url('../../../media/phonocartes/do_bouches/`
+
phonId
+
`.png')`
+
'
,
'
+
`url('../../../media/phonocartes/do_form
es/`
+
phonId
+
`.p
n
g')`
;
//
Fallback : do_formes
newCarte
.
addEventListener
(
"
click
"
,
function
()
{
playPhon
(
phonId
);
});
...
...
static/js/phon2api.js
View file @
8fc4ff14
...
...
@@ -13,6 +13,7 @@ var phon2api = {
"
phon_6
"
:
"
ɐ
"
,
"
phon_7_rho
"
:
"
ɤ˞
"
,
"
phon_7
"
:
"
ɤ
"
,
"
phon_7rho
"
:
"
ɤ˞
"
,
"
phon_8
"
:
"
ɵ
"
,
"
phon_9_maj
"
:
"
ɶ
"
,
"
phon_9_nas
"
:
"
œ̃
"
,
...
...
@@ -24,19 +25,29 @@ var phon2api = {
"
phon_a_maj
"
:
"
ɑ
"
,
"
phon_a_majr
"
:
"
ɑɹ
"
,
"
phon_a_maju_maj
"
:
"
aʊ
"
,
"
phon_a_majschwu
"
:
"
aʊ
"
,
"
phon_a_rho
"
:
"
a˞
"
,
"
phon_a
"
:
"
a
"
,
"
phon_ai_maj
"
:
"
aɪ
"
,
"
phon_aschwi
"
:
"
aɪ
"
,
"
phon_ai_majarobase
"
:
"
aɪə
"
,
"
phon_ai_majschwa
"
:
"
aɪə
"
,
"
phon_arho
"
:
"
a˞
"
,
"
phon_arobase_rho
"
:
"
ɚ
"
,
"
phon_arobase_slash
"
:
"
ɘ
"
,
"
phon_arobase
"
:
"
ə
"
,
"
phon_arobasel
"
:
"
əl
"
,
"
phon_schwal
"
:
"
əl
"
,
"
phon_arobasem
"
:
"
əm
"
,
"
phon_schwam
"
:
"
əm
"
,
"
phon_arobasen
"
:
"
ən
"
,
"
phon_schwan
"
:
"
ən
"
,
"
phon_arobaseu_maj
"
:
"
əʊ
"
,
"
phon_arobaseschwu
"
:
"
əʊ
"
,
"
phon_au_maj
"
:
"
aʊ
"
,
"
phon_aschwu
"
:
"
aʊ
"
,
"
phon_au_majwarobase
"
:
"
aʊwə
"
,
"
phon_au_majwschwa
"
:
"
aʊwə
"
,
"
phon_b_chev
"
:
"
ɓ
"
,
"
phon_b_emph
"
:
"
bˤ
"
,
"
phon_b_maj_slash
"
:
"
ʙ
"
,
...
...
@@ -69,9 +80,11 @@ var phon2api = {
"
phon_e_maj
"
:
"
ɛ
"
,
"
phon_e
"
:
"
e
"
,
"
phon_earobase
"
:
"
eə
"
,
"
phon_eschwa
"
:
"
eə
"
,
"
phon_ef
"
:
"
ef
"
,
"
phon_egal_slash
"
:
"
ǂ
"
,
"
phon_ei_maj
"
:
"
eɪ
"
,
"
phon_eschwi
"
:
"
eɪ
"
,
"
phon_er
"
:
"
eɹ
"
,
"
phon_exclam_slash
"
:
"
ǃ
"
,
"
phon_f_maj
"
:
"
ɱ
"
,
...
...
@@ -101,6 +114,7 @@ var phon2api = {
"
phon_i_long
"
:
"
iː
"
,
"
phon_i_maj
"
:
"
ɪ
"
,
"
phon_i_majarobase
"
:
"
ɪə
"
,
"
phon_i_majschwa
"
:
"
ɪə
"
,
"
phon_i_majr
"
:
"
ɪɹ
"
,
"
phon_i
"
:
"
i
"
,
"
phon_ij
"
:
"
ij
"
,
...
...
@@ -117,6 +131,7 @@ var phon2api = {
"
phon_jarobase
"
:
"
jə
"
,
"
phon_ju_long
"
:
"
juː
"
,
"
phon_ju_majarobase
"
:
"
jʊə
"
,
"
phon_ju_majschwa
"
:
"
jʊə
"
,
"
phon_ju_majr
"
:
"
jʊɹ
"
,
"
phon_k_chev2
"
:
"
kʼ
"
,
"
phon_k_h
"
:
"
kʰ
"
,
...
...
@@ -176,9 +191,11 @@ var phon2api = {
"
phon_o_maj_slash
"
:
"
ʘ
"
,
"
phon_o_maj
"
:
"
ɔ
"
,
"
phon_o_maji_maj
"
:
"
ɔɪ
"
,
"
phon_o_majschwi
"
:
"
ɔɪ
"
,
"
phon_o_majr
"
:
"
ɔɹ
"
,
"
phon_o
"
:
"
o
"
,
"
phon_ou_maj
"
:
"
oʊ
"
,
"
phon_oschwu
"
:
"
oʊ
"
,
"
phon_p_chev2
"
:
"
pʼ
"
,
"
phon_p_d
"
:
"
p̪
"
,
"
phon_p_h
"
:
"
pʰ
"
,
...
...
@@ -242,6 +259,7 @@ var phon2api = {
"
phon_u_maj_ns
"
:
"
ʊ̯
"
,
"
phon_u_maj
"
:
"
ʊ
"
,
"
phon_u_majarobase
"
:
"
ʊə
"
,
"
phon_u_majschwa
"
:
"
ʊə
"
,
"
phon_u_majr
"
:
"
ʊɹ
"
,
"
phon_u
"
:
"
u
"
,
"
phon_v_flap
"
:
"
ⱱ
"
,
...
...
@@ -253,6 +271,7 @@ var phon2api = {
"
phon_wa_maj
"
:
"
wɑ
"
,
"
phon_wa
"
:
"
wa
"
,
"
phon_wai_maj
"
:
"
waɪ
"
,
"
phon_waschwi
"
:
"
waɪ
"
,
"
phon_war
"
:
"
waɹ
"
,
"
phon_we_maj_nas
"
:
"
wɛ̃
"
,
"
phon_wo
"
:
"
wo
"
,
...
...
@@ -279,5 +298,5 @@ var api2phon = {}
for
(
let
phon
in
phon2api
)
{
if
(
!
Object
.
keys
(
api2phon
).
includes
(
phon2api
[
phon
]))
api2phon
[
phon2api
[
phon
]]
=
phon
else
console
.
log
(
"
API2PHON DOUBLON DÉTECTÉ
"
,
phon
)
//
else console.log("API2PHON DOUBLON DÉTECTÉ",phon)
}
\ No newline at end of file
static/js/playerPhono.js
View file @
8fc4ff14
const
thisAppli
=
"
phonoplayer
"
;
const
thisURL
=
window
.
location
.
href
;
var
famille
=
""
;
let
stress1ponderator
=
2
let
stress2ponderator
=
1.5
// PARAMÉTRAGE SÉRIE
var
serieId
=
sc
.
id
;
var
serieId
=
sc
.
code
;
var
serieName
=
sc
.
nom
;
var
random
=
false
// true si série de mots aléatoires
if
([
"
Englishrandom
"
].
includes
(
serieId
))
random
=
true
;
var
audioDeb
=
"
audioDeb
"
in
sc
?
sc
.
audioDeb
:
0
;
var
imageDeb
=
"
imageDeb
"
in
sc
?
sc
.
imageDeb
:
0
;
...
...
@@ -31,11 +38,14 @@ if (videoDeb==1) {
audioMode
=
true
}
selectLang
(
"
fr
"
);
if
(
sc
.
lang
)
selectLang
(
sc
.
lang
)
else
selectLang
(
"
fr
"
)
function
selectLang
(
lang
,
p
=
"
default
"
,
f
=
"
default
"
){
console
.
log
(
'
SelectLang()
'
,
lang
)
var
phonolist
=
document
.
getElementById
(
'
selectPanneau
'
)
phonolist
.
innerHTML
=
''
document
.
getElementById
(
'
stressParam
'
).
style
.
display
=
'
none !important
'
document
.
getElementById
(
'
paramSerieAuto
'
).
style
.
display
=
'
none !important
'
if
(
lang
==
"
fr
"
){
var
phonoFrDo
=
document
.
createElement
(
'
option
'
)
...
...
@@ -43,6 +53,7 @@ function selectLang(lang, p="default", f="default"){
phonoFrDo
.
innerHTML
=
"
Panneaux Fr A. Do
"
phonolist
.
appendChild
(
phonoFrDo
)
famille
=
"
bouches
"
interface
(
"
fr
"
)
}
else
if
(
lang
==
"
en
"
){
...
...
@@ -51,11 +62,14 @@ function selectLang(lang, p="default", f="default"){
phonoEnAlem
.
innerHTML
=
"
ALeM British
"
phonolist
.
appendChild
(
phonoEnAlem
)
//
var phonoEnPronSciBr = document.createElement('option')
//
phonoEnPronSciBr.value = "phonoEnPronSciBr"
//
phonoEnPronSciBr.innerHTML = "PronSci British"
//
phonolist.appendChild(phonoEnPronSciBr)
var
phonoEnPronSciBr
=
document
.
createElement
(
'
option
'
)
phonoEnPronSciBr
.
value
=
"
phonoEnPronSciBr
"
phonoEnPronSciBr
.
innerHTML
=
"
PronSci British
"
phonolist
.
appendChild
(
phonoEnPronSciBr
)
famille
=
"
formes
"
document
.
getElementById
(
'
stressParam
'
).
style
.
display
=
''
document
.
getElementById
(
'
paramSerieAuto
'
).
style
.
display
=
''
interface
(
"
en
"
)
}
selectPanneau
(
p
)
...
...
@@ -136,10 +150,24 @@ function recupPhon(identifiant) {
var
newCarte
=
document
.
createElement
(
'
div
'
)
newCarte
.
classList
=
"
carte
"
+
phonId
+
"
noTextClip
"
;
// on garde rectId, pour connaître le phonème mais sans appeler les styles de phonochromie-alem.css
newCarte
.
draggable
=
true
let
ponderateur
=
1
// pondérateur de taille pour stress
if
(
stress1
)
{
ponderateur
=
stress1ponderator
newCarte
.
classList
.
add
(
'
stress1
'
)
setStress
(
0
)
}
else
if
(
stress2
)
{
ponderateur
=
stress2ponderator
newCarte
.
classList
.
add
(
'
stress2
'
)
setStress
(
0
)
}
if
(
phonId
.
includes
(
'
phon_schw
'
))
newCarte
.
classList
.
add
(
'
schwa
'
)
if
(
!
identifiant
.
match
(
/espace/
))
{
var
newCarteIn
=
document
.
createElement
(
'
div
'
)
newCarteIn
.
classList
=
"
carteIn
"
newCarteIn
.
style
.
backgroundImage
=
`url('../../../media/phonocartes/do_
${
famille
}
/
${
phonId
}
.png')`
;
//"url('/static/cartes/"+ famille +"/"+ phonId + ".jpg')"}
newCarteIn
.
style
.
backgroundImage
=
`url('../../../media/phonocartes/do_
${
famille
}
/
${
phonId
}
.png')`
+
`, url('../../../media/phonocartes/do_formes/
${
phonId
}
.png')`
;
//"url('/static/cartes/"+ famille +"/"+ phonId + ".jpg')"}
newCarte
.
appendChild
(
newCarteIn
)
}
...
...
@@ -210,28 +238,33 @@ function demarrer() {
// charge le mot suivant
function
loadNext
()
{
document
.
getElementById
(
"
bravo
"
).
style
.
display
=
"
none
"
if
(
cptitem
<
nbmots
)
{
saveTrace
(
`next
${
mots
[
cptitem
][
"
motGenerique
"
]}
`
)
rep
.
innerHTML
=
""
currentAudio
=
mots
[
cptitem
][
"
audio
"
]
||
mots
[
cptitem
][
'
audioDeb
'
]
currentVideo
=
mots
[
cptitem
][
"
video
"
]
||
mots
[
cptitem
][
'
videoDeb
'
]
currentAudioFin
=
mots
[
cptitem
][
"
audio_R
"
]
||
mots
[
cptitem
][
"
audioFin
"
]
if
(
audioDeb
==
1
&&
currentAudio
.
length
>
0
)
{
playAudio
()
}
if
(
videoDeb
==
1
&&
currentVideo
.
length
>
0
)
{
document
.
getElementById
(
'
videoSrc
'
).
src
=
'
../../media/video-uploads/
'
+
currentVideo
document
.
getElementById
(
'
video
'
).
load
()
playVideo
()
}
cptitem
=
cptitem
+
1
document
.
getElementById
(
'
cptitem
'
).
innerHTML
=
cptitem
if
(
random
)
{
randomWord
()
}
else
{
getFelicitations
()
playEffect
(
"
success
"
)
saveTrace
(
`end serie
${
serieName
}
`
)
}
if
(
cptitem
<
nbmots
)
{
saveTrace
(
`next
${
mots
[
cptitem
][
"
motGenerique
"
]}
`
)
rep
.
innerHTML
=
""
currentAudio
=
"
../../media/audio-uploads/
"
+
(
mots
[
cptitem
][
"
audio
"
]
||
mots
[
cptitem
][
'
audioDeb
'
])
currentVideo
=
mots
[
cptitem
][
"
video
"
]
||
mots
[
cptitem
][
'
videoDeb
'
]
currentAudioFin
=
mots
[
cptitem
][
"
audio_R
"
]
||
mots
[
cptitem
][
"
audioFin
"
]
if
(
audioDeb
==
1
&&
currentAudio
.
length
>
0
)
{
playAudio
()
}
if
(
videoDeb
==
1
&&
currentVideo
.
length
>
0
)
{
document
.
getElementById
(
'
videoSrc
'
).
src
=
'
../../media/video-uploads/
'
+
currentVideo
document
.
getElementById
(
'
video
'
).
load
()
playVideo
()
}
cptitem
=
cptitem
+
1
document
.
getElementById
(
'
cptitem
'
).
innerHTML
=
cptitem
}
else
{
getFelicitations
()
playEffect
(
"
success
"
)
saveTrace
(
`end serie
${
serieName
}
`
)
}
}
}
// vérifie la réponse
...
...
@@ -248,7 +281,11 @@ function checkAnswer() {
if
(
el
.
classList
.
contains
(
"
delPhon
"
))
rep
.
removeChild
(
el
);
})
rep
.
childNodes
.
forEach
((
el
)
=>
{
myrep
.
push
(
el
.
classList
[
1
].
replace
(
"
rect
"
,
"
phon
"
));
var
phonclass
=
el
.
classList
[
1
].
replace
(
"
rect
"
,
"
phon
"
)
if
([...
el
.
classList
].
includes
(
'
stress1
'
))
phonclass
+=
'
stress1
'
else
if
([...
el
.
classList
].
includes
(
'
stress2
'
))
phonclass
+=
'
stress2
'
else
if
([...
el
.
classList
].
includes
(
'
schwa
'
))
phonclass
+=
'
schwa
'
myrep
.
push
(
phonclass
);
})
console
.
log
(
"
myrep:
"
,
myrep
)
...
...
@@ -338,6 +375,7 @@ function initAnswer(x=0) {
repx
.
innerHTML
=
""
;
document
.
querySelectorAll
(
'
.divReponseMilieu
'
)[
x
].
appendChild
(
repx
)
}
if
(
!
document
.
body
.
contains
(
document
.
getElementById
(
'
rep
'
)))
document
.
querySelector
(
'
.divReponseMilieu
'
).
innerHTML
=
`<div id="rep" class="d-flex align-items-center flex-wrap rep"></div>`
}
function
compareRepRef
(
myrep
,
ref
)
{
...
...
@@ -345,8 +383,7 @@ function compareRepRef(myrep, ref) {
// PREPARATION
// On commence par faire une table au format suivant :
// (r e p)
//
// (r e p)
// 0 1 2 3
// (r 1 0 0 0
// e 2 0 0 0
...
...
@@ -471,7 +508,7 @@ function getFelicitations() {
// SOUNDS
function
playAudio
()
{
var
audio
=
new
Audio
(
"
../../media/audio-uploads/
"
+
currentAudio
)
var
audio
=
new
Audio
(
currentAudio
)
audio
.
play
()
saveTrace
(
"
playAudio
"
)
}
...
...
@@ -619,4 +656,47 @@ function newLine(el){
el
.
parentElement
.
parentElement
.
parentElement
.
insertBefore
(
newLine
,
el
.
parentElement
.
parentElement
.
nextElementSibling
)
changeLigne
(
newLine
.
firstElementChild
)
}
// GESTION DU STRESS
let
stress1
=
false
let
stress2
=
false
function
setStress
(
nb
){
if
(
nb
==
0
)
{
// On passe tout à 0 sans se poser de question
stress1
=
false
document
.
getElementById
(
'
stress1
'
).
classList
.
remove
(
'
stressOn
'
)
stress2
=
false
document
.
getElementById
(
'
stress2
'
).
classList
.
remove
(
'
stressOn
'
)
}
else
if
(
nb
==
1
)
{
if
(
!
stress1
)
{
// Si stress1 n'est pas encore actif
stress1
=
true
document
.
getElementById
(
'
stress1
'
).
classList
.
add
(
'
stressOn
'
)
}
else
{
// Si stress1 est déjà actif : on passe à 0
stress1
=
false
document
.
getElementById
(
'
stress1
'
).
classList
.
remove
(
'
stressOn
'
)
}
stress2
=
false
document
.
getElementById
(
'
stress2
'
).
classList
.
remove
(
'
stressOn
'
)
}
else
if
(
nb
==
2
)
{
stress1
=
false
document
.
getElementById
(
'
stress1
'
).
classList
.
remove
(
'
stressOn
'
)
if
(
!
stress2
)
{
stress2
=
true
document
.
getElementById
(
'
stress2
'
).
classList
.
add
(
'
stressOn
'
)
}
else
{
stress2
=
false
document
.
getElementById
(
'
stress2
'
).
classList
.
remove
(
'
stressOn
'
)
}
}
}
\ No newline at end of file
static/js/playerPhonoAuto.js
0 → 100644
View file @
8fc4ff14
// Fonctions utilisées par le player automatique (suggestion de mots aléatoires)
async
function
getPhono
(
mot
)
{
// OUTPUT: "outText": liste(mots) de liste(phonologies) de liste(phonemes) [+stress1,stress2,schwa]
var
colis
=
{
inText
:
mot
,
lang
:
thisPageLang
}
// Paramètres d'envoi
const
options
=
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
colis
)
};
// ENVOI
const
response
=
await
fetch
(
'
https://wikicolor.alem-app.fr/getPhonoOf/
'
,
options
);
//'http://127.0.0.1:9000/getPhonoOf/', options); //
const
data
=
await
response
.
json
();
console
.
log
(
data
);
return
data
}
async
function
getWikiAudio
(
mot
)
{
// OUTPUT: urls: [ ["uk","https://...mot.ogg"], ["us", "https://...mot.ogg"], ...]
var
colis
=
{
inText
:
mot
,
lang
:
thisPageLang
}
// Paramètres d'envoi
const
options
=
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
colis
)
};
// ENVOI
const
response
=
await
fetch
(
'
/player/getWikiAudio/
'
,
options
);
const
data
=
await
response
.
json
();
console
.
log
(
data
);
return
data
}
async
function
getWord
(
mot
)
{
var
urls
=
[]
var
phono
=
[]
var
urlsOK
=
false
var
phonoOK
=
false
await
getWikiAudio
(
mot
).
then
(
result
=>
{
urls
=
result
[
'
urls
'
];
if
(
urls
.
length
>
0
)
{
urlsOK
=
true
}
})
await
getPhono
(
mot
).
then
(
result
=>
{
phono
=
result
[
'
outText
'
];
if
(
phono
[
0
][
0
][
0
]
!=
"
phon_inconnu
"
)
{
phonoOK
=
true
}
})
if
(
urlsOK
&&
phonoOK
)
return
[
urls
,
phono
]
else
return
null
}
function
loadWord
(
mot
)
{
getWord
(
mot
).
then
(
w
=>
{
console
.
log
(
'
RESULT
'
,
w
);
if
(
w
)
{
[
urls
,
phono
]
=
w
mots
[
0
].
motGenerique
=
mot
mots
[
0
].
phono
=
phono
[
0
]
mots
[
0
].
audioDeb
=
urls
cptitem
=
0
loadNextAuto
()
}
else
{
randomWord
()
}
})
}
// charge le mot suivant (mode automatique)
function
loadNextAuto
()
{
document
.
getElementById
(
"
bravo
"
).
style
.
display
=
"
none
"
saveTrace
(
`next
${
mots
[
cptitem
][
"
motGenerique
"
]}
`
)
rep
.
innerHTML
=
""
var
ukOK
=
false
;
for
(
url
of
urls
)
{
if
(
!
ukOK
&&
[
"
uk
"
,
"
gb
"
,
"
rp
"
].
includes
(
url
[
0
]))
{
currentAudio
=
url
[
1
]
playAudio
()
ukOK
=
true
}
}
if
(
!
ukOK
)
{
currentAudio
=
urls
[
0
][
1
]
playAudio
()
}
cptitem
=
cptitem
+
1
document
.
getElementById
(
'
cptitem
'
).
innerHTML
=
cptitem
}