// Window. _ {}; (function (_) {if (! _) Return ;_. pagesfunction (OS) {// you can use name to bind a click event, and then use the page/li attribute to use // console. log (OS );... syntaxHighlighter. all ();
// Window. _ = {}; (function (_) {if (! _) Return ;_. pages = function (OS) {// you can use name to bind a click event, and then use the page/li attribute to use // console. log (OS); var ops = {count: 0 // number of records, page: 0 // current page, li: 0 // or current number of records, pre: 'jspage' // class, id, and other prefixes, side: 5 // Number of left and right numeric pages on the current page, per: 5 // number of entries per page, first: ''// display homepage (character), last:'' // display last page (character), prev: ''// display previous page (character), next: ''// display the next page (character), prevg:'' // previous section (character): sufficiently forward to a group, not 1, nextg: ''// subsequent section (character): enough to move a group behind, not the last page. url: 'javascript:; '// the url of the page. The character * is replaced Switch to the page number, and the target: '_ self' // page number opens the window. The jump: ''// jump form action, * is replaced with the input page number, attrs: ''// other js attributes appended to the tag, such as data =" 11 "pid =" 2 "aid =" 3 "}; var ma = function (p, t, c, a) {return ''+ (t? T: p) + '\ n'}; var isset = function (v) {return 'undefined '! = Typeof v ;}; var strN0 = function (v) {return 'string' = typeof (v )&&! /^ \ S * $/. test (v )? 1: 0 ;}; // non-empty character for (var o in OS) isset (ops [o]) & (ops [o] = OS [o]); var overp = function (n) {return n> ops. maxp? Ops. maxp: n ;}; // var pages = ''; var p2l = function (p) {return p * ops. per}; // number of page-to-page records var purl = function (p) {return ops. url. replace ('*', p) ;}; // return the page number url (isNaN (ops. per) | ops. per <1) & (ops. per = 5); if (isNaN (ops. count) |! Ops. count | (ops. count <= ops. per) return pages; // there is only one page of ops. maxp = Math. floor (ops. count/ops. per) + (ops. count % ops. per? 1: 0); // maximum page if (0 <ops. li) {ops. li> ops. count & (ops. li = ops. count); ops. page = Math. floor (ops. li/ops. per) + (ops. li % ops. per? 1: 0); // data displacement is converted to page, remainder + 1} else if (ops. page> 1) {ops. page> ops. maxp & (ops. page = ops. maxp); ops. li = ops. page * ops. per;} else {ops. li = 0; ops. page = 1;} ops. nums = ops. side * 2 + 1; // The total number page is * 2 + 1 if (ops. page> ops. side + 1) {// if (strN0 (ops. first) pages + = ma (1, ops. first, 'First '); if (strN0 (ops. prev) pages + = ma (ops. page-1, ops. prev, 'prev');} var prevp = ops. page-ops. nums; if (strN0 (ops. prevg) & prevp> 1) pages + = ma (prevp, ops. prevg, 'prevg '); // this parameter is required only when the preceding content is omitted. 1 The homepage does not need to appear for (var fi = ops. side, sidel = sider = '', pl = pr = ops. page; fi> 0; fi --) {if (-- pl> = 1) sidel = ma (pl) + sidel; if (++ pr <= ops. maxp) sider + = ma (pr);} pages + = sidel + ''+ ops. page + ''+ sider; var nextp = ops. page + ops. nums; if (strN0 (ops. nextg) & ops. maxp> nextp) pages + = ma (nextp, ops. nextg, 'nextg '); // only the backend is not fully displayed. // jump to if (strN0 (ops. jump) & (ops. page> ops. side | ops. maxp-ops.page> ops. side) pages + = '\ n'; if (ops. maxp-ops. page> ops. side) {// only if (strN0 (ops. next) pages + = ma (ops. page + 1, ops. next, 'Next'); if (strN0 (ops. last) pages + = ma (ops. maxp, ops. last, 'last') ;}return pages ;}) (window. _); // document. body. innerHTML = _. pages ({count: 13, page: 1, per: 1, side: 1, first: 'F', prev: 'P', next: 'n', last: 'l', nextg: '>>>', prevg: '<', jump :' http://local.q/?kkkk= * ', Target:' _ blank '});
Js click Application Example: // click $ by PAGE ('# listsBar a [name = "jsPagePages"]'). click (function () {var pid = $ (this ). attr ('pid ') * 1; var page = $ (this ). attr ('page') * 1; $ ('# commentbox' + pid +' div. atBoxPage '+ pid ). hide (); // hide all others $ ('# atBoxPage' + pid + '_' + page ). show (); // display the current page}); Principle Analysis: 10 pages are displayed on the page, 1st pages are displayed, and other pages are hidden, class = "atBoxPage + pid" for each paginated div, and id = 'atboxpage + pid _ + page', click 2 on page 1, first, use the class to hide all 10 pages, and then use the id to get 2 pages.