forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.html
381 lines (336 loc) · 13.2 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!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;
overflow: hidden;
}
.profile-container {
display: flex;
height: 100vh;
overflow-y: scroll;
}
.profile-sidebar {
width: 250px;
padding: 20px;
background: #f57d7d;
border-right: 1px solid #ddd;
box-sizing: border-box;
overflow-y: auto;
}
.profile-main {
flex: 1;
padding: 20px;
box-sizing: border-box;
overflow-y: auto;
}
.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;
}
.clear-item-btn, .clear-wishlist-btn {
background: #f44336;
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
border-radius: 5px;
margin-left: 10px;
transition: background 0.3s;
}
.clear-item-btn:hover, .clear-wishlist-btn:hover {
background: #d32f2f;
}
</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" id="wishlist">
<li>Product 1 <button class="clear-item-btn" onclick="clearWishlistItem(this)">Remove</button></li>
<li>Product 2 <button class="clear-item-btn" onclick="clearWishlistItem(this)">Remove</button></li>
<li>Product 3 <button class="clear-item-btn" onclick="clearWishlistItem(this)">Remove</button></li>
</ul>
<button class="clear-wishlist-btn" onclick="clearWishlist()">Clear Wishlist</button>
</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: ${lastLoginTime}`;
loginTimeElement.style.opacity = 1;
}
// Update Profile Completion
updateProfileCompletion();
// Set personalized greeting
setPersonalizedGreeting();
// Load activities
loadActivities();
// Load notifications
loadNotifications();
});
function setPersonalizedGreeting() {
const now = new Date();
const hours = now.getHours();
let greeting = "Hello";
if (hours < 12) {
greeting = "Good morning";
} else if (hours < 18) {
greeting = "Good afternoon";
} else {
greeting = "Good evening";
}
const profileName = document.querySelector(".profile-name").textContent;
document.getElementById("greeting").textContent = `${greeting}, ${profileName}!`;
}
function updateProfileCompletion() {
const requiredFields = ["profileName", "profileEmail", "profilePhone"];
let filledFields = 0;
requiredFields.forEach(field => {
if (localStorage.getItem(field)) {
filledFields++;
}
});
const completionPercentage = Math.round((filledFields / requiredFields.length) * 100);
document.getElementById("completion-percentage").textContent = `${completionPercentage}%`;
document.getElementById("progress-bar").style.width = `${completionPercentage}%`;
}
function editProfile() {
// Redirect to the profile editing page
window.location.href = "edit_profile.html";
}
function loadActivities() {
const activities = [
"You viewed Product 1",
"You added Product 2 to your cart",
"You made a purchase of Product 3"
];
const activityList = document.getElementById("activity-list");
activities.forEach((activity, index) => {
const li = document.createElement("li");
li.textContent = activity;
if (index < 3) {
li.classList.add("visible");
}
activityList.appendChild(li);
});
}
function toggleActivities() {
const activityListItems = document.querySelectorAll(".activity-list li");
const readMoreBtn = document.getElementById("read-more");
activityListItems.forEach(item => {
item.classList.toggle("visible");
});
if (readMoreBtn.textContent === "Read More") {
readMoreBtn.textContent = "Show Less";
} else {
readMoreBtn.textContent = "Read More";
}
}
function loadNotifications() {
const notifications = [
"Your order #1234 has been shipped",
"Your order #5678 is out for delivery",
"Your order #91011 has been delivered"
];
const notificationList = document.getElementById("notification-list");
notifications.forEach(notification => {
const li = document.createElement("li");
li.textContent = notification;
notificationList.appendChild(li);
});
}
function clearWishlist() {
const wishlist = document.getElementById("wishlist");
wishlist.innerHTML = ""; // Clear all items from the wishlist
// Optionally, you can also clear the wishlist from localStorage if needed
// localStorage.removeItem("wishlistItems");
}
function clearWishlistItem(button) {
const item = button.parentElement; // Get the parent list item
item.remove(); // Remove the item from the list
// Optionally, you can also update the wishlist in localStorage if needed
// updateWishlistInLocalStorage();
}
// Example function to update the wishlist in localStorage (if you're using localStorage)
function updateWishlistInLocalStorage() {
const wishlistItems = [];
document.querySelectorAll(".wishlist li").forEach(item => {
wishlistItems.push(item.textContent.trim());
});
localStorage.setItem("wishlistItems", JSON.stringify(wishlistItems));
}
</script>
</body>
</html>