diff --git a/pages/profil.php b/pages/profil.php index 4db7069..8e3dca3 100644 --- a/pages/profil.php +++ b/pages/profil.php @@ -8,6 +8,8 @@ + +
@@ -26,16 +28,31 @@

▶ Profil ◀

- img} class='imageProfil' onmousedown='return false'/>"; - - echo "

{$u->username}

"; - echo "

{$u->email}

"; - $passwdhiden = hidenPassWd($u); - echo "

{$passwdhiden}

"; + echo ""; + + // Nom d'utilisateur + echo "

+ {$u->username} + + +

"; + + // Email + echo "

+ {$u->email} + + +

"; + + // Mot de passe + echo "

+ {$u->hidenPasswd} + + +

"; ?>
diff --git a/script/changeData.js b/script/changeData.js new file mode 100644 index 0000000..8cc43b3 --- /dev/null +++ b/script/changeData.js @@ -0,0 +1,55 @@ + +function editField(id) { + // Récupérer l'élément

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 a2adc20..0e93e4a 100644 --- a/script/user.php +++ b/script/user.php @@ -2,21 +2,24 @@ class User{ public string $username; public string $passwd; + public string $hidenPasswd; public string $img; public string $email; 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%; }