forked from abhrajit2004/Twitter-Landing-Page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.js
41 lines (36 loc) · 1.3 KB
/
profile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function loadProfileImage(event) {
const profileImage = document.getElementById('profileImage');
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
profileImage.src = e.target.result;
};
reader.readAsDataURL(file);
}
}
document.getElementById('profileForm').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const bio = document.getElementById('bio').value;
console.log("Profile Updated:", { name, email, bio });
alert("Profile updated successfully!");
});
// DARK MODE
const themeToggleButton = document.getElementById("themeToggle");
const body = document.body;
if (localStorage.getItem("theme") === "dark") {
body.classList.add("dark-mode");
themeToggleButton.textContent = "☀️ ";
}
themeToggleButton.addEventListener("click", () => {
body.classList.toggle("dark-mode");
if (body.classList.contains("dark-mode")) {
themeToggleButton.textContent = "☀️";
localStorage.setItem("theme", "dark");
} else {
themeToggleButton.textContent = "🌙";
localStorage.setItem("theme", "light");
}
});