拼接分頁 js
/**
*收藏或取消收藏
*/
function scSave(_this,id){
var params={
collect:trim($("#collect").val()),
infoid:id,
rnd:Math.random()
}
$.ajax({
type:"post",
url:"/userApi/collectOrNot",
dataType: "json",
async:true,
data:params,
success: function(data){
if(undefined==data||data==null) {
alert("收藏庫檔案出現異常");
}else if("-2"==data){
rewardUserLogin();
}else if("1"==data){
$("#collect").val(true);
$(".dpart01div div").attr("class","dpart01div_img collect");
$(".dpart01div_p").html("");
$(".dpart01div_p").html("已收藏");
}else{
$("#collect").val(false);
$(".dpart01div div").attr("class", "dpart01div_img");
$(".dpart01div_p").html("");
$(".dpart01div_p").html("收藏");
}
}
});
}
/**
* 下載當前檔案(通過詞庫id,當前已經關閉)
*/
function downloadth(_this,id){
//驗證是否登入
if (!isLogin()) {
rewardUserLogin();
return false;
}
location.href="/exportExcel/downloadThesaurusFileById/"+id;
}
/**
* 載入更多評論
*/
var currentPage = 2;
var infoId = '${infoId}';
var channelId = 2;
function loadCommentData(){
$.ajax({
type:"post",
url:"/comment/ajaxCommentList",
dataType: "json",
async:false,
data:{currentPage : currentPage,infoId : infoId,channelId : channelId,rnd : Math.random()},
success: function(page){
var html="";
var data = page.data;
var totalPage = page.totalPage;
for(var i in data){
var opt = data[i];
html+="<li>"
html+="<a href=\"javascript:;\">";
if(opt.logoPath!=""&&opt.logoPath!=null){
html+="<img src="+opt.logoPath+" alt=\"評論使用者\">";
}else{
html+="<img src=\"images/userDefault.jpg\" alt=\"評論使用者\">";
}
html+="</a>";
html+="<div class=\"commentList\">";
html+="<div class=\"listTitle\">";
html+="<div class=\"listUser\">";
html+=" <a href=\"javascript:;\">"+opt.noName+"</a>";
html+="</span>";
html+="<span class=\"listTime\">"+opt.dateStr+"</span>";
html+="</div>";
html+="<div class=\"commentDetail\">";
html+="<p>"+subStr(opt.content,40,'...')+"</p>";
html+="</div>";
html+="</div>";
html+="</li>";
}
if(totalPage >= currentPage){
$("#com-list").append(html);
currentPage++;
if(totalPage < currentPage){
$("#load_moreb").text("暫時沒有更多相關評論~~~");
}
}
}
});
}
function subStr(str,length,append){
var pattern =/#[^#]+#/g;
str=str.replace(pattern,"");
if(str.length>length){
str=str.substring(0,length)+append;
}
return str;
}