Jquery extended paging object

Source: Internet
Author: User
/* Jquery paging function. Note that this function only generates paging connections on the front end and processes data on the server end. Write it by yourself. Example: varp $. page ({url: & amp; #39; aaa. php? Kkk88 & amp; #39;, count: 80, page: 1, pagesize: 6}); console. log (p. getPage... /* jquery paging function. Note that this function only generates paging connections on the front end and processes data on the server end. Write it by yourself. Example: var p = $. page ({url: 'aaa. php? Kkk = 88 ', count: 80, page: 1, pagesize: 6}); console. log (p. getPageList (4); */jQuery. extend ({page: function (p) {var _ self = this; var url; var count = parseInt (p. count); var page = parseInt (p. page); var pagesize = parseInt (p. pagesize); if (p. url) {url = p. url;} else {url = location. href; var re = /[? | &] Page = \ d */g; url = url. replace (re, "");} if (! (Page> 1) {page = 1;} var pageCount = (count % pagesize> 0? ParseInt (count/pagesize + 1): parseInt (count/pagesize); var delimiter = '? '; Function p_delimiter (url) {if (url. search ("\\? ") <0) {return '? Page = ';} else {return' & page = ';} delimiter = p_delimiter (url); _ self. getPageCount = function () {return pageCount ;}; _ self. last = function () {return url + delimiter + pageCount;}; _ self. first = function () {return url + delimiter + 1 ;}; _ self. next = function () {if (page + 1) <= pageCount) {return url + delimiter + (page + 1) ;}else {return "";}}; _ self. prev = function () {if (page-1> 0) {return url + delimiter + (pag E-1);} else {return "" ;}}; _ self: go = function (n) {if (n> 0 & n> pageCount) {return url + delimiter + n;} return "" ;}; _ self. getPageList = function (n) {var l_n = parseInt (n/2), r_n = (n % 2 = 0? L_n-1: l_n); var start = (page <= l_n? 1: (page-l_n), end, rlist = new Array (); if (start = 1) end = (n <pageCount? N: pageCount); else end = (page + r_n)> = pageCount? PageCount: (page + r_n); for (var I = start; I <= end; I ++) {rlist. push (url + delimiter + I);} www.2cto.com return rlist;}; return this ;}});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.