const menulogo = getID("menu-logo") const usersettingsBtn = getID("user-settings-button") menu.style.display = "none" menulogo.addEventListener("click", () => { const menu = getID("menu") if(menu.style.display == "block") { menu.style.display = "none" } else { menu.style.display = "block" } }) usersettingsBtn.addEventListener("click", () => { const View = new ViewWindow({ title: ` Mon Compte`, width: "600px", height: "650px" }) View.setContent(`

Mes informations

Nom d'utilisateur

Nom d'affichage

Mot de passe

Photo de profil


Mes permissions

`) const usSettingsImage = getID("us-settings-image") const usSettingsUsername = getID("us-settings-username") const usSettingsDisplayname = getID("us-settings-displayname") const usSettingsPassword = getID("us-settings-password") const usSettingsPermissions = getID("us-settings-permissions") const usSettingsSave = getID("us-settings-save") const usSettingsPicture = getID("us-settings-picture") const returnInfo = new TextResponse("us-settings-return-info") const REQ_user = get("USERINFO") var actualUsername = "" REQ_user.then((ANS_user) => { usSettingsImage.src = ANS_user.picture usSettingsUsername.value = ANS_user.username usSettingsDisplayname.value = ANS_user.display_name actualUsername = ANS_user.username const permissions = ANS_user.permission const permValid = new Array() permissions.forEach((permValue) => { permValid.push("

" + permValue + "

") }) usSettingsPermissions.innerHTML = permValid.join("") }) usSettingsSave.addEventListener("click", () => { const request = post(`US_EDIT_PERSONNAL`, {username: actualUsername, newusername: usSettingsUsername.value, display_name: usSettingsDisplayname.value, password: usSettingsPassword.value, picture: usSettingsPicture.files[0]}) request.then((answer) => { if(answer == "ALREADY_EXIST") { returnInfo.err("L'utilisateur existe déjà !") } else if(answer == "USERNAME_MISSING") { returnInfo.err("Le nom d'utilisateur est manquant !") } else if(answer == "DISPLAY_NAME_MISSING") { returnInfo.err("Le nom d'affichage est manquant !") } else if(answer == "PASSWORD_MISSING") { returnInfo.err("Le mot de passe est manquant !") } else { View.destroy() loadUserInfo() } }) }) }) document.addEventListener("click", (e) => { if(e.target != menulogo) { menu.style.display = "none" } })