add perfil
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user