//获取章节的channel列表
/*
param
{
book:book,
para:para,
target:target,
topchannel:[1,2,3],
showchannel:[1,2,3]
}
*/
function loadChapterChannel(param){
$.getJSON(
"/api/v2/progress?view=chapter_channels",
{
book: param.book,
par: param.para,
},
function (data, status) {
let arrChannelList = data.data.rows;
if(typeof param.readonly != "undefined" && param.readonly == true){
$(param.target).html(render_chapter_progress_list_readonly(arrChannelList,param));
}else{
$(param.target).html(render_chapter_progress_list(arrChannelList,param));
Like();
}
}
);
}
//章节已经有译文的channel 列表
function render_chapter_progress_list(chapterList,param) {
let html = "";
html += "
";
for (const iterator of chapterList) {
if(iterator.channel){
if(param.showchannel){
if(!param.showchannel.includes(iterator.channel.uid)){
continue;
}
}
html += "
";
html += "";
html += "";
html += iterator.channel.name;
html += "";
html += "";
html += "";
html += renderProgressBar(iterator.progress);
html += "";
html += "";
html += iterator.views;
html += "";
html += "";
html += renderChannelLikes(iterator.likes,'progress_chapter',iterator.uid);
html += "";
html += "";
html += getPassDataTime(new Date(iterator.updated_at));
html += "";
html += "
";
}
}
html += "
";
return html;
}
function render_chapter_progress_list_readonly(chapterList,param) {
let html = "";
html += "
";
html += "
";
html += "版本";
html += "进度";
html += "阅读";
html += "点赞";
html += "更新于";
html += "
";
for (const iterator of chapterList) {
if(iterator.channel){
if(param.showchannel){
if(!param.showchannel.includes(iterator.channel.uid)){
continue;
}
}
html += "
";
html += "";
html += "";
html += iterator.channel.name;
html += "";
html += "";
html += "";
html += renderProgressBar(iterator.progress);
html += "";
html += "";
html += iterator.views;
html += "";
html += "";
html += getChapterLikeCount(iterator.likes,'like');
html += "";
html += "";
html += getPassDataTime(new Date(iterator.updated_at));
html += "";
html += "
";
}
}
html += "
";
return html;
}
function getChapterLikeCount(info,likeType){
for (const item of info) {
if(item.type==likeType){
return item.count;
}
}
return 0;
}
function renderChannelLikes(info,restype,resid){
/*
点赞 like
收藏 favorite
关注 watch
书签 bookmark
*/
let like_types = ["like",'favorite',"watch"];
let html = "";
for (const typs of like_types) {
html += ""+count+"";
}
return html;
}
function renderProgressBar(progress){
let html = "";
return html;
}