-
Notifications
You must be signed in to change notification settings - Fork 279
/
profileedit.html
368 lines (281 loc) · 10.8 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<!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: #ffffff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background: #abd4fc;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%;
max-width: 1200px;
margin: auto;
}
.edit-profile {
text-align: center;
margin-bottom: 20px;
width: 100%;
}
.edit-profile h3 {
margin-bottom: 10px;
color: #2980b9;
font-size: 24px;
}
.home-link {
display: flex;
align-items: center;
color: #2980b9;
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;
color: #4280b9;
}
.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: #0560c2;
}
.profile-details {
text-align: center;
margin-bottom: 20px;
width: 100%;
}
.profile-details h4 {
margin-bottom: 10px;
color: #2980b9;
font-size: 20px;
}
.profile-details input,
.profile-details select {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.save-button {
background-color: #0560c2;
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: #5875b3;
transform: scale(1.05);
}
.save-button:focus {
outline: none;
}
</style>
</head>
<body>
<div class="container">
<div class="edit-profile">
<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>
<input type="email" id="emailInput" placeholder="Enter Email" required>
<input type="tel" id="phoneInput" placeholder="Enter Phone" required>
<input type="tel" id="emergencyContactInput" placeholder="Emergency Contact" required>
<input type="date" id="dobInput" placeholder="Date of Birth" required>
<select id="genderInput" required>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
<select id="preferredLanguageInput" required>
<option value="English">English</option>
<option value="Bengali">Bengali</option>
<option value="Hindi">Hindi</option>
</select>
<!-- Added Role select field -->
<select id="roleInput" required>
<option value="Patient">Patient</option>
<option value="Doctor">Doctor</option>
<option value="Nurse">Nurse</option>
<option value="Admin">Admin</option>
</select>
</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 newEmergencyContact = document.getElementById("emergencyContactInput").value.trim();
const newDOB = document.getElementById("dobInput").value.trim();
const newGender = document.getElementById("genderInput").value;
const newPreferredLanguage = document.getElementById("preferredLanguageInput").value;
const newRole = document.getElementById("roleInput").value;
// Validate inputs
if (!nameInput.checkValidity() || !emailInput.checkValidity() || !phoneInput.checkValidity() || !emergencyContactInput.checkValidity()) {
nameInput.reportValidity();
emailInput.reportValidity();
phoneInput.reportValidity();
emergencyContactInput.reportValidity();
dobInput.reportValidity();
return;
}
if (newEmail && !validateEmail(newEmail)) {
alert("Invalid email address");
return;
}
// Save to localStorage
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 (newEmergencyContact) {
localStorage.setItem("emergencyContact", newEmergencyContact);
}
if (newDOB) {
localStorage.setItem("dob", newDOB);
}
if (newGender) {
localStorage.setItem("gender", newGender);
}
if (newPreferredLanguage) {
localStorage.setItem("preferredLanguage", newPreferredLanguage);
}
if (newRole) {
localStorage.setItem("profileRole", newRole);
}
// Redirect to profile page
window.location.href = "profile.html";
}
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 savedEmergencyContact = localStorage.getItem("emergencyContact");
const savedDOB = localStorage.getItem("dob");
const savedGender = localStorage.getItem("gender");
const savedPreferredLanguage = localStorage.getItem("preferredLanguage");
const savedRole = localStorage.getItem("profileRole");
if (savedName) {
document.getElementById("nameInput").value = savedName;
}
if (savedEmail) {
document.getElementById("emailInput").value = savedEmail;
}
if (savedPhone) {
document.getElementById("phoneInput").value = savedPhone;
}
if (savedEmergencyContact) {
document.getElementById("emergencyContactInput").value = savedEmergencyContact;
}
if (savedDOB) {
document.getElementById("dobInput").value = savedDOB;
}
if (savedGender) {
document.getElementById("genderInput").value = savedGender;
}
if (savedPreferredLanguage) {
document.getElementById("preferredLanguageInput").value = savedPreferredLanguage;
}
if (savedRole) {
document.getElementById("roleInput").value = savedRole;
}
});
</script>
</body>
</html>