From 60bf32cc55c68c2929e14476a593a4b16110031d Mon Sep 17 00:00:00 2001 From: Meira Tompkins Date: Tue, 3 Mar 2020 14:27:49 -0500 Subject: [PATCH] changes --- index.html | 1 + js/profile.js | 27 +++++++++++++++++++++++++++ profile.html | 7 ++++--- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 js/profile.js diff --git a/index.html b/index.html index e512195..6e4e8f2 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@
+

Sending messages as {UserName} {Status}

~Meira's Mobile App Chat Room~

Click!
diff --git a/js/profile.js b/js/profile.js new file mode 100644 index 0000000..3c52903 --- /dev/null +++ b/js/profile.js @@ -0,0 +1,27 @@ + +let usernameInput = document.querySelector("#usernameInput"); +let statusInput = document.querySelector("#statusInput"); +let profilePicInput = document.querySelector("#profilePicInput"); +let profileSaveInput = document.querySelector("#profileSaveInput"); + +// setting the input values default +usernameInput.value = localStorage.getItem('userName'); +statusInput.value = localStorage.getItem('userStatus'); + +function saveProfileImageLocally() { + if (profilePicInput.files && profilePicInput.files[0]) { + var reader = new FileReader(); + reader.onload = function(e) { + localStorage.setItem("userProfilePic", reader.result); + } + reader.readAsDataURL(profilePicInput.files[0]); + } +} + +profileSaveInput.addEventListener( 'click', function(e) { + e.preventDefault(); + localStorage.setItem("userName", usernameInput.value); + localStorage.setItem("userStatus", statusInput.value); + + saveProfileImageLocally(); +}); diff --git a/profile.html b/profile.html index 8da158d..3a1c525 100644 --- a/profile.html +++ b/profile.html @@ -9,9 +9,10 @@
- placeholder -

Hannah Baker

-

Cookie Curator

+

+

+

+

Go Back to Chat App

Lorem ipsum dolor sit amet consectetur adipisicing elit. Deserunt numquam, consequatur eos error ducimus quisquam nam ut quasi sint adipisci sit molestiae, ad dolorum iste possimus deleniti rerum ipsum repudiandae.