-
Notifications
You must be signed in to change notification settings - Fork 0
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
0cd8888
commit 74a15ed
Showing
1 changed file
with
44 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
// Function to handle the profile picture change | ||
function changeProfilePicture(event) { | ||
const reader = new FileReader(); | ||
const file = event.target.files[0]; | ||
|
||
reader.onload = function () { | ||
const profilePic = document.getElementById("club-profile-pic"); | ||
profilePic.src = reader.result; | ||
|
||
// Save the image data to localStorage | ||
localStorage.setItem("profilePicture", reader.result); | ||
}; | ||
|
||
if (file) { | ||
reader.readAsDataURL(file); | ||
} | ||
class ProfilePictureChange { | ||
loadProfilePicture() { | ||
const savedProfilePic = localStorage.getItem("profilePicture"); | ||
if (savedProfilePic) { | ||
const profilePic = document.getElementById("club-profile-pic"); | ||
profilePic.src = savedProfilePic; | ||
} | ||
} | ||
|
||
changeProfilePicture(event) { | ||
const reader = new FileReader(); | ||
const file = event.target.files[0]; | ||
|
||
reader.onload = function () { | ||
const profilePic = document.getElementById("club-profile-pic"); | ||
profilePic.src = reader.result; | ||
|
||
// Image data is saved to the localstorage | ||
localStorage.setItem("profilePicture", reader.result); | ||
}; | ||
|
||
if (file) { | ||
reader.readAsDataURL(file); | ||
} | ||
} | ||
} | ||
|
||
// Function to load the profile picture from localStorage on page load | ||
function loadProfilePicture() { | ||
const savedProfilePic = localStorage.getItem("profilePicture"); | ||
if (savedProfilePic) { | ||
document.getElementById("club-profile-pic").src = savedProfilePic; | ||
} | ||
class ChangeProfileAdapter { | ||
constructor(profilePictureChange) { | ||
this.profilePictureChange = profilePictureChange; | ||
} | ||
|
||
load() { | ||
this.profilePictureChange.loadProfilePicture(); | ||
} | ||
|
||
|
||
update(event) { | ||
this.profilePictureChange.changeProfilePicture(event); | ||
} | ||
} | ||
|
||
// Load the profile picture when the page is loaded | ||
window.onload = loadProfilePicture; | ||
const profilePictureChange = new ProfilePictureChange(); | ||
const changeProfileAdapter = new ChangeProfileAdapter(profilePictureChange); | ||
|
||
window.onload = function() { | ||
changeProfileAdapter.load(); // Load profile picture when the page loads | ||
}; |