22 lines
766 B
JavaScript
22 lines
766 B
JavaScript
var scrollListener = function () {
|
|
$(window).one("scroll", function () {
|
|
if($(window).scrollTop() + 256 >= $(document).height() - $(window).height()) {
|
|
$.ajax({
|
|
url: './api/p/'+$('#posts').data('last'),
|
|
dataType: 'json',
|
|
success: function(msg) {
|
|
var html = "";
|
|
for(var i = 0; i < msg.items.length; i++)
|
|
if(msg.items[i].id)
|
|
html += "<a href=\"./"+msg.items[i].id+"\" title=\""+msg.items[i].mime+"\"><img class=\"thumb\" src=\"//f0ck.me/t/"+msg.items[i].id+".png\" /></a>\n";
|
|
$('#posts').append(html);
|
|
$('#posts').data('last', msg.last);
|
|
}
|
|
});
|
|
}
|
|
setTimeout(scrollListener, 50);
|
|
});
|
|
};
|
|
$(document).ready(function () {
|
|
scrollListener();
|
|
}); |