|
|
@@ -46,17 +46,24 @@ var sortBy={ |
|
|
|
"61":"updated_unix.keyword" |
|
|
|
}; |
|
|
|
|
|
|
|
var currentPage = 1; |
|
|
|
var pageSize = 15; |
|
|
|
var currentSearchTableName =""; |
|
|
|
var currentSearchKeyword=""; |
|
|
|
var currentSearchSortBy=""; |
|
|
|
var OnlySearchLabel=false; |
|
|
|
|
|
|
|
function searchItem(type,sortType){ |
|
|
|
console.log("enter here."); |
|
|
|
var keyword = document.getElementById("keyword_input").value; |
|
|
|
var page =1; |
|
|
|
var pageSize=15; |
|
|
|
if(!isEmpty(keyword)){ |
|
|
|
doSearch(itemType[type],keyword,page,pageSize,false,sortBy[sortType]); |
|
|
|
currentSearchKeyword = document.getElementById("keyword_input").value; |
|
|
|
if(!isEmpty(currentSearchKeyword)){ |
|
|
|
currentSearchTableName = itemType[type]; |
|
|
|
doSearch(itemType[type],currentSearchKeyword,page,pageSize,false,sortBy[sortType]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function search(){ |
|
|
|
console.log("enter here."); |
|
|
|
var keyword = document.getElementById("keyword_input").value; |
|
|
@@ -64,15 +71,15 @@ function search(){ |
|
|
|
var pageSize=15; |
|
|
|
if(!isEmpty(keyword)){ |
|
|
|
doSearch("repository",keyword,page,pageSize,false,sortBy[11]); |
|
|
|
doSearch("issue",keyword,page,pageSize,true); |
|
|
|
doSearch("user",keyword,page,pageSize,true); |
|
|
|
doSearch("org",keyword,page,pageSize,true); |
|
|
|
doSearch("dataset",keyword,page,pageSize,true); |
|
|
|
doSearch("pr",keyword,page,pageSize,true); |
|
|
|
doSearch("issue",keyword,page,pageSize,true,""); |
|
|
|
doSearch("user",keyword,page,pageSize,true,""); |
|
|
|
doSearch("org",keyword,page,pageSize,true,""); |
|
|
|
doSearch("dataset",keyword,page,pageSize,true,""); |
|
|
|
doSearch("pr",keyword,page,pageSize,true,""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function doSearch(tableName,keyword,page,pageSize=15,onlyReturnNum=true,sortBy,OnlySearchLabel=false){ |
|
|
|
function doSearch(tableName,keyword,page,pageSize=15,onlyReturnNum=true,sortBy="",OnlySearchLabel=false){ |
|
|
|
$.ajax({ |
|
|
|
type:"GET", |
|
|
|
url:"/all/dosearch/", |
|
|
@@ -114,6 +121,7 @@ function displayResult(tableName,page,jsonResult,onlyReturnNum,keyword){ |
|
|
|
} else if (tableName == "pr") { |
|
|
|
displayPrResult(page,jsonResult,onlyReturnNum,keyword); |
|
|
|
} |
|
|
|
setPage(jsonResult,pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
function displayPrResult(page,jsonResult,onlyReturnNum,keyword){ |
|
|
@@ -484,4 +492,94 @@ var repoAndOrgEN={ |
|
|
|
"5":" minutes ago", |
|
|
|
"6":" seconds ago", |
|
|
|
"7":" days ago" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function page(current){ |
|
|
|
//function doSearch(tableName,keyword,page,pageSize=15,onlyReturnNum=true,sortBy="",OnlySearchLabel=false){ |
|
|
|
doSearch(currentSearchTableName,currentSearchKeyword,current,pageSize,false,currentSearchSortBy,OnlySearchLabel); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function nextPage(){ |
|
|
|
var current = $('#currentPage').text(); |
|
|
|
console.log("current=" + current); |
|
|
|
page(current,pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
function prePage(){ |
|
|
|
var current =$('#currentPage').text(); |
|
|
|
console.log("current=" + current); |
|
|
|
if(current > 1){ |
|
|
|
console.log("current=" + (current - 2)); |
|
|
|
page(current - 2,pageSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function goPage(){ |
|
|
|
var goNum = $('#goNum').val(); |
|
|
|
|
|
|
|
var pageTotal = $("#totalNum").text(); |
|
|
|
var pageNum = parseInt(pageTotal/pageSize); |
|
|
|
if(pageTotal%pageSize!=0){ |
|
|
|
pageNum += 1; |
|
|
|
}else { |
|
|
|
pageNum = pageNum; |
|
|
|
} |
|
|
|
if (goNum<=0){ |
|
|
|
alert("请输入大于0的数值"); |
|
|
|
} |
|
|
|
else if(goNum<=pageNum){ |
|
|
|
page(goNum - 1,pageSize); |
|
|
|
} |
|
|
|
else{ |
|
|
|
alert("不能超出总页码!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setPage(pageData,pageSize,currentPage){ |
|
|
|
if (isEmpty(pageData)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
var startIndex = currentPage * pageSize; |
|
|
|
if(pageData.Total > 0){ |
|
|
|
startIndex = startIndex + 1; |
|
|
|
} |
|
|
|
$('#startIndex').text(startIndex); |
|
|
|
$('#endIndex').text(pageData.current * pageSize + pageData.data.length); |
|
|
|
$('#totalNum').text(pageData.total); |
|
|
|
$('#displayPage1').text(pageData.current + 1); |
|
|
|
|
|
|
|
console.log("set prePage status, pageData.current=" + pageData.current); |
|
|
|
|
|
|
|
if(pageData.current == 0){ |
|
|
|
console.log("set prePage disabled."); |
|
|
|
$('#prePage').removeAttr("href"); |
|
|
|
} |
|
|
|
else{ |
|
|
|
$('#prePage').attr("href","javascript:prePage()"); |
|
|
|
} |
|
|
|
|
|
|
|
if((pageData.current + 1) * pageSize >= pageData.total){ |
|
|
|
console.log("set nextPage disabled."); |
|
|
|
$('#nextPage').removeAttr("href"); |
|
|
|
} |
|
|
|
else{ |
|
|
|
$('#nextPage').attr("href","javascript:nextPage()"); |
|
|
|
} |
|
|
|
|
|
|
|
var pageTotal = pageData.total; |
|
|
|
var pageNum = parseInt(pageTotal/pageSize); |
|
|
|
if(pageTotal%pageSize!=0){ |
|
|
|
pageNum += 1; |
|
|
|
}else { |
|
|
|
pageNum = pageNum; |
|
|
|
} |
|
|
|
$("#totalPageNum").text(pageNum); |
|
|
|
} |