diff --git a/pages/profil.php b/pages/profil.php index e71c703..e2e0a8b 100644 --- a/pages/profil.php +++ b/pages/profil.php @@ -8,6 +8,8 @@ + +
{$u->username}
"; - echo "{$u->email}
"; - $passwdhiden = $u->hidenPassWd($u); - echo "{$passwdhiden}
"; + + echo "
+ {$u->username}
+
+
+
+ {$u->email}
+
+
+
+ {$u->hidenPasswd}
+
+
+
via son identifiant + var pElement = document.getElementById(id); + + // Obtenir le texte actuel du
+ var currentValue = pElement.textContent.trim(); + + // Créer un champ de saisie avec la valeur actuelle + var input = document.createElement('input'); + input.type = 'text'; + input.value = currentValue + input.class = 'changeValue'; + + // Sauvegarde lors de la perte de focus + input.setAttribute('onblur', 'saveField("' + id + '", this.value)'); + + // Remplacer le
par le champ + pElement.innerHTML = ''; + pElement.appendChild(input); + + // Mettre le focus sur le champ de saisie + input.focus(); +} + +//Sauvegarder les changements sur la vue +function saveField(id, newValue) { + if (id === 'email') { + if (!validateEmail(newValue)) { + alert('Adresse email invalide. Veuillez entrer un email valide.'); + document.getElementById(id).querySelector('input').focus(); + return; // Ne pas sauvegarder si l'email n'est pas valide + } + } + if (id === 'username') { + if (newValue.trim() === "") { + alert('Le nom d\'utilisateur ne peut pas être vide.'); + document.getElementById(id).querySelector('input').focus(); + return; // Ne pas sauvegarder si le nom d'utilisateur est vide + } + } + + // Récupérer l'élément
via son identifiant
+ var pElement = document.getElementById(id);
+
+ // Mettre à jour la valeur avec la nouvelle saisie
+ pElement.innerHTML = '' + newValue + ' ';
+}
+
+//Email valide
+function validateEmail(email) {
+ // Regex pour vérifier le format de l'email
+ var re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
+ return re.test(String(email).toLowerCase());
+}
diff --git a/script/user.php b/script/user.php
index fcee21b..fabd795 100644
--- a/script/user.php
+++ b/script/user.php
@@ -3,6 +3,7 @@ class User{
public int $id;
public string $username;
public string $passwd;
+ public string $hidenPasswd;
public string $img;
public string $email;
public bool $admin = false;
@@ -10,15 +11,17 @@ class User{
function __construct(string $pseudo, string $password, string $image, string $mail) {
$this->username = $pseudo;
$this->passwd = $password;
+ $this->hidenPasswd = hidenPassWd($password);
$this->img = $image;
$this->email = $mail;
}
}
-$u = new User('Testeur', 'e', '../images/imageProfil.png', 'testeur.compte@wikifantasy.com'); /*Test*/
+$u = new User('Testeur', 'motDepasse', '../images/imageProfil.png', 'testeur.compte@wikifantasy.com'); /*Test*/
-function hidenPassWd(User $u){
- return str_repeat('*', strlen($u->passwd));
+function hidenPassWd(string $passwd){
+ if(strlen($passwd) >= 16) return str_repeat('*', 16);
+ return str_repeat('*', strlen($passwd));
}
function modifyName(string $name){
diff --git a/styles/styleProfil.css b/styles/styleProfil.css
index 60219f4..3623a99 100644
--- a/styles/styleProfil.css
+++ b/styles/styleProfil.css
@@ -29,8 +29,6 @@ body.dark-mode .buttonSudmite{
font-size: 20px;
}
-
-
body.dark-mode .createQuote{
margin-top: 5%;
margin-bottom: 5%;
@@ -52,6 +50,14 @@ body.dark-mode .login{
border: 2px solid transparent;
}
+body.dark-mode .imgModify{
+ width: 3%;
+ margin-left: 5%;
+ margin-top: 5%;
+ filter: invert(100%) brightness(1000%) contrast(1000%);
+}
+
+
/* ====== LIGHT MODE ====== */
body.light-mode h1{
color : black;
@@ -108,6 +114,11 @@ body.light-mode .login{
text-align: center;
}
+.changeValue{
+ color: red;
+}
+
+
.imageProfil{
width: 25%;
border-radius: 25px;
@@ -117,6 +128,7 @@ body.light-mode .login{
}
.nameProfil{
+ margin-left: 10%;
text-align: center;
font-size: 120%;
}