LORDCHANNEL2.0/static/js/profilo.js

34 lines
2.1 KiB
JavaScript

try{
const current_image_profile = document.getElementById("div_id_immagine_profilo").getElementsByTagName("a")[0];
current_image_profile.style.display = "none";
const current_background_profile = document.getElementById("div_id_background_image").getElementsByTagName("a")[0];
current_background_profile.style.display = "none";
const text_modify_profile = document.getElementById('id_immagine_profilo').previousSibling.textContent="";
const text_actual_profile = current_image_profile.previousSibling.textContent="";
const text_modify_background = document.getElementById('id_background_image').previousSibling.textContent="";
const text_actual_background = current_background_profile.previousSibling.textContent="";
const imagebox = document.getElementById('imagebox');
var backgroundbox = document.createElement("div");
backgroundbox.classList.add("text-center");
backgroundbox.innerHTML = `<div class="text-center mb-3" style="font-weight: bold;color: #0f0c29;">Immagine Sfondo Attuale : </div><img src="${current_background_profile.href}" width="100%" height="250px">`;
document.getElementById("div_id_background_image").prepend(backgroundbox);
imagebox.innerHTML = `<img src="${current_image_profile.href}" width="150px" height="150px">`;
const modify_profile = document.getElementsByName('immagine_profilo')[0];
const modify_profile_background = document.getElementById("id_background_image");
modify_profile.addEventListener('change',()=>{
const image_data = modify_profile.files[0];
const url = URL.createObjectURL(image_data);
imagebox.innerHTML = `<img src="${url}" width="150px" height="150px">`;
});
modify_profile_background.addEventListener('change',()=>{
const image_data = modify_profile_background.files[0];
const url = URL.createObjectURL(image_data);
backgroundbox.innerHTML = `<div class="text-center mb-3" style="font-weight: bold;color: #0f0c29;">Immagine Sfondo Attuale : </div><img src="${url}" width="100%" height="250px">`;
});
}
catch(error){
console.log("Errore!");
}