<%@ page language="java" pageEncoding="UTF-8" %>
<script type="text/javascript">
var sbPageString ="";
var displayNum = 10;//显示页面数量
var totalPages = ${pageCount}; //页面码数
var pageNumber = ${pagedVo.paging.pageNumber}; //当前页码
var startPage = 0; //首页
var endPage = 0; //最后页
if (totalPages <= displayNum) {
startPage = 1;
endPage = totalPages;
}/* else if (pageNumber <= (displayNum - 1) / 2) {
startPage = 1;
endPage = displayNum;
} else if (pageNumber >= totalPages - (displayNum - 1) / 2) {
startPage = totalPages - displayNum + 1;
endPage = totalPages;
} else {
startPage = pageNumber - (displayNum - 1) / 2;
endPage = pageNumber + (displayNum - 1) / 2;
} */
if(totalPages<=10){
if(totalPages==1||totalPages==0){
sbPageString = "<a href='javascript:void(0)' onclick='toPage("+1+")' style='background-color:#EFCFB6;'>" + 1 + "</a>";
}else{
sbPageString += "<a href='javascript:void(0)' class='first-child' onclick='toPage("+(pageNumber -1)+")' >上一页 <p></p></a>";
for(var i=1;i<=totalPages;i++){
if(i<pageNumber){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+i+")'>" + i + "</a>";
}else if(i==pageNumber){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber)+")' style='background-color:#EFCFB6;'>" + pageNumber + "</a>";
}else if(i>pageNumber){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+i+")'>" + i + "</a>";
}
}
sbPageString += "<a href='javascript:void(0)' class='first-child' onclick='toPage("+(pageNumber +1)+")'>下一页 <p class='dpl-paginator-arrow-right'></p></a>";
}
}
if(totalPages>10){
if(pageNumber!=1){
sbPageString += "<a href='javascript:void(0)' class='first-child' onclick='toPage("+(pageNumber -1)+")' >上一页 <p></p></a>";
}
if(pageNumber<=4){
for(var i=1;i<=parseInt(pageNumber);i++){
if(i!=pageNumber){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+i+")' >" + i + "</a>";}
if(i==pageNumber){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber)+")' style='background-color:#EFCFB6;'>" + pageNumber + "</a>";
}
}
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber+1)+")'>" + (pageNumber+1) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber+2)+")'>" + (pageNumber+2) + "</a><span style='float:left;'>...</span>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+totalPages+")'>" + totalPages + "</a>";
}
if(pageNumber>4&&pageNumber<=totalPages-3){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+1+")'>" + 1 + "</a><span style='float:left;'>...</span>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber-2)+")'>" + (pageNumber-2) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber-1)+")'>" + (pageNumber-1) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+pageNumber+")' style='background-color:#EFCFB6;'>" + pageNumber + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber+1)+")'>" + (pageNumber+1) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber+2)+")'>" + (pageNumber+2) + "</a><span style='float:left;'>...</span>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+totalPages+")'>" + totalPages + "</a>";
}
if(pageNumber>totalPages-3){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+1+")'>" + 1 + "</a><span style='float:left;'>...</span>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber-2)+")'>" + (pageNumber-2) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+(pageNumber-1)+")'>" + (pageNumber-1) + "</a>";
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+pageNumber+")' style='background-color:#EFCFB6;'>" + pageNumber + "</a>";
for(var i=pageNumber+1;i<=totalPages;i++){
sbPageString += "<a href='javascript:void(0)' onclick='toPage("+i+")'>" + i + "</a>";
}
}
if(parseInt(pageNumber)!=totalPages){
sbPageString += "<a href='javascript:void(0)' class='first-child' onclick='toPage("+(pageNumber +1)+")' >下一页 <p></p></a>";
}
}
$(".yema").append(sbPageString);
</script>