1//å页 2 3// JavaScript Document 4var Page = function (options) { 5 var defaults = { 6 url: null,// 7 maxP: 0, //Maximum number of pages 8 nowP: 1, //Current number of pages 9 showC:8,//The total number of page numbers displayed when there are multiple pages 10 currClass:'active',//The class of the current page 11 }; 12 var option=$.extend(defaults, options); 13 this._url = option.url; 14 this._nowP = option.nowP; 15 this._maxP = option.maxP; 16 this._currClass = option.currClass; 17 this._showC = option.showC; 18} 19Page.prototype.checkData = function(){ 20 if(!!this._url&&!!this._maxP) 21 return true; 22 return false; 23} 24//This parameter determines the previous, next, or direct page number 25Page.prototype.actionPage = function(pageAction){ 26 var _this = this; 27 if(!!!pageAction&&!_this.checkData()) 28 return false; 29 switch(pageAction){ 30 case "next": 31 if(_this._nowP + 1 > _this._maxP) 32 flage = true; 33 _this._nowP = _this._nowP + 1 >= _this._maxP ? this._maxP : _this._nowP + 1;break; 34 case "prev": 35 if(_this._nowP - 1 < 1) 36 flage = true; 37 _this._nowP = _this._nowP - 1 <= 1 ? 1 : _this._nowP - 1;break; 38 default: 39 pageAction = parseInt(pageAction); 40 if(isNaN(pageAction)) 41 return false; 42 _this._nowP = parseInt(pageAction); 43 } 44 return true; 45} 46Page.prototype.showPage = function(){ 47 var _this = this; 48 if(!_this.checkData()) 49 return false; 50 var str = '<ul class="pagination pagination-purchase">'; 51 var p_prev = _this._nowP - 1 <= 1 ? 1 : _this._nowP - 1; 52 str += "<li><a aria-label='Previous' href="+ _this._url + p_prev +"><span aria-hidden='true'>«</span></a></li>" 53 54 var disc = parseInt(_this._showC/3); //How many page numbers are displayed for each paragraph when there are too many pages 55 var dism = disc + _this._showC%3; //Number of segments displayed when there are too many pages 56 var selcss = ""; 57 for(var i = 1; i <= disc && i <= _this._maxP; i++){ 58 if(_this._nowP == i) 59 selcss =_this._currClass; 60 str += "<li class='" + selcss + " '><a href="+ _this._url + i +" > " + i + " </a></li>"; 61 selcss = ""; 62 } 63 var hafem = parseInt(dism/2); //Display half of the current page in front and back respectively 64 var sStart = _this._nowP - hafem; //Too many pages. At the beginning of the second display, be sure to display the front code in person 65 var sEnd = _this._nowP + hafem; 66 if(sStart <= disc || _this._nowP <= disc || sStart >= _this._maxP - disc) { //When the front page is in front, the beginning of the middle section is the beginning of the end page of the previous paragraph 67 sStart = disc + 1; 68 sEnd = sStart + disc; 69 } 70 for (var i = sStart; i <= sEnd &&i <= _this._maxP; i++) { 71 if (_this._nowP == i) 72 selcss =_this._currClass; 73 str += "<li class='" + selcss + " '><a href="+ _this._url + i + " > " + i + " </a></li>"; 74 selcss = ""; 75 } 76 var eStart = _this._maxP - disc; 77 if(sEnd >= eStart) //When the front page is in the middle, the beginning of the back section is the beginning of the middle end page 78 eStart = sEnd + 1; 79 for (var i = eStart; i <= _this._maxP; i++) { 80 if (_this._nowP == i) 81 selcss =_this._currClass; 82 str += "<li class='" + selcss + " '><a href="+ _this._url + i +" > " + i + " </a></li>"; 83 selcss = ""; 84 } 85 var p_next = _this._nowP + 1 >= _this._maxP ? this._maxP : _this._nowP + 1; 86 str += "<li><a aria-label='Next' href="+ _this._url + p_next + "><span aria-hidden='true'>»</span></a></li></ul>"; 87 return str; 88} 89function js_Page(page,option) { 90 js_Page.s_P = new Page(option); 91 if(option.maxP <=0 ) { 92 $('.pagers').hide(); 93 return; 94 } 95 $('.pagers').show(); 96 if(!isNaN(page)||page=="prev"||page=="next") { 97 if (js_Page.s_P.actionPage(page)) { 98 $('.pagers').html(js_Page.s_P.showPage()); 99 } 100 } 101} 102 103var url=location.href; //Get the entire address bar 104var htmlurl= url.indexOf(".html") != -1; 105if(htmlurl == true){ 106 if(url.indexOf('?page') >= 0) { 107 var s = url.substring(url.indexOf('?page'), url.length); 108 url = url.replace(s, ''); 109 url = url + '?page='; 110 }else{ 111 url = url + '?page='; 112 } 113}else{ 114 if(url.indexOf('-page') >= 0) { 115 var s = url.substring(url.indexOf('-page'), url.length); 116 url = url.replace(s, ''); 117 url = url + '-page-'; 118 }else{ 119 url = url + '-page-'; 120 } 121 122} 123 124//Provide page count and current page within the page 125//Var count=; Number of pages 126//Var current=; Current Page 127new js_Page(current,{url:url,maxP:count}); 128
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.