|
-
- function getPager(url, sum, int currnum, int length) {
- if (length >= sum) {
- return "";
- }
-
- var showsum = "总共";
- var showitem = "条数据";
- var showfirstpage = "首页";
- var showuppage = "上一页";
- var shownextpage = "下一页";
- var showlastpage = "末页";
- var showjump = "跳转到";
- var showselect = "请选择";
- var showtotal = "共";
- var showpage = "页";
-
- var pagerinfo = '';
- var sbinfo = '';
- sbinfo+="<div class='pager'>";
- var pagenum = 0;
-
- if (sum % length == 0) {
-
- pagenum = sum / length;
-
- } else {
- pagenum = sum / length-0 + 1;
- }
-
- var first = "";
- if (url.indexOf("?") != -1) {
- first = "&";
- } else {
- first = "?";
- }
- var pageUrl = "";
- sbinfo+=(showsum + "<font color=\"red\">" + sum + "</font>"
- + showitem + " ");
- var firstUrl = url + first + "currpage=" + 1 + "&" + condtion;
- sbinfo+=("<a class='btn btn-default' href=\"" + firstUrl + "\">"
- + showfirstpage + "</a> ");
- if (1 == currnum) {
-
- sbinfo+=(showuppage + " ");
-
- } else {
-
- pageUrl = url + first + "currpage=" + (currnum - 1) + "&"
- + condtion;
- sbinfo+=("<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl + "\" >" + showuppage + "</a> ");
- }
-
- String tempstr = "";
- if (pagenum < 6) {
- for (int i = 1; i < pagenum + 1; i++) {
- pageUrl = url + first + "currpage=" + i + "&" + condtion;
- if (i == currnum) {
-
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl
- + "\" ><b><font color=\"red\">"
- + i
- + "</font></b></a> ";
- } else {
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl + "\" >" + i + "</a> ";
- }
- sbinfo+=(tempstr);
- }
- } else if (currnum > pagenum - 3) {
-
- sbinfo+=(". . . ");
- for (int i = currnum - 4; i < pagenum + 1; i++) {
- pageUrl = url + first + "currpage=" + i + "&" + condtion;
- if (i == currnum) {
-
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl
- + "\" ><b><font color=\"red\">"
- + i
- + "</font></b></a> ";
- } else {
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl + "\" >" + i + "</a> ";
- }
- sbinfo+=(tempstr);
- }
-
- } else if (currnum < 4) {
-
- for (int i = 1; i < currnum + 3; i++) {
- pageUrl = url + first + "currpage=" + i + "&" + condtion;
-
- if (i == currnum) {
-
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl
- + "\" ><b><font color=\"red\">"
- + i
- + "</font></b></a> ";
- } else {
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl + "\" >" + i + "</a> ";
- }
- sbinfo+=(tempstr);
- }
- sbinfo+=(". . . ");
- } else {
- sbinfo+=(". . . ");
- for (int i = currnum - 2; i < currnum + 3; i++) {
- pageUrl = url + first + "currpage=" + i + "&" + condtion;
-
- if (i == currnum) {
-
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl
- + "\" ><b><font color=\"red\">"
- + i
- + "</font></b></a> ";
- } else {
- tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
- + pageUrl + "\" >" + i + "</a> ";
- }
- sbinfo+=tempstr);
- }
- sbinfo+=(". . . ");
- }
-
- if (currnum == pagenum) {
-
- sbinfo+=(shownextpage);
-
- } else {
- pageUrl = url + first + "currpage=" + (currnum + 1) + "&"
- + condtion;
- sbinfo+=("<a class='btn btn-default' href=\"" + pageUrl
- + "\">" + shownextpage + "</a>");
-
- }
-
- String endUrl = url + first + "currpage=" + pagenum + "&" + condtion;
- sbinfo+=(" <a class='btn btn-default' href=\"" + endUrl + "\">"
- + showlastpage + "</a> ");
-
- String selecturl = url + first + condtion;
- sbinfo+=showjump
- + "<select class='form-control' onchange=\"window.location.href='"
- + selecturl + "&currpage='+this.value;\">");
- sbinfo+=("<option value=\"\" selected>" + showselect + "</option>");
-
- for (int i = 1; i < pagenum + 1; i++) {
- sbinfo+=("<option value=\"" + i + "\">" + i + "</option>");
- }
- sbinfo+=("</select>");
- sbinfo+=(" " + showtotal + "<font color=\"red\">" + pagenum
- + "</font>" + showpage);
- sbinfo+=("</div>");
- pagerinfo = pagerinfo;
-
- return pagerinfo;
- }
|