diff --git a/public/home/search.js b/public/home/search.js index 7caebbffc..6ebd2612a 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -531,6 +531,10 @@ function page(current){ function nextPage(){ currentPage = currentPage+1; console.log("currentPage=" + currentPage); + if(currentPage >= endIndex){ + startIndex=startIndex+1; + endIndex = endIndex +1; + } page(currentPage); } @@ -538,19 +542,15 @@ function page(current){ console.log("currentPage=" + currentPage); if(currentPage > 1){ currentPage = currentPage-1; + if(currentPage <= startIndex && startIndex >= 1){ + startIndex = startIndex -1; + endIndex = endIndex - 1; + } console.log("currentPage=" + (currentPage)); page(currentPage); } } - - $('#inputpage').on('keypress',function(event){ - if(event.keyCode == 13){ - goPage(); - } - }); - - function goPage(){ var goNum = $('#inputpage').val(); @@ -566,41 +566,47 @@ function page(current){ } function setPage(currentPage){ + console.log("totalPage=" + totalPage); + var html =""; + console.log("currentPage=" + currentPage); if(totalPage==0){ - return; + return; } - console.log("currentPage=" + currentPage); - $('#page_total').text("共 " + totalNum + " 条"); + html += "共 " + totalNum + " " if(currentPage > 1){ - $('#startPage').removeClass("disabled"); - $('#lastPage').removeClass("disabled"); + html += "首页"; + html += ""; }else{ - $('#startPage').addClass("disabled"); - $('#lastPage').addClass("disabled"); + html += "首页"; + html += ""; } - console.log("totalPage=" + totalPage); - var html =""; - for(var i=startIndex-1; i < endIndex; i++){ - var page_i = (currentPage + i); + for(var i=startIndex; i <= endIndex; i++){ + var page_i = i; if(page_i > totalPage){ break; } - if( i == (startIndex -1)){ + if( page_i == currentPage){ html += "" + page_i + ""; }else{ html += "" + page_i + ""; } } - console.log("html=" + html) - document.getElementById("page_ids").innerHTML=html; + if(currentPage >=totalPage){ - $('#nextPage').addClass("disabled"); - $('#endPage').addClass("disabled"); + html += ""; + html += "末页"; }else{ - $('#nextPage').removeClass("disabled"); - $('#endPage').removeClass("disabled"); - $('#endPage').attr("href","javascript:page(" + totalPage + ")"); + html += ""; + html += "末页"; } - + + html +="
前往
"; + console.log("html=" + html) + document.getElementById("page_menu").innerHTML=html; + $('#inputpage').on('keypress',function(event){ + if(event.keyCode == 13){ + goPage(); + } + }); } \ No newline at end of file diff --git a/templates/explore/search_new.tmpl b/templates/explore/search_new.tmpl index fd1f338e3..f15e9062b 100644 --- a/templates/explore/search_new.tmpl +++ b/templates/explore/search_new.tmpl @@ -76,15 +76,13 @@
-