-
Notifications
You must be signed in to change notification settings - Fork 0
/
footer.php
856 lines (821 loc) · 41.5 KB
/
footer.php
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
<footer id="footer">
<div id="footerDiv" style="display: flex;justify-content: center;align-content: center;align-items: center;width: 80%;margin:auto;">
<div style="width: 25%;">
<h1>Social Site</h1>
</div>
<div style="width: 37.5%;">
<b style="text-decoration: underline;">Pages</b><br>
<a class="coolButtonFooter" href="index.php">Home</a><br>
<a class="coolButtonFooter" href="profile.php">Profile</a><br>
<a class="coolButtonFooter" href="messenger.php">Messenger</a><br>
</div>
<div style="width: 37.5%;">
<b style="text-decoration: underline;">About</b><br>
<a class="coolButtonFooter" href="about.php">About Social Site</a><br>
<a class="coolButtonFooter" href="#" onclick="toggleFeedbackForm()">Feedback</a><br>
<a class="coolButtonFooter" target="_blank" href="https://github.com/nikhilshakohi/socialsite">Source Code</a><br>
</div>
</div>
</footer>
</body>
<script>
var globalMessage=""; //For storing chats temporarily for comparing with prev.
function copy(postId){
var link=document.getElementById(postId.id);
if(postId.value!=''){
setTimeout(function(){document.getElementById("messagePopup"+postId.id).style.display="none";},3000)
document.getElementById("messagePopup"+postId.id).style.display="block";
document.getElementById("messagePopup"+postId.id).innerHTML='Link Copied to Clipboard!';/*<b>'+link.value+'</b>*/
}else{
alert("No Link Found..!");
}
document.getElementById(postId.id).type="text";
link.select();document.execCommand("copy");document.getElementById(postId.id).type="hidden";
}
function showContent(){
document.getElementById("pageLoader").style.display="none";
<?php
if(!isset($_SESSION['id'])){
?>
document.getElementById("formsContainer").style.display="block";
<?php
}else{
?>
var displayType;
var url = window.location.href;
var urlPage = url.split("/");
(urlPage[4].split("?")[0] == "index.php" || urlPage[4].split("?")[0] == "messenger.php") ? displayType = "flex" : displayType = "block";
document.getElementById("content").style.display=displayType;
<?php
}
?>
}
function showMenuOptions(postId){
if(document.getElementById('menuOptionsFor'+postId).style.display=='block'){
document.getElementById('menuOptionsFor'+postId).style.display='none';
}else{
document.getElementById('menuOptionsFor'+postId).style.display='block';
}
}
function showMenuOptionsOfComment(commentId){
if(document.getElementById('menuOptionsForCommentOf'+commentId).style.display=='inline-flex'){
document.getElementById('menuOptionsForCommentOf'+commentId).style.display='none';
}else{
document.getElementById('menuOptionsForCommentOf'+commentId).style.display='inline-flex';
}
}
function showPostDeleteDiv(postId){
var postId = postId;
var showPostDelete = 'DummyText';
document.getElementById(postId+'DeleteButton').innerHTML="Loading..";
var data = 'showPostDelete='+showPostDelete+'&postId='+postId;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
document.getElementById("deletePostDiv").style.display="block";
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById("deletePostDiv").innerHTML=this.responseText;
document.getElementById(postId+'DeleteButton').innerHTML="delete";
}
}
}
}
function confirmDeletePost(postId){
var postId = postId;
var confirmedDeletePost = 'DummyText';
var data = 'confirmedDeletePost='+confirmedDeletePost+'&postId='+postId;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById('postDivOf'+postId).style.padding='0';
document.getElementById('postDivOf'+postId).innerHTML='deleted';
setTimeout(function(){document.getElementById('postDivOf'+postId).innerHTML='';},1500);
document.getElementById("deletePostDiv").style.display="none";
}
}
}
}
/*Change Privacy*/
function showPostPrivacyDiv(postId){
var postId = postId;
var showPostPrivacy = 'DummyText';
document.getElementById(postId+'PrivacyButton').innerHTML="Loading..";
var data = 'showPostPrivacy='+showPostPrivacy+'&postId='+postId;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
document.getElementById("privacyPostDiv").style.display="block";
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById("privacyPostDiv").innerHTML=this.responseText;
document.getElementById(postId+'PrivacyButton').innerHTML="privacy";
}
}
}
}
function confirmUpdatePrivacyPost(postId){
var postId = postId;
UpdatedPrivacyStatus = document.getElementById("UpdatedPrivacyStatus"+postId).value;
var confirmUpdatePrivacyPost = 'DummyText';
var data = 'confirmUpdatePrivacyPost='+confirmUpdatePrivacyPost+'&postId='+postId+"&UpdatedPrivacyStatus="+UpdatedPrivacyStatus;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
var output = this.responseText;
document.getElementById('confirmUpdatePrivacyPost'+postId).innerHTML='<div class = "loaderButton"></div>';
setTimeout(function(){
document.getElementById('confirmUpdatePrivacyPost'+postId).innerHTML=output;
},1000);
setTimeout(function(){
document.getElementById("privacyPostDiv").style.display="none";
},1500);
if(UpdatedPrivacyStatus=='public'){
document.getElementById("postPrivacyShow"+postId).innerHTML='<span title="This Post is visible to anyone" class = "postPrivacyStyle"> 🌎</span>';
}else if(UpdatedPrivacyStatus=='private'){
document.getElementById("postPrivacyShow"+postId).innerHTML='<span title="This Post is visible to only you" class = "postPrivacyStyle"> 🔒</span>';
}else if(UpdatedPrivacyStatus=='friends'){
document.getElementById("postPrivacyShow"+postId).innerHTML='<span title="This Post is visible to only your friends" class = "postPrivacyStyle"> 👥</span>';
}
}
}
}
}
/*Delete Comment*/
function showCommentDeleteDiv(commentId){
var commentId = commentId;
var showCommentDelete = 'DummyText';
document.getElementById(commentId+'commentDeleteButton').innerHTML="Loading..";
var data = 'showCommentDelete='+showCommentDelete+'&commentId='+commentId;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
document.getElementById("deleteCommentDiv").style.display="block";
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById("deleteCommentDiv").innerHTML=this.responseText;
document.getElementById(commentId+'commentDeleteButton').innerHTML="delete";
}
}
}
}
function confirmDeleteComment(commentId){
var commentId = commentId;
var confirmedDeleteComment = 'DummyText';
document.getElementById("confirmDeleteComment"+commentId).innerHTML="deleting...";
var data = 'confirmedDeleteComment='+confirmedDeleteComment+'&commentId='+commentId;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
eachResponse=this.responseText.split('-period-');
document.getElementById("postCommentsCount"+eachResponse[0]).innerHTML=eachResponse[1];
document.getElementById('commentDivOf'+commentId).innerHTML='deleted';
setTimeout(function(){document.getElementById('commentDivOf'+commentId).innerHTML='';},1500);
document.getElementById("deleteCommentDiv").style.display="none";
}
}
}
}
function showThisProfileDiv(type){
document.getElementById('userProfileDetailsDiv').style.display='none';
document.getElementById('userProfilePostsDiv').style.display='none';
document.getElementById('userProfileFriendsDiv').style.display='none';
document.getElementById('userProfileFriendRequestsDiv').style.display='none';
document.getElementById('userProfileDetailsButton').style.color='black';
document.getElementById('userProfilePostsButton').style.color='black';
document.getElementById('userProfileFriendsButton').style.color='black';
document.getElementById('userProfileFriendRequestsButton').style.color='black';
document.getElementById('userProfileDetailsButtonDiv').style.borderBottom='none';
document.getElementById('userProfilePostsButtonDiv').style.borderBottom='none';
document.getElementById('userProfileFriendsButtonDiv').style.borderBottom='none';
document.getElementById('userProfileFriendRequestsButtonDiv').style.borderBottom='none';
document.getElementById('userProfile'+type+'Div').style.display='block';
document.getElementById('userProfile'+type+'Button').style.color='green';
document.getElementById('userProfile'+type+'ButtonDiv').style.borderBottom='5px solid green';
}
function showLikesDetails(postId){
if(document.getElementById(postId+'LikeDetail').style.display=="none"){
document.getElementById('postLikesCount'+postId).style.backgroundColor="rgba(180,180,180,0.7)";
document.getElementById(postId+'LikeDetail').style.display="block";
}else if(document.getElementById(postId+'LikeDetail').style.display=="block"){
document.getElementById(postId+'LikeDetail').style.display="none";
document.getElementById('postLikesCount'+postId).style.backgroundColor="rgba(230, 230, 230, 1.0)";
}
}
function showPostEditDiv(postId){
var postId = postId;
var caption = document.getElementById("postCaption"+postId).innerHTML;
var showPostCaption = 'DummyText';
document.getElementById(postId+'EditButton').innerHTML="Loading..";
var data = 'showPostCaption='+showPostCaption+'&postId='+postId+'&caption='+caption;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
document.getElementById("editPostDiv").style.display="block";
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById("editPostDiv").innerHTML=this.responseText;
document.getElementById("editedCaption"+postId).innerHTML=caption;
document.getElementById(postId+'EditButton').innerHTML="edit";
}
}
}
}
function editedPostCaption(postId){
var postId = postId;
var caption = document.getElementById("editedCaption"+postId).value;
var editPost = 'DummyText';
var data = 'editPost='+editPost+'&postId='+postId+'&caption='+caption;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
var output=this.responseText;
document.getElementById("menuOptionsFor"+postId).style.display="none";
document.getElementById("editPostDiv").style.display="none";
document.getElementById('postCaption'+postId).innerHTML="<div style='display:inline-flex' class='loaderButton'></div>";
setTimeout(function(){document.getElementById('postCaption'+postId).innerHTML=output;},500);
}
}
}
}
/*Edit Comment*/
function showCommentEditDiv(commentId,comment){
var commentId = commentId;
var comment = document.getElementById("postComment"+commentId).innerHTML;
var showComment = 'DummyText';
document.getElementById(commentId+'commentEditButton').innerHTML="Loading..";
var data = 'showComment='+showComment+'&commentId='+commentId+'&comment='+comment;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
document.getElementById("editCommentDiv").style.display="block";
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
document.getElementById("editCommentDiv").innerHTML=this.responseText;
document.getElementById("editedComment"+commentId).innerHTML=comment;
document.getElementById(commentId+'commentEditButton').innerHTML="edit";
}
}
}
}
function editedComment(commentId){
var commentId = commentId;
var comment = document.getElementById("editedComment"+commentId).value;
document.getElementById("editedCommentConfirmButton"+commentId).innerHTML="<div class='loaderButton'></div>"
var editComment = 'DummyText';
var data = 'editComment='+editComment+'&commentId='+commentId+'&comment='+comment;
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
var output=this.responseText;
document.getElementById("menuOptionsForCommentOf"+commentId).style.display="none";
document.getElementById("editCommentDiv").style.display="none";
document.getElementById('postComment'+commentId).innerHTML="<div style='display:inline-flex' class='loaderButton'></div>";
setTimeout(function(){document.getElementById('postComment'+commentId).innerHTML=output;},500);
}
}
}
}
function closeEditDiv(){
document.getElementById("editPostDiv").style.display="none";
}
function closeEditCommentDiv(){
document.getElementById("editCommentDiv").style.display="none";
}
function closeDeleteDiv(){
document.getElementById("deletePostDiv").style.display="none";
}
function closePrivacyDiv(){
document.getElementById("privacyPostDiv").style.display="none";
}
function closeDeleteCommentDiv(){
document.getElementById("deleteCommentDiv").style.display="none";
}
function likeSubmit(postId,likeStatus){
var likeStatus=likeStatus;
var postId = postId;
if(likeStatus==1){
document.getElementById("likeDiv"+postId).innerHTML="<div class='loaderButton' style='display:inline-flex'></div>";
}else{
document.getElementById("unLikeDiv"+postId).innerHTML="<div class='loaderButton' style='display:inline-flex'></div>";
}
var userId = document.getElementById("userId"+postId).value;
var userFullName = document.getElementById("userFullName"+postId).value;
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var likeSubmit="";var unLikeSubmit="";//Declaring variables for POST Submit
if(likeStatus==1){
var data = "likeSubmit="+likeSubmit+"&postId="+postId+"&userId="+userId+"&userFullName="+userFullName;
}else{
var data = "unLikeSubmit="+unLikeSubmit+"&postId="+postId+"&userId="+userId+"&userFullName="+userFullName;
}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
if(likeStatus==1){
var eachResponse=this.responseText.split('-period-');
document.getElementById('likeDiv'+postId).style.display="none";
document.getElementById('unLikeDiv'+postId).style.display="block";
document.getElementById('unLikeDiv'+postId).classList.add("likedAnimation");
document.getElementById("postLikesCount"+postId).innerHTML=eachResponse[0];
document.getElementById(postId+"newLikeDetail").innerHTML=eachResponse[1];
document.getElementById("likeDiv"+postId).innerHTML="Like";
}else{
var eachResponse=this.responseText.split('-period-');
document.getElementById('likeDiv'+postId).style.display="block";
document.getElementById('unLikeDiv'+postId).style.display="none";
document.getElementById("postLikesCount"+postId).innerHTML=eachResponse[0];
document.getElementById(postId+"newLikeDetail").innerHTML=eachResponse[1];
document.getElementById("unLikeDiv"+postId).innerHTML="Liked!";
}
} else {
alert("There was a problem with the request.");
}
}
}
}
function connectionToggle(userA,userB,connectionId,connectionStatus){
var connectionStatus=connectionStatus;
var userA = userA;
var userB = userB;
var connectionId = connectionId;
if(connectionStatus==1){
document.getElementById("addConnection"+userA+userB).innerHTML="<div class='loaderButton'></div>";
}else{
document.getElementById("confirmConnection"+userA+userB).innerHTML="<div class='loaderButton'></div>";
}
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var addConnection="";var updateConnection="";//Declaring variables for POST Submit
if(connectionStatus==1){
var data = "addConnection="+addConnection+"&userA="+userA+"&userB="+userB+"&connectionStatus="+connectionStatus;
}else{
var data = "updateConnection="+updateConnection+"&connectionId="+connectionId+"&connectionStatus="+connectionStatus+"&userA="+userA+"&userB="+userB;
}
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
if(connectionStatus==1){
document.getElementById("addConnection"+userA+userB).style.display="none";
document.getElementById("yetConfirmConnection"+userA+userB).style.display="block";
}else{
document.getElementById("confirmConnection"+userA+userB).style.display="none";
document.getElementById("confirmedConnection"+userA+userB).style.display="block";
document.getElementById("showFriendsAfterConfirm").innerHTML+=this.responseText;/*friends appended to friendsList*/
document.getElementById("newPostsAfterFriends").style.display="block";
}
} else {
alert("There was a problem with the request.");
}
}
}
}
/*Add Comments*/
function addComment(postId,userId,userFullName){
var postId=postId;
var userId = userId;
var userFullName = userFullName;
document.getElementById('commentSubmitOf'+userId+postId).innerHTML="<span class='loaderButton'></span>";
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var userComment=document.getElementById('postOf'+userId+postId).value;
if(userComment!=''){
var addComment="DummyText";//Declaring variables for POST Submit
var data = "addComment="+addComment+"&postId="+postId+"&userId="+userId+"&userFullName="+userFullName+"&userComment="+userComment;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
eachResponse=this.responseText.split('-period-');
document.getElementById("postCommentsCount"+postId).innerHTML=eachResponse[0];
document.getElementById('newCommentOf'+userId+postId).innerHTML+=eachResponse[1];/*new comment appended to comments*/
document.getElementById('postOf'+userId+postId).value='';
document.getElementById('commentSubmitOf'+userId+postId).innerHTML="Submit";
} else {
alert("There was a problem with the request.");
}
}
}
}else{
document.getElementById('commentSubmitOf'+userId+postId).innerHTML="Submit";
}
}
/*Add Profile Picture*/
function addPost(username,type){
var username=username;
var type = type;
var caption = document.getElementById('postCaptionEntry'+username).value;
var postPrivacy = document.getElementById('postPrivacy'+username).value;
document.getElementById('profilePictureSubmitOf'+username).innerHTML="<span class='loaderButton'></span>";
var myFile = document.getElementById('postUploadFile');
/*If User selects only to write and no Image Uploaded*/
if(myFile.value==''){
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var uploadPostOnlyCaption="DummyText";//Declaring variables for POST Submit
var data = "uploadPostOnlyCaption="+uploadPostOnlyCaption+"&username="+username+"&caption="+caption+"&type="+type+"&postPrivacy="+postPrivacy;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
if(document.getElementById('newPostAdded').innerHTML!="No Posts Added yet.."){
document.getElementById('newPostAdded').innerHTML=this.responseText+document.getElementById('newPostAdded').innerHTML;
}else{
document.getElementById('newPostAdded').innerHTML=this.responseText;
}
document.getElementById('postCaptionEntry'+username).value='';
document.getElementById('getUploadedFileName').innerHTML='';
document.getElementById('profilePictureSubmitOf'+username).innerHTML='Upload';
} else {
alert("There was a problem with the request.");
}
}
}
}else{
var files = myFile.files;
var formData = new FormData();
var file = files[0];
formData.append('postUploadFile', file, file.name);
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var uploadPost="DummyText";//Declaring variables for POST Submit
var data = "uploadPost="+uploadPost+"&username="+username+"&caption="+caption+"&type="+type+"&postPrivacy="+postPrivacy;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
/*For File*/
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhrn = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhrn = new ActiveXObject("Microsoft.XMLHTTP");}
xhrn.open("POST", "conditions.php", true);
xhrn.send(formData);
xhrn.onreadystatechange = function(){
if(xhrn.readyState == 4) {
if (xhrn.status == 200) {
eachResponse=this.responseText.split('-period-');
if(eachResponse[0]!='UploadError'){
if(type=='profilePicture'){
document.getElementById('profilePicture').src=eachResponse[0];
document.getElementById('profilePicImage').src=eachResponse[0];
document.getElementById('headerUserProfilePicture').src=eachResponse[0];
}
if(document.getElementById('newPostAdded').innerHTML!="No Posts Added yet.."){
document.getElementById('newPostAdded').innerHTML=eachResponse[1]+document.getElementById('newPostAdded').innerHTML;
}else{
document.getElementById('newPostAdded').innerHTML=eachResponse[1];
}
document.getElementById('postCaptionEntry'+username).value='';
document.getElementById('getUploadedFileName').innerHTML='';
document.getElementById('profilePictureSubmitOf'+username).innerHTML='Upload';
}else{
document.getElementById('postCaptionEntry'+username).value='';
document.getElementById('getUploadedFileName').innerHTML='';
document.getElementById('profilePictureSubmitOf'+username).innerHTML='File too Big';
setTimeout(function(){document.getElementById('profilePictureSubmitOf'+username).innerHTML='Upload';},2000);
}
} else {
alert("There was a problem with the request.");
}
}
}
}
}
/*Check Messages*/
function checkMessages(currentUsername,friendUsername){
var currentUsername=currentUsername;
var friendUsername=friendUsername;
document.getElementById("contentRightPart").style.display="block";
document.getElementById("contentLeftPart").classList.add("hideInSmall");
document.getElementById(friendUsername+'Messageloader').innerHTML="<div class='loaderButton'></div>";
document.getElementById("contentRightPart").innerHTML="<div class='loaderButton'></div>";
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var checkMessages="DummyText";//Declaring variables for POST Submit
var data = "checkMessages="+checkMessages+"¤tUsername="+currentUsername+"&friendUsername="+friendUsername;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
var friendButtons=document.getElementsByClassName('friendLinkDiv');
for(var i=0;i<friendButtons.length;i++){
friendButtons[i].style.backgroundColor="";
friendButtons[i].style.color="black";
}
document.getElementById("selectFriendButton"+friendUsername).style.backgroundColor="rgba(70,70,150,0.7)";
document.getElementById("selectFriendButton"+friendUsername).style.color="white";
/*New Message Tag*/
document.getElementById(friendUsername+"newMsgTag"+currentUsername).style.display="none";
eachResponse=this.responseText.split("-period-");
document.getElementById("contentRightPart").innerHTML=eachResponse[0];
document.getElementById("newMessageCount").innerHTML=eachResponse[1];
document.getElementById(friendUsername+'Messageloader').innerHTML="";
var currentUsernameId=document.getElementById(currentUsername+"getCurrentUserId"+friendUsername).innerHTML;
var friendUsernameId=document.getElementById(currentUsername+"getFriendUserId"+friendUsername).innerHTML;
document.getElementById(currentUsernameId+"chatInput"+friendUsernameId).focus();
setInterval(checkMessageContinously,2000,currentUsernameId,friendUsernameId);
} else {
alert("There was a problem with the request.");
}
}
}
}
function checkMessageContinously(currentUserId,friendUserId){
var currentUserId=currentUserId;
var friendUserId=friendUserId;
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var checkMessagesContinuosly="DummyText";//Declaring variables for POST Submit
var data = "checkMessagesContinuosly="+checkMessagesContinuosly+"¤tUserId="+currentUserId+"&friendUserId="+friendUserId;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
if(document.getElementById("messageMiddlePart"+friendUserId)){
//To update chat only when new message is received
if(globalMessage != this.responseText){
document.getElementById("messageMiddlePart"+friendUserId).innerHTML=this.responseText;
globalMessage = this.responseText;
//console.count("checks");
}
}
} else {
alert("There was a problem with the request.");
}
}
}
}
/*Show Friends in Messages*/
function showMessagesDiv(){
document.getElementById("contentRightPart").style.display="none";
document.getElementById("contentLeftPart").classList.remove("hideInSmall");
}
/*Send Message*/
function sendMessage(currentUserId,friendUserId){
var currentUserId=currentUserId;
var friendUserId=friendUserId;
var message=document.getElementById(currentUserId+'chatInput'+friendUserId).value;
document.getElementById(currentUserId+'chatInputSend'+friendUserId).innerHTML="<div class='loaderButton'></div>";
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var sendMessage="DummyText";//Declaring variables for POST Submit
var data = "sendMessage="+sendMessage+"¤tUserId="+currentUserId+"&friendUserId="+friendUserId+"&message="+message;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById("messageMiddlePart"+friendUserId).innerHTML=this.responseText;
document.getElementById(currentUserId+'chatInput'+friendUserId).value='';
document.getElementById(currentUserId+'chatInputSend'+friendUserId).innerHTML="Send";
document.getElementById(currentUserId+'chatInput'+friendUserId).focus();
} else {
alert("There was a problem with the request.");
}
}
}
}
function toggleFeedbackForm(){
if(document.getElementById("feedbackFormDiv").style.display=="block"){
document.getElementById("feedbackFormDiv").style.display="none";
}else{
document.getElementById("feedbackFormDiv").style.display="block";
}
}
function sendFeedback(){
var userFeedback=document.getElementById("feedbackInput").value;
var userId=document.getElementById("feedbackUserId").value;
var userFullName=document.getElementById("feedbackUserFullName").value;
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var sendFeedback="DummyText";//Declaring variables for POST Submit
var data = "sendFeedback="+sendFeedback+"&userId="+userId+"&userFullName="+userFullName+"&userFeedback="+userFeedback;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
var output=this.responseText;
setTimeout(function(){document.getElementById("feedbackContent").innerHTML=output;},2000);
document.getElementById("feedbackContent").innerHTML="<br><br><div class='loaderButton'></div>";
} else {
alert("There was a problem with the request.");
}
}
}
}
function forgotPassword(){
if(document.getElementById("forgotPasswordDiv").style.display=="block"){
document.getElementById("forgotPasswordDiv").style.display="none";
}else{
document.getElementById("forgotPasswordDiv").style.display="block";
}
}
function forgotPasswordSendEmail(){
var emailId=document.getElementById("emailIdToBeRecovered").value;
var tryAgain=document.getElementById("forgotPasswordContent").innerHTML;
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var forgotPasswordSendEmail="DummyText";//Declaring variables for POST Submit
var data = "forgotPasswordSendEmail="+forgotPasswordSendEmail+"&emailId="+emailId;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
var eachResponse=this.responseText.split("-period-");
setTimeout(function(){
if(eachResponse[1]=='errorMessage'){
document.getElementById("forgotPasswordContent").innerHTML=tryAgain+eachResponse[0];
}else{
document.getElementById("forgotPasswordContent").innerHTML=eachResponse[0];
}
},2000);
document.getElementById("forgotPasswordContent").innerHTML="<br><br><div class='loaderButton'></div>";
} else {
alert("There was a problem with the request.");
}
}
}
}
function signupUser(){
var username = document.getElementById("signupUsername").value;
var mobile = document.getElementById("signupMobile").value;
var email = document.getElementById("signupEmail").value;
var firstName = document.getElementById("signupFirstName").value;
var lastName = document.getElementById("signupLastName").value;
var password = document.getElementById("signupPassword").value;
document.getElementById("signupSubmit").innerHTML = "<div class='loaderButton'></div>";
/*Remove Previous Validation error messges*/
document.getElementById("signupUsername").style.border ="none";
document.getElementById("signupMobile").style.border ="none";
document.getElementById("signupPassword").style.border ="none";
document.getElementById("signupFirstName").style.border ="none";
document.getElementById("signupLastName").style.border ="none";
document.getElementById("signupEmail").style.border ="none";
document.getElementById("loginStatusMessage").innerHTML = "";
/*Validations*/
if(username == '' || password == '' || firstName == '' || email == ''){ /*Empty Fields*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Please Fill in all the fields</span>";
document.getElementById("signupUsername").style.border = "1px solid orange";
document.getElementById("signupPassword").style.border = "1px solid orange";
document.getElementById("signupEmail").style.border = "1px solid orange";
document.getElementById("signupFirstName").style.border = "1px solid orange";
}else if(!/^[a-zA-Z0-9 ]+$/.test(username)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Invalid charecters in Username</span>";
document.getElementById("signupUsername").style.border = "1px solid red";
}else if(!/^[a-zA-Z0-9!@#$%^&*]{4,15}$/.test(password)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Invalid charecters in Password / Minimum 4 charecters are required</span>";
document.getElementById("signupPassword").style.border = "1px solid red";
}else if(!/^[a-zA-Z0-9.-_]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(email)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Email not valid</span>";
document.getElementById("signupEmail").style.border = "1px solid red";
}else if(!/^[a-zA-Z ]*$/.test(firstName)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Invalid charecters in First Name</span>";
document.getElementById("signupFirstName").style.border = "1px solid red";
}else if(!/^[a-zA-Z ]*$/.test(lastName)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Invalid charecters in Last Name</span>";
document.getElementById("signupLastName").style.border = "1px solid red";
}else if(!/^[0-9 ]*$/.test(mobile)){ /*Validate expressions*/
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML = "";},5000);
document.getElementById("loginStatusMessage").innerHTML = "<span class='errorMessage'>Invalid charecters in Mobile (only numbers)</span>";
document.getElementById("signupMobile").style.border = "1px solid red";
}else{ /*If all above conditions are valid, User is signed up!*/
/*AJAX Functionality*/
/*Declare variables*/
var signupCheck = "RandomInput";
var data = "signupCheck="+signupCheck+"&username="+username+"&password="+password+"&firstName="+firstName+"&lastName="+lastName+"&email="+email+"&mobile="+mobile;
/*Declare XML*/
if(window.XMLHttpRequest){var xhr = new XMLHttpRequest();}
else if(window.ActiveXObject){var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
/*AJAX Methods*/
xhr.open("POST","conditions.php",true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
var eachResponse=this.responseText.split("-period-");
if(eachResponse[1]=='success'){
document.getElementById("loginStatusMessage").innerHTML=eachResponse[0];
setTimeout(function(){window.location.href = "index.php"},2000);
}else{
document.getElementById("loginStatusMessage").innerHTML=eachResponse[0];
setTimeout(function(){document.getElementById("loginStatusMessage").innerHTML='';},5000);
}
}
}
}
}
document.getElementById("signupSubmit").innerHTML = "SIGNUP";
}
//Login
function loginUser(){
var username=document.getElementById("loginUsername").value;
var password=document.getElementById("loginPassword").value;
document.getElementById("loginSubmit").innerHTML="<div class='loaderButton'></div>";
//Declare XML Request
if (window.XMLHttpRequest) { /*Mozilla, Safari*/ var xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) { /*IE 8 and older*/ var xhr = new ActiveXObject("Microsoft.XMLHTTP");}
var loginCheck="DummyText";//Declaring variables for POST Submit
var data = "loginCheck="+loginCheck+"&username="+username+"&password="+password;
xhr.open("POST", "conditions.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4) {
if (xhr.status == 200) {
var eachResponse=this.responseText.split("-period-");
if(eachResponse[1]=='success'){
window.location.href="index.php?LoginSuccess";
}else{
document.getElementById("loginStatusMessage").innerHTML=eachResponse[0];
}
document.getElementById("loginSubmit").innerHTML="LOGIN";
} else {
alert("There was a problem with the request.");
}
}
}
}
//Profile Pic Upload
function openProfilePicUploader(){
if(document.getElementById('profilePicUploader').style.display=='block'){
document.getElementById('profilePicUploader').style.display='none';
}else{
document.getElementById('profilePicUploader').style.display='block';
};
}
</script>
</html>