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() { var scrollListener = function () {
$(window).scroll(function() { $(window).one("scroll", function () {
if($(window).scrollTop() == $(document).height() - $(window).height()) { if($(window).scrollTop() + 256 >= $(document).height() - $(window).height()) {
$.ajax({ $.ajax({
url: './api/p/'+$('#posts').data('last'), url: './api/p/'+$('#posts').data('last'),
dataType: 'json', dataType: 'json',
success: function(msg) { success: function(msg) {
var html = ""; var html = "";
for(var i = 0; i < msg.items.length; i++) for(var i = 0; i < msg.items.length; i++)
if(msg.items[i].id) 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').append(html);
$('#posts').data('last', msg.last); $('#posts').data('last', msg.last);
} }
}); });
} }
}); setTimeout(scrollListener, 50);
});
};
$(document).ready(function () {
scrollListener();
}); });

View File

@ -9,7 +9,7 @@
<div class="body"> <div class="body">
<div id="posts" data-last="{{ last }}"> <div id="posts" data-last="{{ last }}">
{% for item in items %} {% 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 %} {% endfor %}
</div> </div>
<div class="clear"></div> <div class="clear"></div>