-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (189 loc) · 5.75 KB
/
index.html
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="/lib/css/normalize.min.css" rel="stylesheet">
<link href="/lib/css/common.css" rel="stylesheet">
<style for="index">
div.article-list{
margin: 0 auto;
min-width: 32rem;
max-width: 56rem;
}
div.article-list ul{
list-style: none;
padding-left: 0;
}
div.article-list ul li{
border: 1px solid #ccc;
box-shadow: 1px 2px 2px #ddd;
word-wrap: break-word;
margin-top:1rem;
margin-bottom:1rem;
padding: .7rem;
overflow: hidden;
}
div.article-list ul li div.title{
padding-bottom: .7rem;
border-bottom: 1px dashed #bbb;
line-height: 1rem;
height: 1rem;
}
div.article-list ul li div.title a{
color: #666;
text-decoration: none;
}
div.article-list ul li div.title label{
color: #999;
float: right;
font-size: .8rem;
line-height: 1rem;
}
div.article-list ul li div.remark{
padding-top: .7rem;
padding-bottom: .7rem;
}
div.article-list ul li div.bottom{
color: #aaa;
float: right;
font-size: .8rem;
}
div.article-list ul li div.bottom a{
color: #333;
text-decoration: none;
}
div.article-list ul li div.bottom a:hover{
text-decoration: underline;
}
div.article-list .loading{
text-align: center;
height: 2rem;
display: none;
/*line-height: 2rem;*/
}
div.article-list .tail{
text-align: center;
height: 2rem;
display: none;
/*line-height: 2rem;*/
}
</style>
</head>
<body>
<div class="container">
<header role="banner">
<div class="logo">
<img src="/images/logo.png">
</div>
<div class="tag">
<label>HELLO WORLD</label>
</div>
<div class="back-top">
<i class="material-icons">keyboard_arrow_up</i>
</div>
</header>
<nav role="menu">
<ul>
<li>
<a href="/">IO</a>
</li>
<li>
<a href="/im.html">IM</a>
</li>
<li>
<a href="/draw.html">Draw</a>
</li>
</ul>
</nav>
<div class="blank"></div>
<div class="article-list">
<ul></ul>
<script type="text/html" id="articleListItemTpl">
{@each list as row}
<li>
<div class="title">
<a href="/article?id=${row.id}">${row.title}</a>
<label>${row.date}</label>
</div>
<div class="remark">${row.remark}</div>
<div class="bottom">
><a href="/article?id=${row.id}">more</a>
</div>
</li>
{@/each}
</script>
<div class="loading">-- loading --</div>
<div class="tail">-- no more. --</div>
</div>
<footer>
<div class="copy left"><a href="http://guoshikai.com">guoshikai.com</a> © 2016</div>
<div class="right">
<a href="https://github.com/shikaiguo">Github</a>
</div>
</footer>
</div>
<script src="/lib/js/jquery-3.1.1.min.js"></script>
<script src="/lib/juicer/juicer-min.js"></script>
<script>
$(function(){
$(document).scroll(scrollListener);
scrollListener();
$(".back-top").click(function(){
$("body").animate({ scrollTop: 0 }, 200);
});
});
</script>
<script>
var navHeight = false;
var navStatus = false;
function scrollListener(){
var documentScrollTop = $(document).scrollTop();
/* nav */
navHeight = navHeight || $("nav").offset().top + 1;
var f = documentScrollTop > navHeight;
if(f !== navStatus){
navStatus = f;
$("nav,.blank").toggleClass("nav-pin");
$(".back-top").fadeToggle(200);
}
/* get article list*/
if (documentScrollTop + $(window).height() >= $(document).height() - 233) {
getArticleList();
}
}
var page = 0;
var total = 1;
var limit = 10; //max: 25
function getArticleList(){
$.ajax({
url: "//api.guoshikai.com/io/getArticleList",
type: "post",
data: {
page: page + 1
},
beforeSend: function(){
if(page >= total || "block" === $(".loading").css("display")){
return false;
}
$(".loading").fadeIn();
},
success: function(r){
$(".loading").hide();
if(0 !== r.code){
return false;
}
var tpl = $("#articleListItemTpl").text();
var html = juicer(tpl, r.data);
$(".article-list>ul").append(html);
page = parseInt(r.data.page);
total = parseInt(r.data.total);
if(page === total) {
$(".tail").fadeIn();
}
}
});
}
</script>
</body>
</html>