main.html
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="blog/index/include_blog::header"></head>
<body>
<nav th:include="blog/index/include_blog::nav" class="navbar navbar-default navbar-custom navbar-fixed-top" ></nav>
<header class="intro-header"
style="background-image: url('/img/blog/home-bg.jpg')">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="site-heading">
<h1>BootDo Blog</h1>
<span class="subheading">bootdo 博客</span>
</div>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div id="incomeNum"></div>
<div class="clearfix">
<p id="flagLoaded" style="display: none; text-align: center;">已全部加载</p>
<a id="flagLoad" style="display: none;" class="btn btn-secondary float-right"
href="javascript:void(0)" onclick="nextPage()">更早 →</a>
</div>
</div>
</div>
</div>
</body>
<div th:include="blog/index/include_blog::footer"></div>
<script type="text/javascript">
var limit = 10;
var currentPage = 0;
var total;
$(function(){
bindList(0);
});
function nextPage() {
bindList(currentPage * limit)
}
function bindList(offset) {
$
.ajax({
url : 'blog/open/list?type=article&limit=10&offset=' + offset,
method : 'get',
dataType : 'json',
success : function(data) {
var rows = data.rows;
total = data.total;
var htmlText = "";
for (i = 0; i < rows.length; i++) {
htmlText += '<div class="post-preview">';
htmlText += '<a href="/blog/open/post/' + rows[i].cid + '">';
htmlText += '<h2 class="post-title">';
htmlText += rows[i].title;
htmlText += '</h2>';
htmlText += '</a>';
htmlText += '<p class="post-meta">作者:<a href="#">'
+ rows[i].author
+ '</a> '
+ rows[i].gtmModified + '</p>';
htmlText += '</div>';
htmlText += '<hr>';
}
$("#incomeNum").append(htmlText);
document.getElementById("flagLoad").style.display = "block";
currentPage++;
if (total <= currentPage * limit) {
document.getElementById("flagLoaded").style.display = "block";
document.getElementById("flagLoad").style.display = "none";
}
}
});
}
</script>
</html>