}
$content.children(“:lt(” + (minnum) + “)”).css(“display”, “none”);
$content.children(“:gt(” + (maxnum – 1) + “)”).css(“display”, “none”);
}
//主要
//创建SetPager类
var SetPager = function (options,pageCount){
this.op = options;
this.pageCount = pageCount;
}
SetPager.prototype = {
//格式化成a元素
FormatStr : function(pageNo, pageText) {
var href = this.op.mode==’url’?location.pathname+”?”+this.op.urlparameter+”&p=”+pageNo:”javascript:void(0);”;
if (typeof (pageText) == “number”) {
return “<a href='”+href+”‘ >” + pageText + “</a>”;
}
return “<a href='”+href+”‘ i='” + pageNo + “‘>” + pageText + “</a>”;
},
//选中状态a元素
FormatStrIndex : function(pageNo){
return “<span class='”+this.op.selectClass+”‘>” + pageNo + “</span>”;
},
//默认模板初始化页码集合
InitDefaultList : function(_pageIndex){
if(this.op.listCount<5)
throw new Error(“listCount must be lager than 5”); //listCount>5
var pageIndex = parseFloat(_pageIndex); //转化为number
var ns = new Array();
var numList = new Array(this.op.listCount);
if (pageIndex >= this.op.listCount) {
numList[0] = 1;
numList[1] = “…”;
var infront = 0;
var inback = 0;
var inflag = Math.floor((this.op.listCount-2)/2);
if(this.op.listCount%2==0){
infront = inflag-1;
inback = inflag;
}else{
infront = inflag;
inback = inflag;
}
if (pageIndex + inback >= this.pageCount) {
for (i = this.pageCount – (this.op.listCount-3); i < this.pageCount + 1; i++) {
ns.push(i);
}
for (j = 0; j <= (this.op.listCount-3); j++) {
numList[j + 2] = ns[j];
}
}
for (i = pageIndex – infront; i <= pageIndex + inback; i++) {
ns.push(i);
}
for (j = 0; j < (this.op.listCount-2); j++) {
numList[j + 2] = ns[j];
}
} else {
if (this.pageCount >= this.op.listCount) {
for (i = 0; i < this.op.listCount; i++) {
numList[i] = i+1;
}
} else {
for (i = 0; i < this.pageCount; i++) {
numList[i] = i+1;
}
}
}
return numList;
},
//生成页码
InitPager : function(pageIndex){
$(“#”+this.op.pagerName).html(”);
if(this.op.enableFirst==false&&this.pageCount<=1){
return null;
}
var array = new Array();
//var finalarr = new Array();
var $con = $(“#”+this.op.pagerName);
switch(this.op.template){ //选择模板
case ‘default’:array = this.InitDefaultList(pageIndex,this.pageCount);break;
default:array = this.InitDefaultList(pageIndex,this.pageCount);










