-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
292 lines (126 loc) · 4.21 KB
/
home.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
<?php $carousel="no";
include ( "./inc/header.inc.php");
if(!$userid){
die("You must be logged in to view this page");
}
include ( "./inc/header-logged.inc.php");
//print $_SERVER["MYVAR"];
?><br><br>
<div class="load-bar" id="wait" style="position:fixed;z-index:9999999;">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>
<br><br>
<div class="profile--wrapper"><br>
<?php
include ( "./post_actions.php");
//posting
echo '<div style="text-align:center">';
include ("./inc/create-post.inc.php");echo '</div>';
//like
if(isset($_GET['like'])){
post::likePost($_GET['like'], $userid);
}
if(isset($_GET['commenti'])){
if(isset($_POST['comment'])){
$comment=$_POST['comment'];
if($comment != ""){
post::commentPost($_GET['commenti'],$userid,$comment);
}
}
}
?><br><br>
<?php
$post_count=DB::query('SELECT count(*) FROM posts')[0]['count(*)'];
?>
</div> <!--End of profile--wrapper-->
<script type="text/javascript">
var working = false;
$(document).ready(function(){
var row = 0;
$.ajax({
url: './posts',
type: 'post',
data: {row:row},
success: function(response){
document.querySelector('.profile--wrapper').insertAdjacentHTML('beforeend', response);
document.getElementById("row_posts").value = row;
setTimeout(function() {
working = false;
}, 2000)
}
});
});
</script>
<script>
$(window).scroll(function(){
if ($(this).scrollTop() + 100 >= $('body').height() - $(window).height()) {
var row = Number($('#row_posts').val());
var allcount = Number($('#all_posts').val());
var rowperpage = 5;
var reset = 25;
row = row + rowperpage;
if(row > allcount){
row = 0;
document.getElementById("row_posts").value = row;
}
if(working == false){
working = true;
if(row <= allcount){
$('#row').val(row);
$.ajax({
url: './posts',
type: 'post',
data: {row:row},
success: function(response){
$(".profile--wrapper").append(response)
document.getElementById("row_posts").value = row;
setTimeout(function() {
working = false;
}, 2000)
}
});
}
}
}
});
</script>
<input type="hidden" id="row_posts" value="0">
<input type="hidden" id="all_posts" value="<?php echo $post_count; ?>">
<script src='js/like_click.js'></script>
<script src='js/autoresize.jquery.min.js'></script>
<script>
$(function(){
var resize=document.querySelectorAll("#normal");
var i;
for(i=0;i<resize.length;i++){
$(resize[i]).autosize();
}
});
//comments-reveal
$('.profile--wrapper').on('keypress','#normal', function(e){
var textarea = this;
if(textarea.scrollTop != 0){
textarea.style.height = textarea.scrollHeight + "px";
}
})
</script>
<script>
//loading-screen
$loading=$('#wait').hide()
$(document).ready(function(){
$(document).ajaxStart(function(){
$loading.show();
});
$(document).ajaxStop(function(){
$loading.hide();
});
});
</script>
<script>
//comments-reveal
$('.profile--wrapper').on('click','.post--comment', function(){
$(this).parent().next().next().next().toggleClass('open');
})
</script>