var totalPage = pageInfo.totalPage;
var allRow = pageInfo.allRow;
var currentPage = pageInfo.currentPage;
var offset = (currentPage - 1) * pageSize;
var currentListSize = pageInfo.currentListSize;
var buttonListLength = 8;
var pagination = $("#pagination");
pagination.empty();
if (allRow < pageSize ) {
pagination.append("
" + offset + "-" + allRow + " of " + allRow + "
");
} else {
pagination.append("
" + (offset +1) + "-" + (offset + currentListSize) + " of " + allRow + "
");
}
pagination.append("
");
$("#per_page").change(function(){
var size = $("#per_page").val();
pageSize = size;
getPageBean(actionUrl, 1, pageSize, column, way);
});
if (pageSize == "2") {
$("#per_page option[value='2']").attr("selected", true);
}
if (pageSize == "4") {
$("#per_page option[value='4']").attr("selected", true);
}
if (pageSize == "6") {
$("#per_page option[value='6']").attr("selected", true);
}
pagination.append("");
pagination.append("");
if (totalPage <= buttonListLength) {
for (var k = 1; k <= totalPage; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage > buttonListLength && currentPage <= buttonListLength/2 ) {
for (var k = 1; k <= buttonListLength; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage >= buttonListLength && currentPage > buttonListLength/2 && currentPage + buttonListLength/2 <= totalPage) {
for (var k = (currentPage - buttonListLength/2 + 1); k <= (currentPage + buttonListLength/2); k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage >= buttonListLength && (currentPage + buttonListLength/2 > totalPage) ) {
for (var k = (totalPage - buttonListLength + 1); k <= totalPage; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
}
if (currentPage + 1 > totalPage) {
pagination.append("");
} else {
pagination.append("");
}
pagination.append("");
pagination.append("
$("#per_page").change(function(){
var size = $("#per_page").val();
pageSize = size;
getPageBean(actionUrl, 1, pageSize, column, way);
});
if (pageSize == "2") {
$("#per_page option[value='2']").attr("selected", true);
}
if (pageSize == "4") {
$("#per_page option[value='4']").attr("selected", true);
}
if (pageSize == "6") {
$("#per_page option[value='6']").attr("selected", true);
}
pagination.append("");
pagination.append("");
if (totalPage <= buttonListLength) {
for (var k = 1; k <= totalPage; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage > buttonListLength && currentPage <= buttonListLength/2 ) {
for (var k = 1; k <= buttonListLength; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage >= buttonListLength && currentPage > buttonListLength/2 && currentPage + buttonListLength/2 <= totalPage) {
for (var k = (currentPage - buttonListLength/2 + 1); k <= (currentPage + buttonListLength/2); k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
} else if (totalPage >= buttonListLength && (currentPage + buttonListLength/2 > totalPage) ) {
for (var k = (totalPage - buttonListLength + 1); k <= totalPage; k++) {
if ( k == currentPage) {
pagination.append(""+k+"");
} else {
pagination.append(""+k+"");
}
}
}
if (currentPage + 1 > totalPage) {
pagination.append("");
} else {
pagination.append("");
}
pagination.append("");
pagination.append("
");
$(".go").click(function(){
var num = $("#go_page_val").val();
if (isNaN(num)) {
alert("please input a number");
$("#go_page_val").val("");
return false;
} else {
var allPage = parseInt(allRow / pageSize) + 1;
if (num > allPage) {
alert("not over " + allPage + "");
$("#go_page_val").val("");
return false;
}
getPageBean(actionUrl, num, pageSize, column, way);
}
});
return false;
}
$(".go").click(function(){
var num = $("#go_page_val").val();
if (isNaN(num)) {
alert("please input a number");
$("#go_page_val").val("");
return false;
} else {
var allPage = parseInt(allRow / pageSize) + 1;
if (num > allPage) {
alert("not over " + allPage + "");
$("#go_page_val").val("");
return false;
}
getPageBean(actionUrl, num, pageSize, column, way);
}
});
return false;
}