-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.html
401 lines (368 loc) · 17.9 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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!--font awesome script-->
<script src="https://kit.fontawesome.com/bcbd543404.js" crossorigin="anonymous"></script>
<!-- Bootstrap cdn link-->
<!--Bootstrap script-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js " integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4 " crossorigin="anonymous "></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js " integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p " crossorigin="anonymous "></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js " integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT " crossorigin="anonymous "></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<!--Material.io links-->
<link href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">
<script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
<!--google fonts-->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<!--CSS-->
<link rel="stylesheet" href="css/profile.css">
<meta name="viewport" media content="width=device-width, initial-scale=1.0">
<title></title>
<style>
.main {
position: relative;
top: 40px;
max-width: 100%;
height: 640px;
}
.mdc-tab-bar {
--mdc-theme-primary: #ff6e83;
box-shadow: 0px -1px 2px rgba(0, 0, 0, 0.17);
height: 70px;
}
.mdc-tab__content img {
height: 120%;
}
.mdc-tab--active img {
filter: invert(61%) sepia(29%) saturate(3367%) hue-rotate(311deg) brightness(103%) contrast(101%);
}
.mdc-ripple-upgraded--background-focused,
.mdc-text-field {
background-color: white !important;
}
.mdc-tab-icon {
position: relative;
top: -10px;
}
</style>
</head>
<body>
<!--header for logo-brand-->
<header>
<div class="box">
<img class="logo" src="icons/Logo-whitebg.png">
</div>
<hr style="margin: 0; ">
</header>
<!--div for profile picture-->
<!--div for bio-->
<!--div for interest-->
<!--div for profile-->
<div class="container main">
<!--div for row of profiles-->
<div class="row">
<!--start first col-12 is the photo, name and city of user-->
<div class="col-12 photo-name-city-container">
<div class="container ">
<!--this can be card tho...-->
<div class="row">
<div class="col-7">
<!-- start user's profile photo and change photo-->
<div class="profile-picture-div text-center">
<img id="profile-picture" class="img-thumbnail img-fluid profile-pic-click center-block" />
<button class="btn shadow-none upload-btn" data-bs-toggle="modal" data-bs-target="#uploadphotoModal">
<i class="fa fa-camera select" style="z-index: 10;font-size: 16px; color: #3f464d;"></i>
</button>
</div>
</div>
<!--end of user's profile photo and change photo div-->
<div class="col-5">
<!--start user's name and city-->
<div class="city-name-div">
<h4 class="users-name">Helena Grey</h4>
<p class="users-city">Quezon City</p>
</div>
</div>
<!-- end of user's name and city div -->
</div>
</div>
</div>
<!-- end of first col-12 is the photo, name and city of user div-->
<!--start second col-12 is the user's bio-->
<div class="col-12 p-0 bio">
<div class="container bio">
<!--line behind the text
--Bio----------------------edit--
-->
<h4 class="back"><span class="bio-title">Bio</span>
<button class="edit-bio-btn btn shadow-none" data-bs-toggle="modal" data-bs-target="#bioModal">
<i class="fa fa-pencil edit"></i>
</button>
</h4>
<div class="bio-area-div text-wrap">
<span id="bio-area" class="text-wrap bio-area-text">
Write something about yourself...
</span>
</div>
</div>
</div>
<!--end of second col-12 is the user's bio div-->
<!--start second col-12 is the user's interests-->
<div class="col-12 p-0 interest">
<div class="container interest mb-5" id="interests">
<h4 class="back"><span class="bio-title">Interests</span></h4>
</div>
</div>
<!--end of second col-12 is the user's bio div-->
</div>
</div>
<!--tabs-->
<div class="mdc-tab-bar" role="tablist" style="position: fixed; bottom: 0; left: 0; z-index: 100; background-color: white;">
<div class="mdc-tab-scroller">
<div class="mdc-tab-scroller__scroll-area mdc-tab-scroll-area--scroll" style="overflow-y:hidden; margin-bottom: 0;">
<div class="mdc-tab-scroller__scroll-content">
<!--Matchmaking-->
<button id="mdc-tab-1" onclick="location.href='./suggestions.html'" class="mdc-tab mdc-ripple-upgraded" role="tab" aria-selected="true" tabindex="0">
<span class="mdc-tab__content">
<span class="mdc-tab__icon" aria-hidden="true">
<img src="./icons/match.png">
</span>
</span>
<span class="mdc-tab-indicator">
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline" style="border-color: transparent !important;"></span>
</span>
</button>
<!--Messaging-->
<button id="mdc-tab-2" onclick="location.href='./messaging/inbox.html'" class="mdc-tab mdc-ripple-upgraded" role="tab" aria-selected="true" tabindex="0">
<span class="mdc-tab__content">
<span class="mdc-tab__icon" aria-hidden="true">
<img src="./icons/message.png">
</span>
</span>
<span class="mdc-tab-indicator">
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline" style="border-color: transparent !important;"></span>
</span>
</button>
<!--Profile-->
<button id="mdc-tab-3" class="mdc-tab mdc-tab--active mdc-ripple-upgraded" role="tab" aria-selected="true" tabindex="0">
<span class="mdc-tab__content">
<span class="mdc-tab__icon" aria-hidden="true">
<img src="./icons/profile.png">
</span>
</span>
<span class="mdc-tab-indicator">
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline" style="border-color: transparent !important;"></span>
</span>
</button>
<!--Settings-->
<button id="mdc-tab-4" onclick="location.href='./settings/index.html'" class="mdc-tab mdc-ripple-upgraded" role="tab" aria-selected="true" tabindex="0">
<span class="mdc-tab__content">
<span class="mdc-tab__icon" aria-hidden="true">
<img src="./icons/settings.png">
</span>
</span>
<span class="mdc-tab-indicator">
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline" style="border-color: transparent !important;"></span>
</span>
</button>
</div>
</div>
</div>
</div>
<!--modal for profile picture-->
<div class="modal" id="uploadphotoModal" tabindex="-1" role="dialog" aria-labelledby="uploadphotoModalLabel" aria-hidden="true" data-bs-backdrop="true">
<div class="modal-dialog modal-sm"></div>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="uploadphotoModalLabel" style="color: #8999a8; font-size: 18px;">Change your profile picture</h5>
<button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container mx-auto my-auto" style="">
<!--profile photo-->
<div class="viewer-photo">
<img id="viewer" class="img-thumbnail img-fluid mx-auto my-auto" style="z-index: 1000000; width: 100%; border-radius: 50%;" />
</div>
<!--profile-pic form-->
<form id="profile-picture-form" class="form-profPic">
<label class="upload-photo" for="uploadPic">
<i class="fa fa-plus" style="color: #FF6e83;"></i>
</label>
<input type="file" id="uploadPic" />
<br>
<hr class="dropdown-divider" style="position: relative; top: 30px;">
<input type="submit" id="save-pic" value="Save Changes" data-bs-dismiss="modal" class="btn save-changes" />
</form>
</div>
</div>
</div>
</div>
<!--modal for editing bio-->
<div class="modal" id="bioModal" tabindex="-1" role="dialog" aria-labelledby="bioModalLabel" aria-hidden="true" data-bs-backdrop="true">
<div class="modal-dialog modal-sm"></div>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="uploadphotoModalLabel">Write about yourself!</h5>
<button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container mx-auto my-auto" style="height: 200px;">
<!--bio form-->
<form id="bio-form" class="bio-form">
<textarea type="text" id="bio" class="edit-bio-input shadow-none"></textarea>
<input id="save-bio" type="submit" value="Save Changes" data-bs-dismiss="modal" class="btn save-changes" />
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<script src="./scripts/constants.js"></script>
<script>
let user_id = localStorage.getItem('user_id');
let access_token = localStorage.getItem('access_token');
window.addEventListener('load', function() {
fetch(API_URL + 'api/profiles/' + user_id, {
method: 'GET',
headers: {
authorization: access_token
},
})
.then((res) => res.json())
.then((res) => {
user = JSON.parse(atob(localStorage.getItem('access_token').split('.')[1]));
document.querySelector('.users-name').innerText =
user.firstName + ' ' + user.lastName;
document.querySelector('.users-city').innerText =
user.address.city;
document.querySelector('#bio-area').innerText =
res.user.shortDescription;
document
.querySelector('#profile-picture')
.setAttribute('src', res.user.picture.originalImage);
document
.querySelector('#viewer')
.setAttribute('src', res.user.picture.originalImage);
let fields = [
'astrologicalSign',
'religion',
'politicalView',
'smoke',
'wantKids',
'wantMarried',
'sports',
'hobbies',
'musicGenre',
'movieGenre',
'pets',
'books',
'food',
'drinks',
];
let names = {
astrologicalSign: 'Astrological Sign',
religion: 'Religion',
politicalView: 'Political View',
smoke: 'Smoke',
wantKids: 'Want to Have Kids',
wantMarried: 'Want to be Married',
sports: 'Sports',
hobbies: 'Hobbies',
musicGenre: 'Music Genres',
movieGenre: 'Movies and TV Genres',
pets: 'Pets',
books: 'Books',
food: 'Food',
drinks: 'Drinks',
};
let el = document.querySelector('#interests')
let data = `<div class="interest-div mb-3">`
for (let i = 0; i < fields.length; i++) {
let value = res.interest[fields[i]];
value = typeof value !== 'object' ? [value] : value;
data += `<h5 class="interest-category">${names[fields[i]]}</h5>`;
for (let j = 0; j < value.length; j++) {
data += `<span class="badge rounded-pill">${value[j]}</span>`;
}
}
data += '</div>';
el.innerHTML += data;
});
});
document
.getElementById('save-pic')
.addEventListener('click', (e) => {
var input = document.querySelector('input[type="file"]');
var data = new FormData();
data.append('file', input.files[0]);
fetch(API_URL + 'api/profiles/' + user_id, {
method: 'POST',
headers: {
authorization: access_token
},
body: data,
}).then(res => res.json()).then(res => {
document.querySelector('#profile-picture').setAttribute('src', res.user.picture.originalImage)
})
});
/*document
.getElementById('profile-picture-form')
.addEventListener('submit', (e) => {
e.preventDefault();
var input = document.querySelector('input[type="file"]');
var data = new FormData();
data.append('file', input.files[0]);
fetch(API_URL + 'api/profiles/' + user_id, {
method: 'POST',
headers: {
authorization: access_token
},
body: data,
});
});*/
document.getElementById('save-bio').addEventListener('click', (e) => {
let bio = document.querySelector('#bio').value;
fetch(API_URL + 'api/profiles/' + user_id, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
authorization: access_token,
},
body: JSON.stringify({
bio
}),
}).then((res) => res.json()).then((res) => {
console.log(res)
if (res.success) document.querySelector('#bio-area').innerText = bio;
});
})
const readURL = (input) => {
if (input.files && input.files[0]) {
let reader = new FileReader();
reader.onload = function(e) {
document.querySelector("#viewer").setAttribute('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
document.querySelector("#uploadPic").addEventListener('change', () => {
readURL(document.querySelector("#uploadPic"));
});
/*document.getElementById('bio-form').addEventListener('submit', (e) => {
e.preventDefault();
let bio = document.querySelector('#bio').value;
fetch(API_URL + 'api/profiles/' + user_id, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
authorization: access_token,
},
body: JSON.stringify({
bio
}),
});
});*/
new mdc.tabBar.MDCTabBar(document.querySelector('.mdc-tab-bar'));
</script>