var jumpContainer = document.createElement("span"); var span1 = document.createElement("span"); var span2 = document.createElement("span"); var span3 = document.createElement("span"); var span4 = document.createElement("span"); var span5 = document.createElement("span"); var inputBox = document.createElement("input"); var button = document.createElement("input"); inputBox.value = fn.pageNow; button.value = "确定"; button.type = "button"; inputBox.className = "box"; button.className = "BtnSur"; this.inputBox = inputBox; var _this = this; $(button).on("click",function(){ var page = fn.inputBox.value.trim(); fn.jump(page); falBoxInput = page; if(page >= _this.pageCount){ Page.alert(_this.pageCount); fn.inputBox.value = _this.pageCount; }else{ Page.alert(page); } var n = $(".select").text(); fn.inputBox.value = n; }) $(inputBox).on("keyup",function(){ var reg = /^[0-9]*[1-9][0-9]*$/; (!reg.test(this.value)) && (this.value = "") }) span1.innerHTML = "共"+this.pageCount+"页"; span2.innerHTML = "到第"; span4.innerHTML = "页"; span1.className = "jumpContainer"; span2.className = "jumpContainer"; span4.className = "jumpContainer"; span3.appendChild(inputBox); span5.appendChild(button); jumpContainer.appendChild(span1); jumpContainer.appendChild(span2); jumpContainer.appendChild(span3); jumpContainer.appendChild(span4); jumpContainer.appendChild(span5); this.container.appendChild(this.acontainer); this.container.appendChild(next); this.container.appendChild(jumpContainer); }, frontOrNext:function(node,isFront){ if(node.className.indexOf("disable")!=-1){ return; } if(isFront){ this.pageNow--; Page.alert(this.pageNow); }else{ this.pageNow++; Page.alert(this.pageNow); } this.judge(); }, judge:function(){ if(this.pageNow - this.start>2){ this.reset(); }else{ this.drawPage(); } }, jump:function(page){ if(page>this.pageCount){ this.pageNow = this.pageCount; this.drawPage(); return; } this.pageNow = page; if(this.pageNow - this.start > 2){ this.reset(); }else{ this.drawPage(); } }, check:function(){ if(this.pageNow <=1 ){ this.front.className += " disable"; }else{ this.front.className = "front"; } }, reset:function(){ this.acontainer.innerHTML=""; var a1 = document.createElement("a"); var a2 = document.createElement("a"); var etc1 = document.createElement("a"); var etc2 = document.createElement("a"); a1.innerHTML = "1"; a2.innerHTML = "2"; etc1.innerHTML = "..."; etc2.innerHTML = "..."; etc1.className = etc2.className = "etc"; this.front.className = "front"; $(a1).on("click",function(){ fn.pageNow = this.innerHTML; Page.alert(this.innerHTML); Page.select(this,"select"); fn.drawPage(); fn.inputBox.value = this.innerHTML; return; }) $(a2).on("click",function(){ fn.pageNow = this.innerHTML; Page.alert(this.innerHTML); Page.select(this,"select"); fn.drawPage(); fn.inputBox.value = this.innerHTML; return; }) this.acontainer.appendChild(a1); this.acontainer.appendChild(a2); this.acontainer.appendChild(etc1); var start; var startCount = this.pageCount - (this.pageSize - 2)+1; start = this.pageNow - Math.ceil((this.pageSize-2)/2)+1; if(start >= startCount){ start = startCount; this.isEnd = true; }else{ this.isEnd = false } this.start = start; var _this = this; var n = 0; for( var i = 0 ; i=fn.pageSize-1){
fn.reset();
}
fn.inputBox.value = fn.pageNow;
})
}
}