You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

163 lines
4.3 KiB

  1. function getPager(url, sum, int currnum, int length) {
  2. if (length >= sum) {
  3. return "";
  4. }
  5. var showsum = "总共";
  6. var showitem = "条数据";
  7. var showfirstpage = "首页";
  8. var showuppage = "上一页";
  9. var shownextpage = "下一页";
  10. var showlastpage = "末页";
  11. var showjump = "跳转到";
  12. var showselect = "请选择";
  13. var showtotal = "共";
  14. var showpage = "页";
  15. var pagerinfo = '';
  16. var sbinfo = '';
  17. sbinfo+="<div class='pager'>";
  18. var pagenum = 0;
  19. if (sum % length == 0) {
  20. pagenum = sum / length;
  21. } else {
  22. pagenum = sum / length-0 + 1;
  23. }
  24. var first = "";
  25. if (url.indexOf("?") != -1) {
  26. first = "&";
  27. } else {
  28. first = "?";
  29. }
  30. var pageUrl = "";
  31. sbinfo+=(showsum + "<font color=\"red\">" + sum + "</font>"
  32. + showitem + "   ");
  33. var firstUrl = url + first + "currpage=" + 1 + "&" + condtion;
  34. sbinfo+=("<a class='btn btn-default' href=\"" + firstUrl + "\">"
  35. + showfirstpage + "</a>  ");
  36. if (1 == currnum) {
  37. sbinfo+=(showuppage + " ");
  38. } else {
  39. pageUrl = url + first + "currpage=" + (currnum - 1) + "&"
  40. + condtion;
  41. sbinfo+=("<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  42. + pageUrl + "\" >" + showuppage + "</a> ");
  43. }
  44. String tempstr = "";
  45. if (pagenum < 6) {
  46. for (int i = 1; i < pagenum + 1; i++) {
  47. pageUrl = url + first + "currpage=" + i + "&" + condtion;
  48. if (i == currnum) {
  49. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  50. + pageUrl
  51. + "\" ><b><font color=\"red\">"
  52. + i
  53. + "</font></b></a> ";
  54. } else {
  55. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  56. + pageUrl + "\" >" + i + "</a> ";
  57. }
  58. sbinfo+=(tempstr);
  59. }
  60. } else if (currnum > pagenum - 3) {
  61. sbinfo+=(". . . ");
  62. for (int i = currnum - 4; i < pagenum + 1; i++) {
  63. pageUrl = url + first + "currpage=" + i + "&" + condtion;
  64. if (i == currnum) {
  65. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  66. + pageUrl
  67. + "\" ><b><font color=\"red\">"
  68. + i
  69. + "</font></b></a> ";
  70. } else {
  71. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  72. + pageUrl + "\" >" + i + "</a> ";
  73. }
  74. sbinfo+=(tempstr);
  75. }
  76. } else if (currnum < 4) {
  77. for (int i = 1; i < currnum + 3; i++) {
  78. pageUrl = url + first + "currpage=" + i + "&" + condtion;
  79. if (i == currnum) {
  80. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  81. + pageUrl
  82. + "\" ><b><font color=\"red\">"
  83. + i
  84. + "</font></b></a> ";
  85. } else {
  86. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  87. + pageUrl + "\" >" + i + "</a> ";
  88. }
  89. sbinfo+=(tempstr);
  90. }
  91. sbinfo+=(". . . ");
  92. } else {
  93. sbinfo+=(". . . ");
  94. for (int i = currnum - 2; i < currnum + 3; i++) {
  95. pageUrl = url + first + "currpage=" + i + "&" + condtion;
  96. if (i == currnum) {
  97. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  98. + pageUrl
  99. + "\" ><b><font color=\"red\">"
  100. + i
  101. + "</font></b></a> ";
  102. } else {
  103. tempstr = "<a class='btn btn-default' stlye=\"text-decoration: none;\" href=\""
  104. + pageUrl + "\" >" + i + "</a> ";
  105. }
  106. sbinfo+=tempstr);
  107. }
  108. sbinfo+=(". . . ");
  109. }
  110. if (currnum == pagenum) {
  111. sbinfo+=(shownextpage);
  112. } else {
  113. pageUrl = url + first + "currpage=" + (currnum + 1) + "&"
  114. + condtion;
  115. sbinfo+=("<a class='btn btn-default' href=\"" + pageUrl
  116. + "\">" + shownextpage + "</a>");
  117. }
  118. String endUrl = url + first + "currpage=" + pagenum + "&" + condtion;
  119. sbinfo+=(" <a class='btn btn-default' href=\"" + endUrl + "\">"
  120. + showlastpage + "</a>   ");
  121. String selecturl = url + first + condtion;
  122. sbinfo+=showjump
  123. + "<select class='form-control' onchange=\"window.location.href='"
  124. + selecturl + "&currpage='+this.value;\">");
  125. sbinfo+=("<option value=\"\" selected>" + showselect + "</option>");
  126. for (int i = 1; i < pagenum + 1; i++) {
  127. sbinfo+=("<option value=\"" + i + "\">" + i + "</option>");
  128. }
  129. sbinfo+=("</select>");
  130. sbinfo+=("  " + showtotal + "<font color=\"red\">" + pagenum
  131. + "</font>" + showpage);
  132. sbinfo+=("</div>");
  133. pagerinfo = pagerinfo;
  134. return pagerinfo;
  135. }