-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopics.html
338 lines (281 loc) · 20.1 KB
/
topics.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>project_SN</title>
<link rel="stylesheet" type="text/css" href="assets/css/styles.css" />
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/fonts/ionicons.min.css">
<link rel="stylesheet" href="assets/fonts/iconicss.min.css">
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
<link rel="stylesheet" href="assets/css/Login-Form-Clean-1.css">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/Login-Form-Clean.css">
<link rel="stylesheet" href="assets/css/Navigation-with-Search.css">
</head>
<body>
<div class="container-fluid" id="tl_page_container">
<div class=" p-3 flex-column bd-highlight" id="page_header">
<div class="p-0 d-flex flex-fill justify-content-center bd-highlight" id="site_title">
<h1>AcademiKe.</h1>
</div>
<div class="p-1 d-flex flex-fill justify-content-center bd-highlight" id="user_profile_page_top">
<img id="profile_img_navbar"
class="rounded-circle border justify-content-center img-responsive shadow-sm visible"
style="width: 70px;height: 70px;" loading=" lazy" />
</div>
<div class="p-1 d-flex flex-fill justify-content-center bd-highlight" id="username_page_top">
<strong>username</strong>
</div>
</div>
<div class="icon-bar flex-row d-flex bd-highlight" id="navbar">
<!-- <div class="d-flex p-1 flex-column bd-highlight" id="page_header">
<div class="p-1 d-flex flex-fill justify-content-center bd-highlight" id="user_profile_page_top">
<img id="profile_img_navbar" class="rounded-circle border img-responsive shadow-sm visible"
style="width: 30px;height: 30px;" loading=" lazy" />
</div>
<div class="p-1 d-flex flex-fill justify-content-center bd-highlight" id="username_page_top">
<small>username</small>
</div>
</div> -->
<!-- <div class="p-1 bd-highlight" id="user-profile-navbar">
<center><img id="profile_img_navbar"
class="rounded-circle border justify-content-center flex-shrink img-responsive shadow-sm visible"
style="width: 50px;height: 50px;" loading=" lazy" /><br>
<small>username</small></center>
</div> -->
<div class="d-flex p-1 bd-highlight justify-content-around flex-fill">
<div class="p-1 bd-highlight">
<a href="#"><i class="fa fa-users" style="font-size: 2em;"></i></a>
</div>
<div class="p-1 bd-highlight">
<a href="#"><i class="fa fa-bell-o" style="font-size: 2em;"></i></a>
</div>
<div class="p-1 bd-highlight">
<a href="#"><i class="fa fa-search" style="font-size: 2em; font-weight: 1px;"></i></a>
</div>
<div class="p-1 bd-highlight">
<a href="#"><i class="fa fa-user-o" style="font-size: 2em;"></i></a>
</div>
</div>
<!-- <a class="p-2 bd-highlight" href="#"><i class="fa fa-bell" style="height: 30px; width: 30px;"></i></a>
<a class="p-2 bd-highlight" href="#"><i class="fa fa-search" style="height: 30px; width: 30px;"></i></a>
<a class="p-2 bd-highlight" href="#"><i class="fa fa-cog" style="height: 30px; width: 30px;"></i></a> -->
</div>
<div id="tl_content_container">
<ul class="nav nav-tabs nav-justified">
<li class="nav-item text-left"><a class="nav-link text-capitalize text-center" role="tab"
data-toggle="tab" href="index.html"
style="/*padding: 8px;*//*width: inherit;*//*margin: -5px;*//*padding-top: 8px;*//*margin-top: 3px;*//*margin-bottom: 0px;*/padding-left: 19px;margin-left: 11px;/*margin-left: 4px;*/margin-top: 3px;">People</a>
</li>
<li class="nav-item"><a class="nav-link active text-center" onclick="topic_posts()" id="tab-inactive"
role="tab" data-toggle="tab" href="#tab-2" style="margin-left: 4px;margin-top: 3px;">Topics</a>
</li>
</ul>
<div class="tab-content" id="tab_content">
<div class="tab-pane active" role="tabpanel" id="tab-1">
<div style="padding-left: 65px;" id="shared_by">
<small>shared by name</small>
</div>
<div class="conatiner d-flex flex-row bd-highlight" id="timeline_posts"
style="scroll-padding-left: 10px;">
<div class="p-1 flex-column bd-highlight" id="tl_profile_img_container"> <img
class="rounded-circle border img-responsive shadow-sm visible" id="profile_img_tl"
loading="lazy"> </div>
<div class="p-1 flex-fill bd-highlight">
<div class="d-flex p-0 bd-highlight">
<table>
<tr>
<td colspan="3">username here ∙</td>
<td>designation here ∙</td>
<td>Time
</td>
</tr>
<tr>
<td>institution here</td>
</tr>
</table>
<!-- <div id="tl_post_time" class="p-1 bd-highlight mr-auto"> <small> Time
</small></div> -->
<div id="tl_post_options" class="p-1 ml-auto ml-left bd-highlight"><small>...</small>
</div>
</div>
<div class="d-flex p-0 bd-highlight">
<div class="p-1 bd-highlight" id="tl_post_topic"><small>Topic
</small></div>
<div class="p-1 bd-highlight" id="tl_post_type"><small>Type</small></div>
</div>
<div class="p-0 bd-highlight">
<p>post body</p>
<div class="d-flex p-2 bd-highlight flex-fill justify-content-around">
<div class="p-2 bd-highlight"><a href="#"><i
class="icss-heart post_icon"></i></a><span><small>CONTENT
HERE</small></span></div>
<div class="p-2 bd-highlight"><a href="#"><i
class="icss-comment post_icon"></i></a><span><small>CONTENT
HERE</small></span></div>
<div class="p-2 bd-highlight"><a href="#"><i
class="icss-share post_icon"></i></a><span><small>CONTENT
HERE</small></span></div>
</div>
</div>
<hr>
</div>
</div>
<!-- <div id="tl_user" style="height: 50px;width: 80%;align-content: center;/*background-color: black;*/">
<div id="tl_p_pic_container" style="height: 40px;width: 40px;"><img class="rounded-circle img-fluid border shadow-sm visible" id="tl_p_pic" loading="lazy" style="width: 40px;height: 40px;float: left;"></div>
<div id="tl_username" style="float: right;margin-left: 50px;height: 40px;/*margin-top: 0px;*/"></div>
</div> -->
<div class="modal fade" role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">Edit Response</h6><button type="button" class="close"
data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
</div>
<div class="modal-body" style="overflow-y: auto; max-height: 700px;">
<p>The content of your modal.</p>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane active" role="tabpanel" id="tab-2">
</div>
<div class="tab-pane" role="tabpanel" id="tab-3">
<p>Content for tab 3.</p>
</div>
</div>
</div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
method: "GET",
url: "REST_api/topic_posts",
processData: false,
contentType: "application/json",
data: '',
success: function (r) {
var posts = JSON.parse(r);
// document.getElementById('username_page_top').innerHTML = r.Username;
console.log(r);
$.each(posts, function (index) {
const current_date = new Date();
const months = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",];
const post_date = new Date(posts[index].PostedAt * 1000);
var date_difference = current_date - post_date;
var date_difference_in_seconds = Math.floor((current_date - post_date) / 1000);
var date_difference_in_minutes = Math.floor(date_difference_in_seconds / 60);
var date_difference_in_hours = Math.floor(date_difference_in_minutes / 60);
var date_difference_in_days = Math.floor(date_difference_in_hours / 24);
var date_difference_in_years = Math.floor(date_difference_in_days / 365.25);
// console.log(date_difference_in_hours);
if (date_difference_in_seconds < 60) {
posts[index].PostedAt = date_difference_in_seconds + 'sec';
} else if ((date_difference_in_seconds >= 60) && (date_difference_in_minutes < 60)) {
posts[index].PostedAt = date_difference_in_minutes + 'min';
} else if ((date_difference_in_minutes >= 60) && (date_difference_in_hours < 24)) {
posts[index].PostedAt = date_difference_in_hours + 'h';
} else if ((date_difference_in_hours >= 24) && (date_difference_in_days < 7)) {
posts[index].PostedAt = date_difference_in_days + 'd';
} else if ((date_difference_in_days > 7) && (date_difference_in_years < 1)) {
posts[index].PostedAt = months[post_date.getUTCMonth()] + ', ' + post_date.getUTCDay();
;
} else {
posts[index].PostedAt = post_date.getUTCFullYear() + ', ' + months[post_date.getUTCMonth()] + ' ' + post_date.getUTCDay();
;
}
$('#tab-2').html(
$('#tab-2').html() + '<div class="conatiner d-flex flex-row bd-highlight" id="timeline_posts"style="scroll-padding-left: 10px;"><div class="p-1 flex-column bd-highlight" id="tl_profile_img_container"> <img class= "rounded-circle border img-responsive shadow-sm visible" id = "profile_img_tl" loading = "lazy" > </div > <div class="p-1 flex-fill bd-highlight"> <div class="d-flex p-0 bd-highlight"> <table> <tr> <td colspan="2">' + posts[index].PostedByName + ' ∙ ' + posts[index].PostedByDesignation + ' ∙ ' + posts[index].PostedAt + '</tr><tr><td>' + posts[index].PostedByInstitution + '</td></tr></table><div id="tl_post_options" class="p-1 ml-auto ml-left bd-highlight"><small>...</small></div></div><div class="d-flex p-0 bd-highlight"><div class="p-1 bd-highlight" id="tl_post_topic"><small> ' + posts[index].PostTopic + ' </small></div><div class="p-1 bd-highlight" id="tl_post_type"><small>' + posts[index].PostType + '</small></div> </div> <div class="p-0 bd-highlight"><p>' + posts[index].PostBody + '</p><div class="d-flex p-2 bd-highlight flex-fill justify-content-around"><div class="p-2 bd-highlight"><button class="post_icon" id="like_btn" data-id="' + posts[index].PostId + '"><i class="fa fa-check-square-o " ></i><span><small> ' + posts[index].PostLikes + '</small></span></button></div><div class="p-2 bd-highlight"><button class="post_icon" id="comment_btn" data-post_id="' + posts[index].PostId + '"><i class="fa fa-comment-o " ></i><span><small> ' + posts[index].PostComments + '</small></span></button></div><div class="p-2 bd-highlight"><button class="post_icon"><button class="post_icon" id="share_btn" data-shared_post_id = "' + posts[index].PostId + '"><i class="fa fa-share-alt " ></i><span><small> ' + posts[index].PostShares + '</small></span></button></div></div></div><hr></div></div>'
)
//ajax handler for displaying comments
$('[data-post_id]').click(function () {
var button_id = $(this).attr('data-post_id');
$.ajax({
method: "GET",
url: "REST_api/comments?post_id=" + $(this).attr('data-post_id'),
processData: false,
contentType: "application/json",
data: '',
success: function (r) {
var comment = JSON.parse(r || '{}');
$.each(comment, function (index) {
const current_date = new Date();
const months = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",];
const comment_date = new Date(comment[index].CommentedAt * 1000);
var date_difference = current_date - comment_date;
var date_difference_in_seconds = Math.floor((current_date - comment_date) / 1000);
var date_difference_in_minutes = Math.floor(date_difference_in_seconds / 60);
var date_difference_in_hours = Math.floor(date_difference_in_minutes / 60);
var date_difference_in_days = Math.floor(date_difference_in_hours / 24);
var date_difference_in_years = Math.floor(date_difference_in_days / 365.25);
// console.log(date_difference_in_hours);
if (date_difference_in_seconds < 60) {
comment[index].CommentedAt = date_difference_in_seconds + 'sec';
} else if ((date_difference_in_seconds >= 60) && (date_difference_in_minutes < 60)) {
comment[index].CommentedAt = date_difference_in_minutes + 'min';
} else if ((date_difference_in_minutes >= 60) && (date_difference_in_hours < 24)) {
comment[index].CommentedAt = date_difference_in_hours + 'h';
} else if ((date_difference_in_hours >= 24) && (date_difference_in_days < 7)) {
comment[index].CommentedAt = date_difference_in_days + 'd';
} else if ((date_difference_in_days > 7) && (date_difference_in_years < 1)) {
comment[index].CommentedAt = months[post_date.getUTCMonth()] + ', ' + comment_date.getUTCDay();
;
} else {
comment[index].CommentedAt = comment_date.getUTCFullYear() + ', ' + months[comment_date.getUTCMonth()] + ' ' + comment_date.getUTCDay();
;
}
showCommentsModal(comment, posts[index].PostedByName, posts[index].PostedByDesignation, posts[index].PostedAt, posts[index].PostedByInstitution, posts[index].PostTopic, posts[index].PostType, posts[index].PostBody, posts[index].PostId, posts[index].PostLikes, posts[index].PostComments, posts[index].PostShares, comment[index].CommentBody, comment[index].CommentedBy, comment[index].CommentedAt);
})
},
error: function () {
console.log('error');
}
})
})
// ajax handler for liking
$('[data-id]').click(function () {
var button_id = $(this).attr('data-id');
$.ajax({
method: "POST",
url: "REST_api/likes?post_id=" + $(this).attr('data-id'),
processData: false,
contentType: "application/json",
data: '',
success: function (r) {
var res = JSON.parse(r)
$("[data-id='" + button_id + "']").html('<i class="fa fa-check-square-o"></i><span ><small> ' + res.PostLikes + '</small></span>');
if (res.PostIsLiked) {
$("[data-id='" + button_id + "']").css("color", "limegreen");
} else {
$("[data-id='" + button_id + "']").css("color", "grey");
}
console.log(res);
},
error: function () {
console.log('error');
}
})
})
if (posts[index].PostIsLiked) {
$("[data-id='" + posts[index].PostId + "']").css("color", "limegreen");
}
if (posts[index].PostIsShared) {
$("[data-shared_post_id='" + posts[index].PostId + "']").css("color", "limegreen");
}
})
},
error: function (r) {
console.log(r)
}
});
}
)
</script>