forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.html
345 lines (308 loc) · 12.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" sizes="180x180" href="./assets/favicon_package_v0.16/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./assets/favicon_package_v0.16/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./assets/favicon_package_v0.16/favicon-16x16.png">
<link rel="manifest" href="./assets/favicon_package_v0.16/site.webmanifest">
<link rel="mask-icon" href="./assets/favicon_package_v0.16/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<title>Profile Page</title>
<link rel="stylesheet" href="profile.css">
<style>
/* Additional CSS for styling */
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
height: 100vh; /* Ensure body takes full height of the viewport */
overflow: hidden; /* Prevent scrolling on the body */
}
.profile-container {
display: flex;
height: 100vh; /* Ensure it takes the full height of the viewport */
overflow-y:scroll;
}
.profile-sidebar {
width: 250px;
padding: 20px;
background: #f57d7d;
border-right: 1px solid #ddd;
box-sizing: border-box;
overflow-y: auto; /* Allow scrolling if content overflows */
}
.profile-main {
flex: 1;
padding: 20px;
box-sizing: border-box;
overflow-y: auto; /* Allow scrolling if content overflows */
}
.profile-last-login {
margin-top: 20px;
font-size: 14px;
color: #0e0d0d;
text-align: center;
opacity: 0;
animation: fade-in 1s ease-in-out forwards;
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.activity-list li {
display: none;
}
.activity-list li.visible {
display: list-item;
}
.read-more {
color: #007bff;
cursor: pointer;
text-decoration: underline;
display: inline-block;
margin-top: 10px;
}
.profile-section {
margin-bottom: 20px;
}
.profile-picture img {
width: 100%;
height: auto;
border-radius: 50%;
}
.profile-details {
text-align: center;
}
.profile-details h1 {
margin: 10px 0;
}
.profile-details p {
margin: 5px 0;
}
.edit-profile-btn {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 5px;
margin-top: 20px;
transition: background 0.3s;
}
.edit-profile-btn:hover {
background: #0056b3;
}
.profile-completion {
margin-top: 20px;
text-align: center;
}
.profile-completion .progress-bar-container {
background: #ddd;
border-radius: 10px;
overflow: hidden;
width: 80%;
margin: 10px auto;
}
.profile-completion .progress-bar {
height: 20px;
width: 0;
background: #007bff;
transition: width 0.5s;
}
.personalized-greeting {
font-size: 18px;
margin-bottom: 20px;
text-align: center;
}
</style>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<div class="profile-container">
<div class="profile-sidebar">
<div class="profile-picture">
<img id="profile-avatar" src="https://via.placeholder.com/150" alt="Profile Picture">
</div>
<div class="profile-details">
<div class="personalized-greeting" id="greeting"></div>
<h1 class="profile-name">John Doe</h1>
<p class="profile-email"><i class="fas fa-envelope"></i> [email protected]</p>
<p class="profile-phone"><i class="fas fa-phone"></i> +123 456 7890</p>
<p class="profile-last-login" id="last-login-time">Last login: Not available</p>
<button class="edit-profile-btn" onclick="editProfile()"><i class="fas fa-edit"></i> Edit Profile</button>
<div class="profile-completion">
<p>Profile Completion: <span id="completion-percentage">0%</span></p>
<div class="progress-bar-container">
<div class="progress-bar" id="progress-bar"></div>
</div>
</div>
</div>
</div>
<div class="profile-main">
<div class="profile-section">
<h2>Order History</h2>
<ul class="order-list">
<li>Order #1234 - <span class="order-status">Delivered</span></li>
<li>Order #5678 - <span class="order-status">Shipped</span></li>
<li>Order #91011 - <span class="order-status">Processing</span></li>
</ul>
</div>
<div class="profile-section">
<h2>Wishlist</h2>
<ul class="wishlist">
<li>Product 1</li>
<li>Product 2</li>
<li>Product 3</li>
</ul>
</div>
<div class="profile-section">
<h2>Saved Addresses</h2>
<ul class="address-list">
<li>123 Main St, San Francisco, CA</li>
<li>456 Maple Rd, Los Angeles, CA</li>
</ul>
</div>
<div class="profile-section">
<h2>Payment Methods</h2>
<ul class="payment-methods">
<li>Visa ending in 1234</li>
<li>MasterCard ending in 5678</li>
</ul>
</div>
<div class="profile-section">
<h2>Recent Activities</h2>
<ul class="activity-list" id="activity-list">
<!-- Activities will be dynamically added here -->
</ul>
<span class="read-more" id="read-more" onclick="toggleActivities()">Read More</span>
</div>
<div class="profile-section">
<h2>Notifications</h2>
<ul class="notification-list" id="notification-list">
<!-- Notifications will be dynamically added here -->
</ul>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const savedAvatar = localStorage.getItem("selectedAvatar");
if (savedAvatar) {
const profileAvatar = document.getElementById("profile-avatar");
profileAvatar.src = `../assets/images/${savedAvatar}`;
}
const savedName = localStorage.getItem("profileName");
const savedEmail = localStorage.getItem("profileEmail");
const savedPhone = localStorage.getItem("profilePhone");
const lastLoginTime = localStorage.getItem("lastLoginTime");
if (savedName) {
document.querySelector(".profile-name").textContent = savedName;
}
if (savedEmail) {
document.querySelector(".profile-email").innerHTML = `<i class="fas fa-envelope"></i> ${savedEmail}`;
}
if (savedPhone) {
document.querySelector(".profile-phone").innerHTML = `<i class="fas fa-phone"></i> ${savedPhone}`;
}
if (lastLoginTime) {
const loginTimeElement = document.getElementById("last-login-time");
loginTimeElement.textContent = `Last login: ${new Date(lastLoginTime).toLocaleString()}`;
loginTimeElement.style.opacity = 1; // Ensure it's visible after animation
} else {
// Set last login time if not already set
setLastLoginTime();
}
// Calculate profile completion percentage
calculateProfileCompletion();
// Add personalized greeting
addPersonalizedGreeting();
// Dynamically add recent activities
const activities = [
"Logged in",
"Viewed product 'Product 1'",
"Added 'Product 2' to wishlist",
"Checked out order #1234"
];
const activityList = document.getElementById("activity-list");
activities.forEach((activity, index) => {
const li = document.createElement("li");
li.textContent = activity;
if (index < 2) {
li.classList.add("visible");
}
activityList.appendChild(li);
});
// Dynamically add notifications
const notifications = [
"Your order #5678 has been shipped",
"New product 'Product 4' added to wishlist",
"Price drop alert on 'Product 3'"
];
const notificationList = document.getElementById("notification-list");
notifications.forEach(notification => {
const li = document.createElement("li");
li.textContent = notification;
notificationList.appendChild(li);
});
});
function editProfile() {
window.location.href = "./assets/html/profileedit.html";
}
// Set last login time when the user logs in (first visit)
function setLastLoginTime() {
const now = new Date().toISOString();
localStorage.setItem("lastLoginTime", now);
const loginTimeElement = document.getElementById("last-login-time");
loginTimeElement.textContent = `Last login: ${new Date(now).toLocaleString()}`;
loginTimeElement.style.opacity = 1; // Ensure it's visible after animation
}
function calculateProfileCompletion() {
let completedFields = 0;
const totalFields = 3; // Assuming name, email, and phone are the fields
if (localStorage.getItem("profileName")) completedFields++;
if (localStorage.getItem("profileEmail")) completedFields++;
if (localStorage.getItem("profilePhone")) completedFields++;
const completionPercentage = Math.round((completedFields / totalFields) * 100);
document.getElementById("completion-percentage").textContent = `${completionPercentage}%`;
document.getElementById("progress-bar").style.width = `${completionPercentage}%`;
}
function addPersonalizedGreeting() {
const now = new Date();
const hour = now.getHours();
let greeting = "Hello";
if (hour < 12) {
greeting = "Good morning";
} else if (hour < 18) {
greeting = "Good afternoon";
} else {
greeting = "Good evening";
}
const name = localStorage.getItem("profileName") || "User";
document.getElementById("greeting").textContent = `${greeting}, ${name}!`;
}
function toggleActivities() {
const activityList = document.getElementById("activity-list");
const readMore = document.getElementById("read-more");
const activities = activityList.querySelectorAll("li");
activities.forEach((activity, index) => {
if (index >= 2) {
activity.classList.toggle("visible");
}
});
if (readMore.textContent === "Read More") {
readMore.textContent = "Show Less";
} else {
readMore.textContent = "Read More";
}
}
</script>
</body>
</html>