-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pagination.js
77 lines (76 loc) · 1.8 KB
/
Pagination.js
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
/**
* 生成分页
* 当前页 curr_page
* 总页数 pages
* zldfd lie表
*/
function pagenations(curr_page, pages, v) {
if (pages < 2) {
return false;
}
var init_len = 3;
var number_page = (init_len * 2) + 1;
var tmp = {};
for ( var i = 1; i <= number_page; i++) {
tmp[i] = 0;
}
i = 1;
if (pages <= number_page) {
for (i; i <= pages; i++) {
tmp[i] = i;
}
} else if (pages > number_page) {
if (curr_page <= init_len + 1) {
for (i; i <= number_page; i++) {
tmp[i] = i;
}
} else {
if (pages - curr_page <= init_len) {
var start = pages - number_page + 1;
var end = pages;
for (i; i <= number_page; i++) {
if (start > end) {
break;
}
tmp[i] = start;
start++;
}
} else {
var start = curr_page - init_len;
var end = start + (init_len * 2);
for (i; i <= number_page; i++) {
if (start > end) {
break;
}
tmp[i] = start;
start++;
}
}
}
}
var n_style = 'style="font-size:14px; margin:0 5px; _display:inline;cursor:pointer;color:#666666;"';
var html = '';
for (i = 1; i <= number_page; i++) {
if (tmp[i] != 0) {
var p_style = n_style;
if (tmp[i] == curr_page) {
p_style = 'style="font-size:14px; margin:0 5px; _display:inline;cursor:pointer;color:#11AFDE ;font-weight:bold;"';
}
html += '<span class="' + v + '" ' + p_style + ' id="page_'
+ tmp[i] + '">' + tmp[i] + '</span>';
}
}
var prev = '';
if (curr_page > 1) {
prev = '<span class="' + v + '" id="prev" ' + n_style
+ '><<</span>';
}
var next = '';
if (curr_page < pages) {
next = '<span class="' + v + '" id="next" ' + n_style
+ '>>></span>';
}
html = '<tr ><td colspan="6" bgcolor="#ffffff" align="right"><div style="padding:0 10px;">'
+ prev + html + next + '</div></td></tr>';
return html;
}