forked from Laboratoria/BOG001-social-network
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c61f82
commit b705f63
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,4 +58,6 @@ window.addEventListener('hashchange', () => { | |
router(window.location.hash); | ||
}); | ||
|
||
|
||
|
||
myFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,53 @@ export default () => { | |
history.replaceState({}, 'profileUser', '#profile'); | ||
const profile = document.createElement('div'); | ||
profile.setAttribute('id', 'profile'); | ||
profile.innerHTML = `<img src="img/foto.jpg" alt="photoUser" class="photo"/> | ||
profile.innerHTML = `<img src="" id="preview" alt="photoUser" class="photo"/> | ||
<div class="default-image"></div> | ||
<h1>Clara Escobar</h1> | ||
<input type="file" id="archivo" name="archivo"/> | ||
<ul> | ||
<li> | ||
<a href="#">[email protected]</a> | ||
</li> | ||
</ul> | ||
<h3>Sobre mi</h3> | ||
<input type="text" id="biography" class="aboutMe" placeholder="Cuéntanos de ti"/>`; | ||
|
||
const photos = profile.querySelector('#archivo'); | ||
const previewPhoto = profile.querySelector('#preview'); | ||
const defaultImage = profile.querySelector('.default-image'); | ||
|
||
photos.addEventListener('change', () => { | ||
const file = photos.files[0]; | ||
console.log(file); | ||
if (file) { | ||
const reader = new FileReader(); | ||
defaultImage.style.display = 'none'; | ||
previewPhoto.style.display = 'block'; | ||
reader.addEventListener('load', () => { | ||
previewPhoto.setAttribute('src', reader.result); | ||
}); | ||
reader.readAsDataURL(file); | ||
} else { | ||
defaultImage.style.display = null; | ||
previewPhoto.style.display = null; | ||
previewPhoto.setAttribute('src', ''); | ||
} | ||
}); | ||
return profile; | ||
}; | ||
}; | ||
|
||
|
||
/*function mostrarImagen(event){ | ||
let imagenSource = event.target.result; | ||
let previewImage = document.getElementById("preview"); | ||
} | ||
function changePhoto(event){ | ||
let imagen = event.target.files[0]; | ||
let lector = new FileReader(); | ||
lector.addEventListener("load", mostrarImagen,false); | ||
lector.readAsDataURL(imagen); | ||
} | ||
document.getElementById("archivo").addEventListener("change", changePhoto,false);*/ | ||
|