forked from ayush-that/FinVeda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.html
174 lines (152 loc) · 6.07 KB
/
profile.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile Page</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.profile-display {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.profile-img {
border-radius: 50%;
width: 100px;
height: 100px;
margin-right: 20px;
border: 2px solid gray;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
background-color: #007bff;
color: white;
}
button:hover {
background-color: #0056b3;
}
#cancelButton {
background-color: #dc3545;
}
#cancelButton:hover {
background-color: #c82333;
}
</style>
</head>
<body>
<div class="container">
<h1>User Profile</h1>
<div id="profileDisplay" class="profile-display">
<img id="profileImage" src="no-profile-photo.png" alt="Profile Image" class="profile-img">
<div class="profile-info">
<p><strong>Username:</strong> <span id="displayUsername">john_doe</span></p>
<p><strong>Email:</strong> <span id="displayEmail">[email protected]</span></p>
<p><strong>Bio:</strong> <span id="displayBio">Welcome to my profile!</span></p>
</div>
</div>
<div id="profileEdit" style="display: none;">
<form id="profileForm">
<div class="form-group">
<label for="imageUpload">Profile Image:</label>
<input type="file" id="imageUpload" accept="image/*">
</div>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" value="john_doe">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" value="[email protected]">
</div>
<div class="form-group">
<label for="bio">Bio:</label>
<textarea id="bio" name="bio">Welcome to my profile!</textarea>
</div>
<button type="submit">Save</button>
<button type="button" id="cancelButton">Cancel</button>
</form>
</div>
<button id="editButton">Edit Profile</button>
</div>
<script>
const editButton = document.getElementById('editButton');
const profileDisplay = document.getElementById('profileDisplay');
const profileEdit = document.getElementById('profileEdit');
const cancelButton = document.getElementById('cancelButton');
const profileForm = document.getElementById('profileForm');
// Function to toggle between display and edit mode
editButton.addEventListener('click', function() {
profileDisplay.style.display = 'none';
profileEdit.style.display = 'block';
document.getElementById('username').focus(); // Set focus to the username field
});
cancelButton.addEventListener('click', function() {
resetProfileForm();
});
// Handle form submission
profileForm.addEventListener('submit', function(e) {
e.preventDefault(); // Prevent page refresh
const username = document.getElementById('username').value;
const email = document.getElementById('email').value;
const bio = document.getElementById('bio').value;
const imageUpload = document.getElementById('imageUpload').files[0];
// Update profile display
document.getElementById('displayUsername').textContent = username;
document.getElementById('displayEmail').textContent = email;
document.getElementById('displayBio').textContent = bio;
// Update profile image if an image is uploaded
if (imageUpload) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('profileImage').src = e.target.result; // Set the uploaded image as profile image
};
reader.readAsDataURL(imageUpload);
}
// Show profile display and hide edit form
profileDisplay.style.display = 'flex';
profileEdit.style.display = 'none';
});
// Reset the form and return to profile display
function resetProfileForm() {
// Reset form values
document.getElementById('username').value = document.getElementById('displayUsername').textContent;
document.getElementById('email').value = document.getElementById('displayEmail').textContent;
document.getElementById('bio').value = document.getElementById('displayBio').textContent;
// Hide edit form and show profile display
profileEdit.style.display = 'none';
profileDisplay.style.display = 'flex';
}
</script>
</body>
</html>