Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ff2balex
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lex gaMe
ff2balex
Commits
72231105
Commit
72231105
authored
4 months ago
by
Prénom Nom
Browse files
Options
Downloads
Patches
Plain Diff
affichage pos + transcription phon. dans sidebar
parent
aaa953f3
No related branches found
Branches containing commit
No related tags found
1 merge request
!9
Affichage stats
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/definitions.js
+212
-112
212 additions, 112 deletions
src/utils/definitions.js
with
212 additions
and
112 deletions
src/utils/definitions.js
+
212
−
112
View file @
72231105
...
@@ -77,7 +77,7 @@ async function fetchLexiconDefinitions(word) {
...
@@ -77,7 +77,7 @@ async function fetchLexiconDefinitions(word) {
const
results
=
await
Promise
.
all
(
definitionsPromises
);
const
results
=
await
Promise
.
all
(
definitionsPromises
);
// 3) Parcourir les résultats et extraire les définitions
// 3) Parcourir les résultats et extraire les définitions
+ prononciations
let
allDefinitions
=
[];
let
allDefinitions
=
[];
results
.
forEach
(
result
=>
{
results
.
forEach
(
result
=>
{
log
(
`Pour le lexique
${
result
.
lexiconId
}
, entrées filtrées :`
,
result
.
entries
);
log
(
`Pour le lexique
${
result
.
lexiconId
}
, entrées filtrées :`
,
result
.
entries
);
...
@@ -98,6 +98,13 @@ async function fetchLexiconDefinitions(word) {
...
@@ -98,6 +98,13 @@ async function fetchLexiconDefinitions(word) {
items
.
forEach
(
item
=>
{
items
.
forEach
(
item
=>
{
const
definitionsArray
=
item
.
Sense
?.
Definitions
;
const
definitionsArray
=
item
.
Sense
?.
Definitions
;
const
pronunciationsArray
=
item
.
Sense
?.
Pronunciations
;
let
pronunciations
=
[];
if
(
Array
.
isArray
(
pronunciationsArray
))
{
pronunciations
=
pronunciationsArray
.
map
(
p
=>
p
.
Transcription
).
filter
(
p
=>
p
);
}
if
(
!
Array
.
isArray
(
definitionsArray
))
return
;
if
(
!
Array
.
isArray
(
definitionsArray
))
return
;
definitionsArray
.
forEach
(
defObj
=>
{
definitionsArray
.
forEach
(
defObj
=>
{
...
@@ -105,6 +112,7 @@ async function fetchLexiconDefinitions(word) {
...
@@ -105,6 +112,7 @@ async function fetchLexiconDefinitions(word) {
allDefinitions
.
push
({
allDefinitions
.
push
({
source
:
sourceName
,
source
:
sourceName
,
text
:
defObj
.
Def
,
text
:
defObj
.
Def
,
pronunciations
:
pronunciations
,
lexiconId
:
lexiconId
lexiconId
:
lexiconId
});
});
}
}
...
@@ -112,14 +120,13 @@ async function fetchLexiconDefinitions(word) {
...
@@ -112,14 +120,13 @@ async function fetchLexiconDefinitions(word) {
});
});
});
});
});
});
log
(
"
Résultat final filtré :
"
,
allDefinitions
);
log
(
"
Résultat final filtré :
"
,
allDefinitions
);
return
allDefinitions
;
return
allDefinitions
;
}
catch
(
error
)
{
}
catch
(
error
)
{
log
(
"
❌ Erreur générale lors de la récupération des définitions :
"
,
error
);
log
(
"
❌ Erreur générale lors de la récupération des définitions :
"
,
error
);
return
[];
return
[];
}
}
}
}
/**
/**
* Récupère la définition d'un mot depuis le Wiktionnaire (fr).
* Récupère la définition d'un mot depuis le Wiktionnaire (fr).
...
@@ -130,11 +137,19 @@ async function fetchWiktionaryDefinition(word) {
...
@@ -130,11 +137,19 @@ async function fetchWiktionaryDefinition(word) {
const
result
=
await
browser
.
storage
.
local
.
get
(
"
accessToken
"
);
const
result
=
await
browser
.
storage
.
local
.
get
(
"
accessToken
"
);
authToken
=
result
.
accessToken
;
authToken
=
result
.
accessToken
;
// 🔹 Initialisation d'une structure vide pour éviter les erreurs
let
formattedData
=
{
definitions
:
[],
pronunciations
:
[],
definitionsByPOS
:
{}
// Pour stocker les définitions triées par POS
};
if
(
!
authToken
)
{
if
(
!
authToken
)
{
log
(
`🔍 Requête Wiktionnaire pour "
${
word
}
"...`
);
log
(
`🔍 Requête Wiktionnaire pour "
${
word
}
"...`
);
if
(
!
word
||
word
.
trim
()
===
""
)
{
if
(
!
word
||
word
.
trim
()
===
""
)
{
throw
new
Error
(
"
⚠️ Mot vide, impossible d'envoyer la requête.
"
);
throw
new
Error
(
"
⚠️ Mot vide, impossible d'envoyer la requête.
"
);
}
}
const
wiktionaryURL
=
`https://fr.wiktionary.org/w/api.php?action=query&format=json&origin=*&prop=extracts&explaintext=true&redirects=1&titles=
${
encodeURIComponent
(
word
)}
`
;
const
wiktionaryURL
=
`https://fr.wiktionary.org/w/api.php?action=query&format=json&origin=*&prop=extracts&explaintext=true&redirects=1&titles=
${
encodeURIComponent
(
word
)}
`
;
const
response
=
await
fetch
(
wiktionaryURL
);
const
response
=
await
fetch
(
wiktionaryURL
);
if
(
!
response
.
ok
)
{
if
(
!
response
.
ok
)
{
...
@@ -145,17 +160,19 @@ async function fetchWiktionaryDefinition(word) {
...
@@ -145,17 +160,19 @@ async function fetchWiktionaryDefinition(word) {
const
pages
=
data
.
query
?.
pages
;
const
pages
=
data
.
query
?.
pages
;
const
page
=
pages
?
Object
.
values
(
pages
)[
0
]
:
null
;
const
page
=
pages
?
Object
.
values
(
pages
)[
0
]
:
null
;
const
definitionText
=
page
&&
page
.
extract
?
page
.
extract
.
trim
()
:
"
⚠️ Aucune définition trouvée sur le Wiktionnaire.
"
;
log
(
"
🌍 Définition Wiktionnaire extraite :
"
,
definitionText
);
formattedData
.
definitions
=
page
&&
page
.
extract
?
[
page
.
extract
.
trim
()]
:
[
"
⚠️ Aucune définition trouvée sur le Wiktionnaire.
"
];
log
(
"
🌍 Définition Wiktionnaire extraite :
"
,
formattedData
.
definitions
);
return
[
return
[
{
{
source
:
"
Wiktionnaire
"
,
source
:
"
Wiktionnaire
"
,
text
:
definitionText
text
:
formattedData
.
definitions
.
join
(
"
|
"
),
pronunciations
:
formattedData
.
pronunciations
,
definitionsByPOS
:
formattedData
.
definitionsByPOS
}
}
];
];
}
else
{
}
else
{
...
@@ -166,27 +183,47 @@ async function fetchWiktionaryDefinition(word) {
...
@@ -166,27 +183,47 @@ async function fetchWiktionaryDefinition(word) {
log
(
"
Réponse brute de l'API :
"
,
apiResponse
);
log
(
"
Réponse brute de l'API :
"
,
apiResponse
);
if
(
!
Array
.
isArray
(
apiResponse
)
||
apiResponse
.
length
===
0
)
{
if
(
!
Array
.
isArray
(
apiResponse
)
||
apiResponse
.
length
===
0
)
{
console
.
warn
(
`Aucune définition trouvée pour "
${
word
}
"`
);
console
.
warn
(
`Aucune définition trouvée pour "
${
word
}
"`
);
return
[];
// Retourne un tableau vide si aucune définition
return
[];
// Retourne un tableau vide si aucune définition
}
}
// Formatage des données
// 🛠 Formatage des données récupérées
const
formattedData
=
formatDefinitionData
(
apiResponse
);
formattedData
=
formatDefinitionData
(
apiResponse
);
log
(
"
Données formatées :
"
,
formattedData
);
log
(
"
Données formatées :
"
,
formattedData
);
// Vérification avant retour
if
(
!
formattedData
.
definitions
)
{
formattedData
.
definitions
=
[];
// 🔹 Toujours s'assurer que cette clé existe
}
if
(
!
formattedData
.
pronunciations
)
{
formattedData
.
pronunciations
=
[];
// 🔹 Toujours s'assurer que cette clé existe
}
if
(
!
formattedData
.
definitionsByPOS
)
{
formattedData
.
definitionsByPOS
=
{};
// 🔹 Toujours s'assurer que cette clé existe
}
return
[
return
[
{
{
source
:
"
Wiktionnaire
"
,
source
:
"
Wiktionnaire
"
,
text
:
formattedData
.
definitions
.
length
>
0
?
formattedData
.
definitions
.
join
(
"
|
"
)
:
"
⚠️ Aucune définition disponible.
"
text
:
formattedData
.
definitions
.
length
>
0
?
formattedData
.
definitions
.
join
(
"
|
"
)
:
"
Aucune définition disponible.
"
,
}
pronunciations
:
formattedData
.
pronunciations
,
definitionsByPOS
:
formattedData
.
definitionsByPOS
}
];
];
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
log
(
"
❌ Erreur lors de la récupération de la définition :
"
,
error
);
log
(
"
❌ Erreur lors de la récupération de la définition :
"
,
error
);
return
[{
source
:
"
Wiktionnaire
"
,
text
:
"
Erreur lors de la récupération sur le Wiktionnaire.
"
}];
return
[{
source
:
"
Wiktionnaire
"
,
text
:
"
Erreur lors de la récupération sur le Wiktionnaire.
"
,
pronunciations
:
[],
definitionsByPOS
:
{}
}];
}
}
}
}
async
function
wikiApiResponse
(
word
)
{
async
function
wikiApiResponse
(
word
)
{
const
result
=
await
browser
.
storage
.
local
.
get
(
"
accessToken
"
);
const
result
=
await
browser
.
storage
.
local
.
get
(
"
accessToken
"
);
authToken
=
result
.
accessToken
;
authToken
=
result
.
accessToken
;
...
@@ -219,47 +256,71 @@ async function wikiApiResponse(word) {
...
@@ -219,47 +256,71 @@ async function wikiApiResponse(word) {
function
formatDefinitionData
(
apiResponse
)
{
function
formatDefinitionData
(
apiResponse
)
{
let
formattedData
=
{
let
formattedData
=
{
word
:
apiResponse
[
0
]?.
id
.
split
(
"
-
"
).
slice
(
2
).
join
(
"
-
"
)
||
""
,
word
:
apiResponse
[
0
]?.
id
.
split
(
"
-
"
).
slice
(
2
).
join
(
"
-
"
)
||
""
,
pronunciations
:
[],
pronunciations
:
new
Set
(),
// Utilisation d'un Set pour éviter les doublons
definitions
:
[],
definitionsByPOS
:
{}
// Organisation par catégorie grammaticale
examples
:
[],
translations
:
{},
};
};
apiResponse
.
forEach
(
entry
=>
{
apiResponse
.
forEach
(
entry
=>
{
const
wordData
=
entry
[
entry
.
id
.
split
(
"
.
"
).
slice
(
-
1
)[
0
]];
// Accéder aux données via la clé dynamique
const
wordData
=
entry
[
entry
.
id
.
split
(
"
.
"
).
slice
(
-
1
)[
0
]];
// Accès aux données via clé dynamique
const
pos
=
wordData
.
pos
||
"
Autre
"
;
// Définit le POS ou "Autre" si absent
if
(
!
formattedData
.
definitionsByPOS
[
pos
])
{
formattedData
.
definitionsByPOS
[
pos
]
=
{
definitions
:
[],
examples
:
[],
pronunciations
:
new
Set
()
};
}
// Ajout des prononciations
// Ajout des prononciations
globales en extrayant les transcriptions valides
if
(
wordData
.
pronunciations
)
{
if
(
wordData
.
pronunciations
)
{
formattedData
.
pronunciations
.
push
(...
wordData
.
pronunciations
);
wordData
.
pronunciations
.
forEach
(
pron
=>
{
if
(
pron
.
transcript
)
{
formattedData
.
pronunciations
.
add
(
pron
.
transcript
);
}
});
}
}
// Ajout des définitions
// Ajout des prononciations spécifiques au POS
if
(
wordData
.
pronunciations
)
{
wordData
.
pronunciations
.
forEach
(
pron
=>
{
if
(
pron
.
transcript
)
{
formattedData
.
definitionsByPOS
[
pos
].
pronunciations
.
add
(
pron
.
transcript
);
}
});
}
// Ajout des définitions et des exemples
if
(
wordData
.
senses
)
{
if
(
wordData
.
senses
)
{
for
(
let
senseKey
in
wordData
.
senses
)
{
for
(
let
senseKey
in
wordData
.
senses
)
{
let
sense
=
wordData
.
senses
[
senseKey
];
let
sense
=
wordData
.
senses
[
senseKey
];
if
(
sense
.
Definitions
)
{
if
(
sense
.
Definitions
)
{
formattedData
.
definitions
.
push
(...
sense
.
Definitions
.
map
(
d
=>
d
.
definition
));
formattedData
.
definitionsByPOS
[
pos
].
definitions
.
push
(
...
sense
.
Definitions
.
map
(
d
=>
d
.
definition
)
);
}
}
if
(
sense
.
Examples
)
{
if
(
sense
.
Examples
)
{
formattedData
.
examples
.
push
(...
sense
.
Examples
.
map
(
e
=>
e
.
example
));
formattedData
.
definitionsByPOS
[
pos
].
examples
.
push
(
...
sense
.
Examples
.
map
(
e
=>
e
.
example
)
);
}
}
}
}
}
}
});
// Ajout des traductions
// Convertir les Sets en Arrays
if
(
entry
.
translations
)
{
formattedData
.
pronunciations
=
[...
formattedData
.
pronunciations
];
entry
.
translations
.
forEach
(
translation
=>
{
Object
.
keys
(
formattedData
.
definitionsByPOS
).
forEach
(
pos
=>
{
if
(
!
formattedData
.
translations
[
translation
.
lang_name
])
{
formattedData
.
definitionsByPOS
[
pos
].
pronunciations
=
[...
formattedData
.
definitionsByPOS
[
pos
].
pronunciations
];
formattedData
.
translations
[
translation
.
lang_name
]
=
[];
}
formattedData
.
translations
[
translation
.
lang_name
].
push
(
translation
.
sense
);
});
}
});
});
return
formattedData
;
return
formattedData
;
}
}
// ─────────────────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────────────────
// ▌ Affichage des définitions dans la barre latérale
// ▌ Affichage des définitions dans la barre latérale
// ─────────────────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────────────────
...
@@ -278,99 +339,138 @@ function displayDefinitions(definitions) {
...
@@ -278,99 +339,138 @@ function displayDefinitions(definitions) {
const
noLexiconDefinitionsContainer
=
document
.
getElementById
(
"
noLexiconDefinitionsContainer
"
);
const
noLexiconDefinitionsContainer
=
document
.
getElementById
(
"
noLexiconDefinitionsContainer
"
);
const
noWiktionaryDefinitionsContainer
=
document
.
getElementById
(
"
noWiktionaryDefinitionsContainer
"
);
const
noWiktionaryDefinitionsContainer
=
document
.
getElementById
(
"
noWiktionaryDefinitionsContainer
"
);
// Nettoyage des listes existantes
mesLexiquesList
.
innerHTML
=
""
;
mesLexiquesList
.
innerHTML
=
""
;
wiktionnaireList
.
innerHTML
=
""
;
wiktionnaireList
.
innerHTML
=
""
;
// Masquer les sections vides par défaut
if
(
noLexiconDefinitionsContainer
)
noLexiconDefinitionsContainer
.
style
.
display
=
"
none
"
;
if
(
noLexiconDefinitionsContainer
)
noLexiconDefinitionsContainer
.
style
.
display
=
"
none
"
;
if
(
noWiktionaryDefinitionsContainer
)
noWiktionaryDefinitionsContainer
.
style
.
display
=
"
none
"
;
if
(
noWiktionaryDefinitionsContainer
)
noWiktionaryDefinitionsContainer
.
style
.
display
=
"
none
"
;
let
hasLexiconDefinitions
=
false
;
let
hasLexiconDefinitions
=
false
;
let
hasWiktionaryDefinitions
=
false
;
let
hasWiktionaryDefinitions
=
false
;
const
lexiconGroups
=
{};
const
lexiconGroups
=
{};
definitions
.
forEach
(({
source
,
text
})
=>
{
definitions
.
forEach
(({
source
,
text
,
definitionsByPOS
})
=>
{
if
(
!
source
||
!
text
)
return
;
if
(
!
source
||
!
definitionsByPOS
)
return
;
const
li
=
document
.
createElement
(
"
li
"
);
const
definitionContainer
=
document
.
createElement
(
"
div
"
);
let
displayedText
=
text
;
definitionContainer
.
classList
.
add
(
"
definition-item
"
);
if
(
text
.
length
>
MAX_LENGTH
)
{
// 🔊 1. Affichage des prononciations globales si disponibles
displayedText
=
text
.
slice
(
0
,
MAX_LENGTH
)
+
"
...
"
;
const
allPronunciations
=
new
Set
();
const
readMoreLink
=
document
.
createElement
(
"
a
"
);
Object
.
values
(
definitionsByPOS
).
forEach
(
posData
=>
{
readMoreLink
.
href
=
"
#
"
;
posData
.
pronunciations
.
forEach
(
pron
=>
allPronunciations
.
add
(
pron
));
readMoreLink
.
textContent
=
"
[Lire la suite]
"
;
readMoreLink
.
style
.
marginLeft
=
"
5px
"
;
readMoreLink
.
style
.
color
=
"
#8d5c70
"
;
readMoreLink
.
style
.
textDecoration
=
"
underline
"
;
readMoreLink
.
style
.
cursor
=
"
pointer
"
;
readMoreLink
.
addEventListener
(
"
click
"
,
(
event
)
=>
{
event
.
preventDefault
();
openDefinitionPopup
(
text
);
});
});
li
.
appendChild
(
document
.
createTextNode
(
displayedText
));
li
.
appendChild
(
readMoreLink
);
}
else
{
li
.
textContent
=
displayedText
;
}
// Vérifier la source : Wiktionnaire/Lexiques
if
(
allPronunciations
.
size
>
0
)
{
if
(
source
===
"
Wiktionnaire
"
)
{
const
pronDiv
=
document
.
createElement
(
"
div
"
);
wiktionnaireList
.
appendChild
(
li
);
pronDiv
.
style
.
fontWeight
=
"
bold
"
;
hasWiktionaryDefinitions
=
true
;
pronDiv
.
style
.
color
=
"
#94608a
"
;
}
else
{
pronDiv
.
style
.
marginBottom
=
"
5px
"
;
if
(
!
lexiconGroups
[
source
])
{
pronDiv
.
textContent
=
`Prononciations possibles :
${[...
allPronunciations
].
join
(
"
,
"
)}
`
;
lexiconGroups
[
source
]
=
[];
definitionContainer
.
appendChild
(
pronDiv
);
}
// 2. Affichage des définitions triées par POS
Object
.
entries
(
definitionsByPOS
).
forEach
(([
pos
,
posData
])
=>
{
if
(
posData
.
definitions
.
length
===
0
)
return
;
// Évite les POS vides
// Titre du POS
const
posTitle
=
document
.
createElement
(
"
h4
"
);
posTitle
.
style
.
marginTop
=
"
10px
"
;
posTitle
.
style
.
color
=
"
#e3e3e3
"
;
posTitle
.
textContent
=
`
${
pos
.
toUpperCase
()}
`
;
definitionContainer
.
appendChild
(
posTitle
);
// Prononciations spécifiques au POS
if
(
posData
.
pronunciations
.
length
>
0
)
{
const
posPronDiv
=
document
.
createElement
(
"
div
"
);
posPronDiv
.
style
.
fontStyle
=
"
italic
"
;
posPronDiv
.
style
.
color
=
"
#94608a
"
;
// posPronDiv.textContent = `${posData.pronunciations.join(", ")}`;
// definitionContainer.appendChild(posPronDiv);
}
// Liste des définitions
const
defList
=
document
.
createElement
(
"
ul
"
);
defList
.
style
.
margin
=
"
0
"
;
defList
.
style
.
paddingLeft
=
"
20px
"
;
posData
.
definitions
.
forEach
(
def
=>
{
const
li
=
document
.
createElement
(
"
li
"
);
// 3. Gestion du bouton "Lire la suite"
let
displayedText
=
def
.
trim
();
if
(
displayedText
.
length
>
MAX_LENGTH
)
{
const
truncatedText
=
displayedText
.
slice
(
0
,
MAX_LENGTH
)
+
"
...
"
;
const
readMoreLink
=
document
.
createElement
(
"
a
"
);
readMoreLink
.
href
=
"
#
"
;
readMoreLink
.
textContent
=
"
[Lire la suite]
"
;
readMoreLink
.
style
.
marginLeft
=
"
5px
"
;
readMoreLink
.
style
.
color
=
"
#8d5c70
"
;
readMoreLink
.
style
.
textDecoration
=
"
underline
"
;
readMoreLink
.
style
.
cursor
=
"
pointer
"
;
readMoreLink
.
addEventListener
(
"
click
"
,
(
event
)
=>
{
event
.
preventDefault
();
openDefinitionPopup
(
displayedText
);
});
li
.
appendChild
(
document
.
createTextNode
(
truncatedText
));
li
.
appendChild
(
readMoreLink
);
}
else
{
li
.
textContent
=
displayedText
;
}
defList
.
appendChild
(
li
);
});
definitionContainer
.
appendChild
(
defList
);
});
// 4. Ajout dans la bonne section (Lexique ou Wiktionnaire)
if
(
source
===
"
Wiktionnaire
"
)
{
wiktionnaireList
.
appendChild
(
definitionContainer
);
hasWiktionaryDefinitions
=
true
;
}
else
{
if
(
!
lexiconGroups
[
source
])
{
lexiconGroups
[
source
]
=
[];
}
lexiconGroups
[
source
].
push
(
definitionContainer
);
hasLexiconDefinitions
=
true
;
}
}
lexiconGroups
[
source
].
push
(
li
);
hasLexiconDefinitions
=
true
;
}
});
});
// 5. Gestion des groupes de lexiques personnels
Object
.
entries
(
lexiconGroups
).
forEach
(([
lexiconName
,
definitionItems
])
=>
{
Object
.
entries
(
lexiconGroups
).
forEach
(([
lexiconName
,
definitionItems
])
=>
{
const
lexiconContainer
=
document
.
createElement
(
"
div
"
);
const
lexiconContainer
=
document
.
createElement
(
"
div
"
);
lexiconContainer
.
className
=
"
lexicon-section
"
;
lexiconContainer
.
className
=
"
lexicon-section
"
;
const
lexiconHeader
=
document
.
createElement
(
"
div
"
);
const
lexiconHeader
=
document
.
createElement
(
"
div
"
);
lexiconHeader
.
className
=
"
lexicon-header
"
;
lexiconHeader
.
className
=
"
lexicon-header
"
;
lexiconHeader
.
textContent
=
lexiconName
;
lexiconHeader
.
textContent
=
lexiconName
;
lexiconHeader
.
addEventListener
(
"
click
"
,
()
=>
{
lexiconHeader
.
addEventListener
(
"
click
"
,
()
=>
{
lexiconContent
.
classList
.
toggle
(
"
hidden
"
);
lexiconContent
.
classList
.
toggle
(
"
hidden
"
);
});
});
const
lexiconContent
=
document
.
createElement
(
"
ul
"
);
const
lexiconContent
=
document
.
createElement
(
"
div
"
);
lexiconContent
.
className
=
"
lexicon-content hidden
"
;
lexiconContent
.
className
=
"
lexicon-content hidden
"
;
definitionItems
.
forEach
(
l
i
=>
lexiconContent
.
appendChild
(
l
i
));
definitionItems
.
forEach
(
i
tem
=>
lexiconContent
.
appendChild
(
i
tem
));
lexiconContainer
.
appendChild
(
lexiconHeader
);
lexiconContainer
.
appendChild
(
lexiconHeader
);
lexiconContainer
.
appendChild
(
lexiconContent
);
lexiconContainer
.
appendChild
(
lexiconContent
);
mesLexiquesList
.
appendChild
(
lexiconContainer
);
mesLexiquesList
.
appendChild
(
lexiconContainer
);
});
});
if
(
!
hasLexiconDefinitions
&&
noLexiconDefinitionsContainer
)
{
// 6. Gestion des sections vides
if
(
!
authToken
)
{
noLexiconDefinitionsContainer
.
textContent
=
"
Veuillez vous connecter pour accéder aux définitions de vos lexiques.
"
;
noLexiconDefinitionsContainer
.
style
.
textAlign
=
"
center
"
;
noLexiconDefinitionsContainer
.
style
.
fontStyle
=
"
italic
"
;
}
else
{
noLexiconDefinitionsContainer
.
textContent
=
"
Aucune définition trouvée dans les lexiques.
"
;
}
noLexiconDefinitionsContainer
.
style
.
display
=
"
block
"
;
}
if
(
!
hasWiktionaryDefinitions
&&
noWiktionaryDefinitionsContainer
)
{
if
(
!
hasWiktionaryDefinitions
&&
noWiktionaryDefinitionsContainer
)
{
noWiktionaryDefinitionsContainer
.
style
.
display
=
"
block
"
;
noWiktionaryDefinitionsContainer
.
style
.
display
=
"
block
"
;
}
const
mesLexiquesContainer
=
document
.
getElementById
(
"
mesLexiquesContainer
"
);
if
(
mesLexiquesContainer
)
{
mesLexiquesContainer
.
style
.
display
=
hasLexiconDefinitions
?
"
block
"
:
"
none
"
;
}
const
wiktionnaireContainer
=
document
.
getElementById
(
"
wiktionnaireContainer
"
);
if
(
wiktionnaireContainer
)
{
wiktionnaireContainer
.
style
.
display
=
hasWiktionaryDefinitions
?
"
block
"
:
"
none
"
;
}
}
}
}
// ─────────────────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────────────────
// ▌ Gestion du popup pour afficher la définition complète du Wiktionnaire
// ▌ Gestion du popup pour afficher la définition complète du Wiktionnaire
// ─────────────────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────────────────
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment