File size: 2.06Kb
<div class="container user-posts__container">
<div class="user-posts explore-posts-container pg_grid_posts pg_grid_posts_tag">
<?php if (count($context['posts']) > 0) {
foreach ($context['posts'] as $key => $post_data) {
include 'includes/list.html';
}
} else{
include 'includes/no-posted.html';
} ?>
</div>
</div>
<script>
var ajax_url = '<?php echo($context['xhr_url']); ?>';
var user_id = '<?php echo($context['user_data']['user_id']) ?>';
jQuery(document).ready(function($) {
var scrolled = 0;
var last_id = 0;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
if (scrolled == 0 && $('.user-postset').length > 0) {
scrolled = 1;
var list_ids = $("div.user-postset[id]").map(function() {
if($(this).attr('id') > 0) {
return $(this).attr('id');
}
}).get();
if (!list_ids) {
return false;
}
var last_id = Math.min.apply(Math,list_ids);
var pathname = window.location.pathname
var str2 = "DEFG";
if(pathname.indexOf('reels') != -1){
$.ajax({
url: ajax_url + '/load-user-reels',
type: 'GET',
dataType: 'json',
data: {
offset:last_id,
user_id:user_id
},
}).done(function(data) {
if (data.status == 200) {
$(".user-posts").append(data.html);
scrolled = 0;
}
else{
$(window).unbind('scroll');
}
});
}else{
$.ajax({
url: ajax_url + '/load-user-posts',
type: 'GET',
dataType: 'json',
data: {
offset:last_id,
user_id:user_id
},
}).done(function(data) {
if (data.status == 200) {
$(".user-posts").append(data.html);
scrolled = 0;
}
else{
$(window).unbind('scroll');
}
});
}
}
}
});
});
</script>