pagination

This commit is contained in:
Flummi
2016-08-30 10:50:06 +00:00
parent 0621234e50
commit 852af35e46
5 changed files with 63 additions and 9 deletions

4
s/jquery-3.1.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,6 @@
html, body {
height: 100%;
}
body {
width: 100%;
margin: 1em auto 3em auto;

18
s/test.js Normal file
View File

@ -0,0 +1,18 @@
$(document).ready(function() {
$(window).scroll(function() {
if($(window).scrollTop() == $(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";
$('#posts').append(html);
$('#posts').data('last', msg.last);
}
});
}
});
});

View File

@ -5,12 +5,17 @@
<link rel="icon" type="image/gif" href="./s/favicon.gif" />
<link rel="stylesheet" type="text/css" href="./s/test.css">
</head>
<div class="body">
{% for item in items %}
<a href="./{{ item.id }}" title="{{ item.mime }}"><img class="thumb" src="./t/{{ item.id }}.png" /></a>
{% endfor %}
<div class="clear"></div>
</div>
<body>
<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>
{% endfor %}
</div>
<div class="clear"></div>
</div>
<div style="position: fixed; top:0;right:0" id="debug"></div>
<script src="./s/jquery-3.1.0.min.js"></script>
<script src="./s/test.js"></script>
</body>
</html>