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.

3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. var newUrl;
  2. var page_name='';
  3. var total_page=0;
  4. function getPager(url, sum, currnum, length,idTag,page_tag_name) {
  5. page_tag_name=page_tag_name+'=';
  6. page_name=page_tag_name;
  7. newUrl =url;
  8. sum=parseInt(sum);
  9. currnum=parseInt(currnum);
  10. length=parseInt(length);
  11. if (length >= sum) {
  12. document.getElementById(idTag).innerHTML= "";
  13. return "";
  14. }
  15. var showsum = "共";
  16. var showitem = "页";
  17. var showfirstpage = "首页";
  18. var showuppage = "<";
  19. var shownextpage = ">";
  20. var showlastpage = "尾页";
  21. var showjump = "跳转到";
  22. var showselect = "Go";
  23. // var showtotal = "共";
  24. // var showpage = "页";
  25. var pagerinfo = '';
  26. var sbinfo = '';
  27. sbinfo+="<div class='pager'>";
  28. var pagenum = 0;
  29. if (sum % length == 0) {
  30. pagenum = sum / length;
  31. pagenum = parseInt(pagenum);
  32. } else {
  33. pagenum = sum / length-0 + 1;
  34. pagenum = parseInt(pagenum);
  35. }
  36. total_page=pagenum;
  37. showfirstpage = "" +1;
  38. showlastpage = ""+pagenum;
  39. var first = "";
  40. if (url.indexOf("?") != -1) {
  41. first = "&";
  42. } else {
  43. first = "?";
  44. }
  45. var pageUrl = "";
  46. sbinfo+=(showsum + "<font color=\"gray\">" + pagenum + "</font>"
  47. + showitem + "   ");
  48. if (1 == currnum) {
  49. sbinfo+=(showuppage + " ");
  50. } else {
  51. pageUrl = url + first +page_tag_name+ (currnum - 1);
  52. sbinfo+=("<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none; \" href=\""
  53. + pageUrl + "\" >" + showuppage + "</a> ");
  54. }
  55. var firstUrl = url + first +page_tag_name+ 1;
  56. sbinfo+=("<a class='paginationjs-prev J-paginationjs-previous' href=\"" + firstUrl + "\">"
  57. + showfirstpage + "</a>  ");
  58. var tempstr = "";
  59. if (pagenum < 6) {
  60. var tag = 0;
  61. for (var i = 2; i < pagenum + 1 && i <= pagenum-1; i++) {
  62. pageUrl = url + first +page_tag_name+ i;
  63. if (i == currnum) {
  64. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  65. + pageUrl
  66. + "\" ><b><font color=\"gray\">"
  67. + i
  68. + "</font></b></a> ";
  69. } else {
  70. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  71. + pageUrl + "\" >" + i + "</a> ";
  72. }
  73. sbinfo+=(tempstr);
  74. if(i>=pagenum-1){
  75. tag = 1;
  76. }
  77. }
  78. } else if (currnum > pagenum - 1) {
  79. var tag = 0;
  80. sbinfo+=("...");
  81. for (var i = currnum - 4; i < pagenum + 1 && i <= pagenum-1; i++) {
  82. pageUrl = url + first +page_tag_name+ i;
  83. if (i == currnum) {
  84. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  85. + pageUrl
  86. + "\" ><b><font color=\"gray\">"
  87. + i
  88. + "</font></b></a> ";
  89. } else {
  90. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  91. + pageUrl + "\" >" + i + "</a> ";
  92. }
  93. sbinfo+=(tempstr);
  94. if(i>=pagenum-1){
  95. tag = 1;
  96. }
  97. }
  98. } else if (currnum < 4) {
  99. var tag = 0;
  100. for (var i = 2; i < currnum + 3 && i <= pagenum-1; i++) {
  101. pageUrl = url + first +page_tag_name+ i;
  102. if (i == currnum) {
  103. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  104. + pageUrl
  105. + "\" ><b><font color=\"gray\">"
  106. + i
  107. + "</font></b></a> ";
  108. } else {
  109. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  110. + pageUrl + "\" >" + i + "</a> ";
  111. }
  112. sbinfo+=(tempstr);
  113. if(i>=pagenum-1){
  114. tag = 1;
  115. }
  116. }
  117. if(tag == 0){
  118. sbinfo+=("...");
  119. }
  120. } else {
  121. if(currnum - 2 > 2){
  122. sbinfo+=("...");
  123. }else{
  124. }
  125. var tag = 0;
  126. for (var i = currnum - 2; i < currnum + 3 && i <= pagenum-1; i++) {
  127. pageUrl = url + first +page_tag_name+ i;
  128. if (i == currnum) {
  129. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  130. + pageUrl
  131. + "\" ><b><font color=\"gray\">"
  132. + i
  133. + "</font></b></a> ";
  134. } else {
  135. tempstr = "<a class='paginationjs-prev J-paginationjs-previous' stlye=\"text-decoration: none;\" href=\""
  136. + pageUrl + "\" >" + i + "</a> ";
  137. }
  138. sbinfo+=tempstr;
  139. if(i>=pagenum-1){
  140. tag = 1;
  141. }
  142. }
  143. if(tag == 0){
  144. sbinfo+=("...");
  145. }
  146. }
  147. var endUrl = url + first +page_tag_name+ pagenum;
  148. sbinfo+=(" <a class='paginationjs-prev J-paginationjs-previous' href=\"" + endUrl + "\">"
  149. + showlastpage + "</a>   ");
  150. if (currnum == pagenum) {
  151. sbinfo+=(shownextpage);
  152. } else {
  153. pageUrl = url + first +page_tag_name+ (currnum + 1);
  154. sbinfo+=("<a class='paginationjs-prev J-paginationjs-previous' href=\"" + pageUrl
  155. + "\">" + shownextpage + "</a>");
  156. }
  157. var selecturl = url + first;
  158. sbinfo+=(showjump
  159. + "<input id='goButton' onKeyUp='page_put_change(this,this.value)' class='form-control' style='display:inline-block;width: 40px;height:25px; margin-left:5px; margin-top:-4px' >"+"</input>");
  160. sbinfo+=("</input type='text'><button id='go' style='margin-top=-2px' onclick=\"go()\">GO</button>");
  161. pagerinfo = sbinfo;
  162. document.getElementById(idTag).innerHTML=pagerinfo;
  163. }
  164. function page_put_change(self_obj,value){
  165. var int_value=parseInt(value);
  166. if (total_page<int_value) {
  167. self_obj.value=total_page;
  168. }
  169. }
  170. function go(){
  171. var tt= document.getElementById("goButton").value;
  172. if (total_page<parseInt(tt)) {
  173. tt=total_page+'';
  174. }
  175. var first = "";
  176. if (newUrl.indexOf("?") != -1) {
  177. first = "&";
  178. } else {
  179. first = "?";
  180. }
  181. var listURL = newUrl+first+page_name+tt;
  182. // 跳转前将URL编码
  183. listURL = encodeURI(listURL);
  184. window.location.href = listURL;
  185. }