add perfil

This commit is contained in:
2026-09-23 13:58:05 +02:00
parent 4cb4faff1b
commit 835b8e332b
3 changed files with 686 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
// =========================
// CAMBIAR NOMBRE
// =========================
function cambiarNombre() {
const input = document.getElementById("nuevoNombre");
const nombre = document.getElementById("nombre");
const nuevoNombre = input.value.trim();
if (nuevoNombre !== "") {
nombre.textContent = nuevoNombre;
input.value = "";
}
}
// =========================
// BORRAR NOMBRE
// =========================
function borrarNombre() {
document.getElementById("nuevoNombre").value = "";
}
// =========================
// ABRIR SELECTOR DE IMAGEN
// =========================
function seleccionarFoto() {
document.getElementById("inputFoto").click();
}
// =========================
// CAMBIAR FOTO
// =========================
document.getElementById("inputFoto").addEventListener(
"change",
function(event) {
const archivo = event.target.files[0];
if (archivo) {
// Comprobamos que sea una imagen
if (!archivo.type.startsWith("image/")) {
alert("Por favor, selecciona una imagen.");
return;
}
// Creamos una URL temporal
const imagenURL = URL.createObjectURL(archivo);
// Cambiamos la foto
document.getElementById("fotoPerfil").src = imagenURL;
}
}
);