This commit is contained in:
Flummi 2016-08-30 11:57:03 +00:00
parent 852af35e46
commit da08de7b79
2 changed files with 12 additions and 8 deletions

View File

@ -1,18 +1,22 @@
$(document).ready(function() {
$(window).scroll(function() {
if($(window).scrollTop() == $(document).height() - $(window).height()) {
$.ajax({
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=\"./t/"+msg.items[i].id+".png\" /></a>\n";
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();
});

View File

@ -9,7 +9,7 @@
<div class="body">
<div id="posts" data-last="{{ last }}">
{% for item in items %}
<a href="./{{ item.id }}" title="{{ item.mime }}"><img class="thumb" src="./t/{{ item.id }}.png" /></a>
<a href="./{{ item.id }}" title="{{ item.mime }}"><img class="thumb" src="//f0ck.me/t/{{ item.id }}.png" /></a>
{% endfor %}
</div>
<div class="clear"></div>