pager = function (divPager, pageIndex, pageSize, totalCount, pageChange, opt) {
var theOpt = { 🎜 > barTemplate: "{bar} 共{totalPage}頁{totalCount}條 {goto}", //顯示範本
, //在totalPage>barSize時是自動否顯示第一頁連結
showLast: true, //在totalPage>barSize時自動否顯示最後一頁連結
GoTo: true / /如果太少是否自動隱藏GoTo
};
if (opt) {
.barSize = opt.barSize;
if (opt .barTemplate)
theOpt.barTemplate = opt.barTemplate;
theOpt.autoHide = false;
if (opt.showFirst == false)
theOpt.showFirst = false;
if (opt.showLast = false)
showGoTo == false)
theOpt.showGoTo = false;
if (opt.autoHideGoTo == false)
theOpt.autoHideGoTo = false;
. turn x; } (window.myPagerChanges || {} ));
if (!myPagerChanges[divPager]) myPagerChanges[divPager] = pageChange;
; //分頁條終止頁
var showFirst = true;
var showLast = true;
}
pageIndex = parseInt(pageIndex);
if (pageIndex {
pageIndex = Math.ceil(totalCount / pageSize);
}
if (totalCount == 0) { //如果沒有資料
return "";
}
var totalPage = Math.ceil(totalCount / pageSize);
document.getElementById(divPager).innerHTML = "";
return "";
}
🎜> endPage = this.totalPage;
theOpt.showLast = theOpt.showFirst = false;
}
else {
if (pageIndex theOpt.showFirst = false;
}
else if (pageIndex, startPage = totalPage - theOpt.barSize 1;
endPage = totalPage;
theOpt.showLast = false;
}
else { //中間的頁時
startPage = pageIndex - Math.ceil(theOpt.barSize / 2) 1;
endPage = pageIndex Math.floor(theOpt.barSize / 2);
}
theOpt.showLast = theOpt.showFirst = false;
}
}
function _getsLink return "
";
gotoHtml = " ";
}
}
re " {bar} ", barHtml)
.replace("{totalCount}",totalCount)
.replace("{pageIndex}", pageIndex)
.replace("{totalPage}",totalPage)
。替換("{goto}", gotoHtml);
document.getElementById(divPager).innerHTML = pagerHtml;