47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
|
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
?>
|
||
|
<script>
|
||
|
var offset = 0;
|
||
|
var amount = 10;
|
||
|
var firstRun = true;
|
||
|
var itemsLeft = true;
|
||
|
var running = false;
|
||
|
|
||
|
loadEntries();
|
||
|
|
||
|
function loadEntries() {
|
||
|
if(!running && itemsLeft) {
|
||
|
$.ajax({
|
||
|
url: 'http://192.168.178.39/user/getComments',
|
||
|
data: {
|
||
|
user: <?= $data['ID'] ?>,
|
||
|
amount: amount,
|
||
|
offset: offset
|
||
|
},
|
||
|
beforeSend: function () {
|
||
|
$('.loading-spinner').show();
|
||
|
running = true;
|
||
|
},
|
||
|
success: function (data) {
|
||
|
$('.loading-spinner').hide();
|
||
|
$('.post-container .comment-list').append(data);
|
||
|
offset++;
|
||
|
if (data === "") {
|
||
|
$('.post-container').append("<p>Es konnten keine weiteren Kommentare gefunden werden. Bitte schaue später nochmal vorbei!</p>");
|
||
|
itemsLeft = false;
|
||
|
}
|
||
|
firstRun = false;
|
||
|
running = false;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$(window).scroll(function() {
|
||
|
if($(document).scrollTop() + 360 + $(window).height() >= $('.comment-list').position().top + $('.comment-list').outerHeight()) {
|
||
|
loadEntries();
|
||
|
}
|
||
|
});
|
||
|
</script>
|