var _MaxPageSize = 0;
var _PageSize = 5;
var _IsUpDown = false;
function InitPage(funName, currentPageSize, maxPageSize, pageSize, isUpDown) {
_FunName = funName;
_CurrentPageSize = currentPageSize;
_MaxPageSize = maxPageSize;
_PageSize = pageSize;
_IsUpDown = isUpDown;
}
function ShowPage(objDiv) {
var strResult = "";
var size = Math.floor(_PageSize / 2);
var maxSize = _CurrentPageSize size > _MaxPageSize ? _MaxPageSize : _CurrentPageSize size;
var minSize = _CurrentPageSize - size < 1 ? 1 : _CurrentPageSize - size;
if (maxSize == _MaxPageSize)
minSize = maxSize - _PageSize 1;
if (minSize == 1)
maxSize = minSize _PageSize - 1;
var str = "";
for (var i = 0; i < _MaxPageSize; i ) {
var curPage = i 1;
if (curPage == 1 || (curPage >= minSize && curPage <= maxSize) || curPage == _MaxPageSize) {
var strPage = "";
if (curPage == minSize && (_CurrentPageSize > _PageSize || minSize > 2))
strPage = "... ";
if (_CurrentPageSize == curPage) {
strPage = "
" curPage "";
}
else {
strPage = "
" curPage "";
}
if (curPage == maxSize && _MaxPageSize - _CurrentPageSize - 1 > size) {
strPage = "... ";
}
strResult = strPage;
}
}
strResult = "";
if (_IsUpDown) {
if (_CurrentPageSize == 1)
strResult = "
上一页" strResult;
else
strResult = "
上一页" strResult;
if (_CurrentPageSize == _MaxPageSize) {
strResult = strResult "
下一页";
}
else {
strResult = strResult "
下一页";
}
}
document.getElementById(objDiv).innerHTML =strResult;
}