-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.html
175 lines (149 loc) · 5.59 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
175
<!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>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-image: url('https://img.freepik.com/free-vector/gradient-black-background-with-wavy-lines_52683-76100.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
color: #fff;
}
header {
background-color: rgba(51, 51, 51, 0.8);
text-align: center;
padding: 20px;
position: relative;
}
h1 {
margin: 0;
color: #fff;
}
.header-buttons {
position: absolute;
top: 20px;
right: 20px;
}
button {
background-color: #4caf50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
section {
background-color: black(255, 255, 255, 0.9);
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: white; /* Text color for labels */
}
input,
select {
width: 100%;
padding: 8px;
margin-bottom: 16px;
border: 1px solid #ccc;
border-radius: 4px;
color: #333; /* Text color for input fields */
}
button.save-btn {
background-color: #4caf50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 20px;
}
</style>
</head>
<body>
<header>
<h1>Profile</h1>
<div class="header-buttons">
<button onclick="navigateToModules()"><a href="chat.html">Home</a></button>
<button onclick="navigateToModules()"><a href="m3.html">Modules</a></button>
<button onclick="navigateToBadges()"><a href="badges.html">Badges</a></button>
</div>
</header>
<form id="profileForm">
<section>
<h2>Basic Information</h2>
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" required>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName" required>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required>
<label for="gender">Gender:</label>
<select id="gender" name="gender" required>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</section>
<section>
<h2>Contact Information</h2>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="phoneNumber">Phone Number:</label>
<input type="tel" id="phoneNumber" name="phoneNumber" required>
</section>
<button type="button" onclick="saveProfile()">Save Profile</button>
</form>
<script>
// Call this function on page load
window.onload = function () {
displayProfile();
};
function displayProfile() {
var storedProfileJSON = localStorage.getItem('userProfile');
if (storedProfileJSON) {
var storedProfileData = JSON.parse(storedProfileJSON);
// Display the details on the form
document.getElementById('firstName').value = storedProfileData.firstName;
document.getElementById('lastName').value = storedProfileData.lastName;
document.getElementById('age').value = storedProfileData.age;
document.getElementById('gender').value = storedProfileData.gender;
document.getElementById('email').value = storedProfileData.email;
document.getElementById('phoneNumber').value = storedProfileData.phoneNumber;
}
}
function saveProfile() {
var firstName = document.getElementById('firstName').value;
var lastName = document.getElementById('lastName').value;
var age = document.getElementById('age').value;
var gender = document.getElementById('gender').value;
var email = document.getElementById('email').value;
var phoneNumber = document.getElementById('phoneNumber').value;
var profileData = {
'firstName': firstName,
'lastName': lastName,
'age': age,
'gender': gender,
'email': email,
'phoneNumber': phoneNumber
};
var profileDataJSON = JSON.stringify(profileData);
localStorage.setItem('userProfile', profileDataJSON);
// Display the saved profile details
displayProfile();
}
</script>
</body>
</html>