-
Notifications
You must be signed in to change notification settings - Fork 189
/
profileedit.html
342 lines (252 loc) · 9.24 KB
/
profileedit.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Profile</title>
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: 'Arial', sans-serif;
background-image: radial-gradient(circle at 50% 50%, rgba(0, 255, 136, 0.1) 0%, transparent 50%), linear-gradient(to bottom, #0a0b1a 0%, #1a1b3a 100%);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: #0b0e1c;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 0 15px rgba(0, 255, 136, 0.2);
border-color: #00d0ff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%;
max-width: 800px;
margin: auto;
}
.edit-profile {
text-align: center;
margin-bottom: 20px;
width: 100%;
}
.edit-profile h3 {
margin-bottom: 10px;
color: #ffffff;
font-size: 24px;
}
.home-link {
display: flex;
align-items: center;
color: #00d0ff;
font-size: 18px;
text-decoration: none;
position: absolute;
margin-left: 20px;
}
.home-link i {
margin-right: 8px;
font-size: 24px;
}
.home-link:hover {
color: #ffffff;
}
.avatar-selection {
text-align: center;
margin-bottom: 20px;
}
.avatars {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 20px;
}
.avatars img {
width: 120px;
height: 120px;
cursor: pointer;
border: 4px solid transparent;
border-radius: 50%;
transition: transform 0.3s ease-in-out, border-color 0.3s ease-in-out;
}
.avatars img:hover {
transform: scale(1.1);
}
.avatars img.selected {
border-color: #00d0ff;
}
.profile-details {
text-align: center;
margin-bottom: 20px;
width: 100%;
}
.profile-details h4 {
margin-bottom: 10px;
color: #ffffff;
font-size: 20px;
}
.profile-details input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;
background: transparent;
border-color: #00d0ff;
color: white;
}
.save-button {
background-color: #00d0ff;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
margin-top: 20px;
}
.save-button:hover {
background-color: #0087a5;
transform: scale(1.05);
}
.save-button:focus {
outline: none;
}
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1170px;
margin: auto;
max-height: 650px;
}
.row {
display: flex;
flex-wrap: wrap;
}
ul {
list-style: none;
}
</style>
</head>
<body>
<div class="container">
<div class="edit-profile">
<!-- Home Link -->
<a href="../../index.html" class="home-link">
<i class='bx bx-home'></i> Home
</a>
<h3>Edit Profile</h3>
</div>
<div class="avatar-selection">
<h4>Select Avatar</h4>
<div class="avatars">
<img src="https://i.postimg.cc/VvvM4LLK/4140061.png" onclick="selectAvatar('https://i.postimg.cc/VvvM4LLK/4140061.png')" />
<img src="https://i.postimg.cc/g0yv2TTH/6833605.png" onclick="selectAvatar('https://i.postimg.cc/g0yv2TTH/6833605.png')" />
<img src="https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg" onclick="selectAvatar('https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg')" />
<img src="https://i.postimg.cc/rwKwFnfR/4139967.png" onclick="selectAvatar('https://i.postimg.cc/rwKwFnfR/4139967.png')" />
<img src="https://i.postimg.cc/dQNG3d4p/6997484.png" onclick="selectAvatar('https://i.postimg.cc/dQNG3d4p/6997484.png')" />
</div>
</div>
<div class="profile-details">
<h4>Edit Details</h4>
<input type="text" id="nameInput" placeholder="Enter Name" required required pattern="[a-zA-Z ]+" oninvalid="this.setCustomValidity('Numbers and Symbols are not allowed')" oninput="this.setCustomValidity('')">
<input type="email" id="emailInput" placeholder="Enter Email" required>
<input type="tel" id="phoneInput" placeholder="Enter Phone" required>
<input type="text" id="bioInput" placeholder="Add Bio" maxlength="150" required>
</div>
<button class="save-button" onclick="saveProfile()">Save Profile</button>
</div>
<script>
let selectedAvatar = "";
function selectAvatar(avatarSrc) {
const avatars = document.querySelectorAll('.avatars img');
avatars.forEach(img => {
img.classList.remove('selected');
});
const selectedImg = Array.from(avatars).find(img => img.src === avatarSrc);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = avatarSrc;
}
}
function saveProfile() {
const newName = document.getElementById("nameInput").value.trim();
const newEmail = document.getElementById("emailInput").value.trim();
const newPhone = document.getElementById("phoneInput").value.trim();
const newBio = document.getElementById("bioInput").value.trim();
// Check if all fields are valid before proceeding
if (!nameInput.checkValidity() || !emailInput.checkValidity() || !phoneInput.checkValidity()) {
nameInput.reportValidity();
emailInput.reportValidity();
phoneInput.reportValidity();
bioInput.reportValidity();
return; // Stop function execution if invalid
}
if (newEmail && !validateEmail(newEmail)) {
alert("Invalid email address");
return;
}
if (selectedAvatar) {
localStorage.setItem("selectedAvatar", selectedAvatar);
}
if (newName) {
localStorage.setItem("profileName", newName);
}
if (newEmail) {
localStorage.setItem("profileEmail", newEmail);
}
if (newPhone) {
localStorage.setItem("profilePhone", newPhone);
}
if (newBio) {
localStorage.setItem("profileBio", newBio);
}
// Redirect to the profile page
window.location.href = "profile.html"; // Change made here
}
function validateEmail(email) {
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return re.test(email);
}
document.addEventListener("DOMContentLoaded", () => {
const savedAvatar = localStorage.getItem("selectedAvatar");
if (savedAvatar) {
const selectedImg = Array.from(document.querySelectorAll('.avatars img')).find(img => img.src === savedAvatar);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = savedAvatar;
}
}
const savedName = localStorage.getItem("profileName");
const savedEmail = localStorage.getItem("profileEmail");
const savedPhone = localStorage.getItem("profilePhone");
const savedBio = localStorage.getItem("profileBio");
if (savedName) {
document.getElementById("nameInput").value = savedName;
}
if (savedEmail) {
document.getElementById("emailInput").value = savedEmail;
}
if (savedPhone) {
document.getElementById("phoneInput").value = savedPhone;
}
if (savedBio) {
document.getElementById("bioInput").value = savedBio;
}
});
</script>
</body>
</html>