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
99ef6749
Commit
99ef6749
authored
4 months ago
by
Lucie Bader
Browse files
Options
Downloads
Patches
Plain Diff
Correction beugs
parent
40623938
No related branches found
No related tags found
2 merge requests
!8
Test final
,
!5
Ajout manuel d'un mot dans un ou plusieurs lexique(s)
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
manifest.json
+1
-1
1 addition, 1 deletion
manifest.json
src/assets/lexicon_icon.js
+19
-10
19 additions, 10 deletions
src/assets/lexicon_icon.js
src/background/background.js
+9
-1
9 additions, 1 deletion
src/background/background.js
src/sidebar/sidebar.js
+1
-1
1 addition, 1 deletion
src/sidebar/sidebar.js
with
30 additions
and
13 deletions
manifest.json
+
1
−
1
View file @
99ef6749
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
"src/sidebar/sidebar.js"
,
"src/sidebar/sidebar.js"
,
"src/context_menu/custom_context_menu.js"
],
"src/context_menu/custom_context_menu.js"
],
"css"
:
[
"src/context_menu/custom_context_menu.css"
],
"css"
:
[
"src/context_menu/custom_context_menu.css"
],
"run_at"
:
"document_
end
"
"run_at"
:
"document_
idle
"
}
}
],
],
...
...
This diff is collapsed.
Click to expand it.
src/assets/lexicon_icon.js
+
19
−
10
View file @
99ef6749
console
.
log
(
"
lexicon_icon.js chargé
"
);
console
.
log
(
"
lexicon_icon.js chargé
"
);
/**
/**
*
Génère
une couleur
hexadécimal
e al
éatoire (#RRGGBB)
.
*
Sélectionne aléatoirement
une couleur
dans un
e
p
al
ette prédéfinie
.
* @returns {string} Une couleur hexadécimal
e, ex: "#A1B2C3"
.
* @returns {string} Une couleur
au format
hexadécimal
ou HSL
.
*/
*/
function
generateRandomColor
()
{
function
generateRandomColor
()
{
const
letters
=
'
0123456789ABCDEF
'
;
const
palette
=
[
let
color
=
'
#
'
;
"
#6e76c7
"
,
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
"
#00a0bd
"
,
color
+=
letters
[
Math
.
floor
(
Math
.
random
()
*
16
)];
"
#96cd95
"
,
}
"
#ffeac2
"
,
return
color
;
"
#fff6ff
"
,
"
#e67e22
"
,
"
#20bad8
"
,
"
#f290e7
"
,
"
#f4ab9d
"
,
"
#f1e87a
"
,
"
#84e8e6
"
];
const
index
=
Math
.
floor
(
Math
.
random
()
*
palette
.
length
);
return
palette
[
index
];
}
}
/**
/**
...
@@ -18,10 +27,10 @@ function generateRandomColor() {
...
@@ -18,10 +27,10 @@ function generateRandomColor() {
* @param {string|number} lexiconId - L'identifiant du lexique.
* @param {string|number} lexiconId - L'identifiant du lexique.
* @returns {Promise<string>} La couleur associée au lexique.
* @returns {Promise<string>} La couleur associée au lexique.
*/
*/
async
function
getOrCreateLexiconColor
(
lexiconId
)
{
async
function
getOrCreateLexiconColor
(
lexiconId
,
forceReset
=
false
)
{
// Récupère la correspondance stockée dans storage
// Récupère la correspondance stockée dans storage
let
{
lexiconColors
}
=
await
browser
.
storage
.
local
.
get
(
"
lexiconColors
"
);
let
{
lexiconColors
}
=
await
browser
.
storage
.
local
.
get
(
"
lexiconColors
"
);
if
(
!
lexiconColors
)
{
if
(
!
lexiconColors
||
forceReset
)
{
lexiconColors
=
{};
lexiconColors
=
{};
}
}
// Si aucune couleur n'est associée à ce lexiconId, on la génère et on la sauvegarde
// Si aucune couleur n'est associée à ce lexiconId, on la génère et on la sauvegarde
...
...
This diff is collapsed.
Click to expand it.
src/background/background.js
+
9
−
1
View file @
99ef6749
...
@@ -88,11 +88,18 @@ async function actuallyOpenLoginPage() {
...
@@ -88,11 +88,18 @@ async function actuallyOpenLoginPage() {
browser
.
runtime
.
sendMessage
({
action
:
"
authStatusChanged
"
,
isLoggedIn
:
false
});
browser
.
runtime
.
sendMessage
({
action
:
"
authStatusChanged
"
,
isLoggedIn
:
false
});
}
}
// Déconnecte l'utilisateur
(sans notification)
// Déconnecte l'utilisateur
async
function
disconnectFromLexicalDB
()
{
async
function
disconnectFromLexicalDB
()
{
console
.
log
(
"
🔓 Déconnexion en cours...
"
);
console
.
log
(
"
🔓 Déconnexion en cours...
"
);
await
browser
.
storage
.
local
.
remove
(
"
accessToken
"
);
await
browser
.
storage
.
local
.
remove
(
"
accessToken
"
);
console
.
log
(
"
🔓 Token supprimé avec succès.
"
);
console
.
log
(
"
🔓 Token supprimé avec succès.
"
);
// Réinitialiser les couleurs des lexiques dans le local storage
try
{
await
browser
.
storage
.
local
.
remove
(
"
lexiconColors
"
);
console
.
log
(
"
Les couleurs des lexiques ont été réinitialisées dans le local storage.
"
);
}
catch
(
error
)
{
console
.
error
(
"
Erreur lors de la réinitialisation des couleurs :
"
,
error
);
}
setTimeout
(
async
()
=>
{
setTimeout
(
async
()
=>
{
await
refreshAllUI
();
await
refreshAllUI
();
},
500
);
},
500
);
...
@@ -135,6 +142,7 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
...
@@ -135,6 +142,7 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
const
isConnected
=
await
isUserConnected
();
const
isConnected
=
await
isUserConnected
();
if
(
isConnected
)
{
if
(
isConnected
)
{
await
disconnectFromLexicalDB
();
await
disconnectFromLexicalDB
();
await
browser
.
storage
.
local
.
remove
(
"
lexiconColors
"
);
}
else
{
}
else
{
actuallyOpenLoginPage
();
actuallyOpenLoginPage
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/sidebar/sidebar.js
+
1
−
1
View file @
99ef6749
...
@@ -533,7 +533,7 @@ document.addEventListener("DOMContentLoaded", async () => {
...
@@ -533,7 +533,7 @@ document.addEventListener("DOMContentLoaded", async () => {
authButton
.
addEventListener
(
"
click
"
,
handleAuthButtonClick
);
authButton
.
addEventListener
(
"
click
"
,
handleAuthButtonClick
);
}
}
const
chercherDefButton
=
document
.
getElementById
(
"
chercherDef
"
);
const
chercherDefButton
=
document
.
querySelector
(
"
#
chercherDef
"
);
if
(
chercherDefButton
)
{
if
(
chercherDefButton
)
{
chercherDefButton
.
addEventListener
(
"
click
"
,
async
()
=>
{
chercherDefButton
.
addEventListener
(
"
click
"
,
async
()
=>
{
openBlock
(
"
definitionContent
"
);
openBlock
(
"
definitionContent
"
);
...
...
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