Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/1788/head
zouap 3 years ago
parent
commit
ac6025e0af
2 changed files with 36 additions and 32 deletions
  1. +34
    -28
      public/home/search.js
  2. +2
    -4
      templates/explore/search_new.tmpl

+ 34
- 28
public/home/search.js View File

@@ -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 += "<span class=\"item\">共 " + totalNum + " </span>"
if(currentPage > 1){
$('#startPage').removeClass("disabled");
$('#lastPage').removeClass("disabled");
html += "<a class=\"item navigation\" href=\"javascript:page(1)\"><span class=\"navigation_label\">首页</span></a>";
html += "<a class=\"item navigation\" href=\"javascript:prePage()\"><i class=\"left arrow icon\"></i></a>";
}else{
$('#startPage').addClass("disabled");
$('#lastPage').addClass("disabled");
html += "<a class=\"disabled item navigation\" href=\"javascript:page(1)\"><span class=\"navigation_label\">首页</span></a>";
html += "<a class=\"disabled item navigation\" href=\"javascript:prePage()\"><i class=\"left arrow icon\"></i></a>";
}
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 += "<a id=\"page_" + page_i+ "\" class=\"active item\" href=\"page(" + page_i +")\">" + page_i + "</a>";
}else{
html += "<a id=\"page_" + page_i+ "\" class=\"item\" href=\"page(" + page_i +")\">" + page_i + "</a>";
}
}
console.log("html=" + html)
document.getElementById("page_ids").innerHTML=html;

if(currentPage >=totalPage){
$('#nextPage').addClass("disabled");
$('#endPage').addClass("disabled");
html += "<a class=\"disabled item navigation\" href=\"javascript:nextPage()\"><i class=\"icon right arrow\"></i></a>";
html += "<a class=\"disabled item navigation\" href=\"javascript:page(" + totalPage + ")\"><span class=\"navigation_label\">末页</span></a>";
}else{
$('#nextPage').removeClass("disabled");
$('#endPage').removeClass("disabled");
$('#endPage').attr("href","javascript:page(" + totalPage + ")");
html += "<a class=\"item navigation\" href=\"javascript:nextPage()\"><i class=\"icon right arrow\"></i></a>";
html += "<a class=\"item navigation\" href=\"javascript:page(" + totalPage + ")\"><span class=\"navigation_label\">末页</span></a>";
}

html +="<div class=\"item\"> 前往<div class=\"ui input\"><input id=\"inputpage\" type=\"text\" placeholder=\"1\"></div>页</div>";
console.log("html=" + html)
document.getElementById("page_menu").innerHTML=html;
$('#inputpage').on('keypress',function(event){
if(event.keyCode == 13){
goPage();
}
});
}

+ 2
- 4
templates/explore/search_new.tmpl View File

@@ -76,15 +76,13 @@
<div class="center page buttons" style="margin: 0px auto 15px">
<div class="ui borderless mini pagination menu">
<div class="ui borderless mini pagination menu" id="page_menu">
<span class="item" id="page_total"></span>
<a id="startPage" class=" item navigation" href="javascript:page(1)"><span class="navigation_label">首页</span></a>
<a id="lastPage" class=" item navigation" href="javascript:prePage()">
<i class="left arrow icon"></i>
</a>
<span id="page_ids">
</span>
<a id="nextPage" class="item navigation" href="javascript:nextPage()">
<i class="icon right arrow"></i>
</a>


Loading…
Cancel
Save