";
if (chapter_info.progress && chapter_info.progress.length > 0) {
let r = 12;
let perimeter = 2 * Math.PI * r;
for (const iterator of chapter_info.progress) {
let stroke1 = parseInt(perimeter * iterator.all_trans);
let stroke2 = perimeter - stroke1;
html += '
";
return html;
}
function render_chapter_list(chapterList) {
let html = "";
for (const iterator of chapterList) {
html += palicanon_render_chapter_row(iterator);
}
return html;
}
function isChapterWithParent(list, item) {}
function palicanon_chapter_list_apply(div_index) {
let iDiv = parseInt(div_index);
let html = "";
html +=
"";
html +=
"
";
html += "
";
html += "
";
html +=
'
';
html += "";
html += "";
html += "
";
$("#list_shell_" + (iDiv + 1)).html(html);
$("#list_shell_" + (iDiv + 1)).removeClass();
$("#list_shell_" + (iDiv + 1)).addClass("show");
//隐藏之后的列表
for (let index = iDiv + 2; index <= 8; index++) {
$("#list_shell_" + index).removeClass();
$("#list_shell_" + index).addClass("hidden");
}
//收缩当前的
$("#list-" + iDiv).removeClass();
$("#list-" + iDiv).addClass("list");
$("#list_shell_" + iDiv).removeClass();
$("#list_shell_" + iDiv).addClass("list");
updateFirstListView();
}
function next_page_loader_show() {
$("#page_loader").css("visibility", "visible");
}
function next_page_loader_hide() {
$("#page_loader").css("visibility", "hidden");
}
function next_page() {
_nextPageStart += _pageSize;
communityGetChapter(_nextPageStart);
}
function chapter_onclick(obj) {
let objList = $(obj).parent().parent().parent().parent().parent();
let book = $(objList).attr("book");
let para = $(objList).attr("para");
let channel = $(objList).attr("channel");
let type = $(objList).attr("type");
let level = parseInt($(objList).parent().attr("level"));
let title1 = $(objList).find(".title_1").first().text();
if (_view == "category" && level == 1) {
$("#index_div").addClass("popup");
}
if (type == "article") {
window.open(
"../article/index.php?view=chapter&book=" +
book +
"&par=" +
para +
"&channel=" +
channel
);
} else {
gBreadCrumbs[level] = {
title1: title1,
book: book,
para: para,
level: level,
};
RenderBreadCrumbs();
$(objList).siblings().removeClass("selected");
$(objList).addClass("selected");
$("#tag_list").slideUp();
palicanon_load_chapter(book, para, level);
}
}
function close_tag_list() {
$("#tag_list").slideUp();
$("#btn-filter").removeClass("active");
}
function renderProgress(progress = 0, width = 16, height = 16) {
//绘制进度圈
let r = 12;
let perimeter = 2 * Math.PI * r;
let stroke1 = parseInt(perimeter * progress);
let stroke2 = perimeter - stroke1;
let html = "";
html +=
'";
return html;
}
function palicanon_render_chapter_row(chapter, isSub = false) {
let html = "";
let levelClass = "";
if (chapter.level == 1) {
//levelClass = " level_1";
}
let para = 0;
if (chapter.para) {
para = chapter.para;
} else if (chapter.paragraph) {
para = chapter.paragraph;
}
html +=
'
";
html += '
';
html += '
';
html += "
";
if (typeof chapter.views != "undefined") {
html += "
";
html += "";
html += "";
html += "";
html += chapter.views;
html += "";
html += "";
html += "
";
}
if (typeof chapter.likes != "undefined") {
html += "
";
html += "";
html += "";
html += "";
html += chapter.likes;
html += "";
html += "";
html += "
";
}
//完成度
if (chapter.progress && chapter.progress.all_trans) {
html += "
";
html += "";
html += renderProgress(chapter.progress.all_trans);
html += "";
if (chapter.progress) {
html += parseInt(chapter.progress.all_trans * 100 + 1) + "%";
} else {
html += "无";
}
html += "";
html += "";
html += "
";
}
html += "";
html += "
"; //end of left_items
html += "
";
html += '';
html += "";
html += "";
html += "
";
html += "
"; //end of left
html += '
';
html += '
';
html += '
';
html += '
';
let sPaliTitle = chapter.title;
if (chapter.title == "") {
sPaliTitle = "unnamed";
}
if (
typeof chapter.trans_title == "undefined" ||
chapter.trans_title == ""
) {
html += "
";
switch (getCookie("language")) {
case "my":
html += roman_to_my(sPaliTitle);
break;
case "si":
html += roman_to_si(sPaliTitle);
break;
default:
html += sPaliTitle;
break;
}
html += "
";
} else {
html += "
" + chapter.trans_title + "
";
}
html += '
' + sPaliTitle + "
";
html += '
';
//书名
if (chapter.path) {
let arrPath = false;
if (Array.isArray(chapter.path)) {
arrPath = chapter.path;
} else {
try {
arrPath = JSON.parse(chapter.path);
} catch (e) {
console.error("json parse", chapter.path);
}
}
if (arrPath && arrPath.length > 0) {
html += "";
html +=
"";
html += arrPath[0].title;
html += "";
}
}
let chapterPara;
if (chapter.paragraph) {
}
html += "
";
html += "
";
html += '
';
html += "";
/*
if(isSub){
html += "";
}else{
html += "";
}
*/
html += "
";
html += "
";
html += '
';
if (chapter.summary) {
html += chapter.summary;
}
html += "
";
html += '
';
//最下面一栏,左侧的标签列表
html += "
";
if (chapter.tags) {
html += renderChapterTags(chapter.tags);
}
html += "
";
html += "
";
if (typeof chapter.type !== "undefined" && chapter.type === "article") {
html += "";
html +=
"";
html +=
"";
html += chapter.channel_info.name;
html += "";
html += "";
}
if (chapter.created_at) {
html += "";
html +=
"";
html += "";
html += getPassDataTime(new Date(chapter.created_at));
html += "";
html += "";
}
if (chapter.children && chapter.children.length > 0) {
html += "";
html += "";
html += "展开折叠子章节 " + chapter.children.length;
html += "";
html += "";
}
html += "
";
html += "
";
html += "
"; //end of head bar
html += "
";
html += "
"; //end of main
html += "
";
if (chapter.children) {
html += "
";
for (const subchapter of chapter.children) {
html += palicanon_render_chapter_row(subchapter, true);
}
html += "
";
}
html += "
";
html += "
";
return html;
}
function subchapter_slideToggle(obj) {
$(obj)
.parent()
.parent()
.parent()
.parent()
.parent()
.siblings(".subchapter")
.slideToggle();
}
function tag_get_local_word(word) {
let termKey = term_lookup_my(
word,
"",
getCookie("userid"),
getCookie("language")
);
if (typeof termKey == "undefined" || termKey === false || termKey === "") {
switch (getCookie("language")) {
case "my":
return roman_to_my(word);
case "si":
return roman_to_si(word);
default:
return word;
}
} else {
return termKey.meaning;
}
}
function tag_render_others() {
let strOthersTag = "";
currTagLevel0 = new Array();
$(".tag_others").html("");
document.getElementById("main_tag").style.margin = 1 + "em";
document.getElementById("main_tag").style.fontSize = 100 + "%";
for (const key in allTags) {
if (allTags.hasOwnProperty(key)) {
let count = allTags[key];
if ($("#tag_input").val().length > 0) {
if (key.indexOf($("#tag_input").val()) >= 0) {
strOthersTag =
'";
}
} else {
let keyname = tag_get_local_word(key);
strOthersTag =
'";
}
let thisLevel = 100;
if (tag_level.hasOwnProperty(key)) {
thisLevel = tag_level[key].level;
if (tag_level[key].level == 0) {
currTagLevel0[key] = 1;
}
}
$(".tag_others[level='" + thisLevel + "']").html(
$(".tag_others[level='" + thisLevel + "']").html() +
strOthersTag
);
}
}
}
function tag_click(tag) {
list_tag.push(tag);
render_selected_filter_list();
tag_changed();
}
function tag_set(tag) {
list_tag = new Array();
if (Array.isArray(tag)) {
for (const iterator of tag) {
list_tag.push(iterator);
}
} else {
list_tag.push(tag);
}
_tags = list_tag.join();
render_selected_filter_list();
tag_changed();
}
function renderChapterTags(tags) {
let html = "";
for (const iterator of tags) {
html += "";
html += "";
html +=
'' +
tag_get_local_word(iterator.name) +
"";
//html += '✕";
html += "";
}
return html;
}
function render_selected_filter_list() {
refresh_selected_tag();
refresh_selected_channel();
}
function refresh_selected_tag() {
let strListTag = "";
for (const iterator of list_tag) {
if (iterator != "") {
strListTag += "";
strListTag +=
"";
strListTag +=
'' +
tag_get_local_word(iterator) +
"";
strListTag +=
'✕";
strListTag += "";
}
}
$("#tag_selected").html(strListTag);
}
function refresh_selected_channel() {
let channels = _channel.split(",");
let html = "";
for (const iterator of channels) {
if (_channelList) {
let item = _channelList.find(
(element) => element.channel_id == iterator
);
if (item) {
html += "";
html +=
'版本:' +
item.channel.name +
"";
html +=
'✕";
html += "";
}
}
}
html += "";
$("#channel_selected").html(html);
}
function channel_tag_remove(channelId) {
let channels = _channel.split(",");
if (channels.indexOf(channelId) >= 0) {
channels.splice(channels.indexOf(channelId), 1);
_channel = channels.join();
refresh_selected_channel();
tag_changed();
}
}
function tag_remove(tag) {
for (let i = 0; i < list_tag.length; i++) {
if (list_tag[i] == tag) {
list_tag.splice(i, 1);
}
}
render_selected_filter_list();
tag_changed();
}
function sortNumber(a, b) {
return b - a;
}
function tag_list_slide_toggle(element) {
if ($("#tag_list").css("display") == "none") {
$(element).addClass("active");
} else {
$(element).removeClass("active");
}
$("#tag_list").slideToggle();
}
function chapter_back(parent) {
if (_view == "category" && parent == 1) {
$("#index_div").removeClass("popup");
}
let curr = parseInt(parent) + 1;
let prt = parseInt(parent);
//隐藏当前的
for (let index = curr; index < 8; index++) {
$("#list_shell_" + index).removeClass();
$("#list_shell_" + index).addClass("hidden");
gBreadCrumbs[index - 1] = "";
}
//展开上一个
$("#list-" + prt).removeClass();
$("#list-" + prt).addClass("grid");
$("#list_shell_" + prt).removeClass();
$("#list_shell_" + prt).addClass("show");
RenderBreadCrumbs();
}
function categoryGoHome() {
updatePalicanonCategoryList();
$("#palicanon-category").show();
$("#chapter_shell").hide();
tag_set([]);
}
function updatePalicanonCategoryList(name = "__home__") {
switch (name) {
case "__home__":
_palicanonCategoryCurrent = _palicanonCategory.slice();
_palicanonCategoryPath = new Array();
_palicanonCategoryPath.push(_palicanonCategoryCurrent);
break;
case "__prev__":
_palicanonCategoryPath.pop();
_palicanonCategoryCurrent =
_palicanonCategoryPath[
_palicanonCategoryPath.length - 1
].slice();
break;
default:
if (_palicanonCategoryCurrent.length > 0) {
let next = _palicanonCategoryCurrent.find(
(element) => element.name == name
);
if (typeof next !== "undefined") {
if (next.children && next.children.length > 0) {
//有子目录
_palicanonCategoryCurrent = next.children.slice();
_palicanonCategoryPath.push(
_palicanonCategoryCurrent.slice()
);
} else {
//没有子目录
tag_set(next.tag);
$("#palicanon-category").hide();
$("#chapter_shell").show();
}
}
} else {
}
break;
}
$("#palicanon-category").html(renderPalicanonCategoryList());
}
function renderPalicanonCategoryList() {
let html = "
";
if (_palicanonCategoryPath.length > 1) {
html += "
";
html += "上一级";
html += "
";
}
for (const item of _palicanonCategoryCurrent) {
html +=
"
";
html += "
";
html += "";
html += "
";
html += "
";
html += '
';
html += '
' + item.name + "
";
html += '
' + item.name + "
";
html += "
";
html += '
';
html += "";
html += "
";
html += "
";
html += "
";
}
html += "
";
return html;
}
function loadTagCategory(name = "default") {
$.getJSON("../palicanon/category/" + name + ".json", function (result) {
_palicanonCategory = result;
_palicanonCategoryCurrent = _palicanonCategory.slice();
_palicanonCategoryPath = new Array();
_palicanonCategoryPath.push(_palicanonCategoryCurrent.slice());
updatePalicanonCategoryList();
$("#tag-category").html("");
$("#tag-category").fancytree({
autoScroll: true,
selectMode: 1, // 1:single, 2:multi, 3:multi-hier
checkbox: false, // Show checkboxes.
source: tocGetTagCategory(result.slice()),
activate: function (e, data) {
console.log("tree", data);
tag_set(arrTagCategory[data.node.key]);
},
select: function (e, data) {
// Display list of selected nodes
currSelectNode = data.tree.getSelectedNodes();
},
});
});
}
var arrTagCategory = new Array();
function tocGetTagCategory(data) {
let output = new Array();
for (const iterator of data) {
let item = { key: com_uuid(), title: iterator.name, tag: iterator.tag };
arrTagCategory[item.key] = iterator.tag;
if (typeof iterator.children !== "undefined") {
item.children = tocGetTagCategory(iterator.children);
}
output.push(item);
}
return output;
}
function loadTagCategoryIndex() {
$.getJSON("../palicanon/category/index.json", function (result) {
let indexFilename = localStorage.getItem("palicanon_tag_category");
if (!indexFilename) {
indexFilename = "defualt";
}
let html = "";
for (const iterator of result) {
html += "";
}
$("#tag_category_index").html(html);
});
}
function TagCategoryIndexchange(obj) {
localStorage.setItem("palicanon_tag_category", $(obj).val());
//loadTagCategory($(obj).val());
location.reload();
}
function RenderBreadCrumbs() {
let html = "";
html += "";
html += '';
html += "";
html += "";
html += "";
for (const iterator of gBreadCrumbs) {
if (iterator.title1) {
html += "";
html += "";
html += "";
html += "";
html += '';
html += iterator.title1;
html += "";
html += "";
}
}
$("#bread-crumbs").html(html);
}
function select_channel(id, obj = null) {
_channel = id;
_nextPageStart = 0;
updataHistory();
communityGetChapter(_nextPageStart);
refresh_selected_channel();
console.log("change channel", _channel);
//$(obj).siblings.removeClass('active');
//$(obj).addClass('active');
}
function LoadAllChannel() {
$.getJSON(
"/api/v2/progress?view=channel",
{
lang: _lang,
channel_type: _channelType,
progress: _progress,
},
function (data, status) {
let html = "";
html += "
";
_channelList = data.data.rows;
for (const iterator of data.data.rows) {
if (iterator.channel) {
html +=
"
";
html += iterator.channel.name + "(" + iterator.count + ")";
html += "
";
}
}
html += "
";
$("#filter-author").html(html);
refresh_selected_channel();
}
);
}
function LoadAllLanguage() {
$.getJSON("/api/v2/progress?view=lang", {}, function (data, status) {
let html = "";
html += "";
html += "";
for (const iterator of data.data.rows) {
if (iterator.lang != "") {
html += "";
}
}
$("#setting_lang").html(html);
});
}
function ReanderMainMenu() {
let html = "";
html += "" +
gLocal.gui.community_new +
"";
html += "" +
gLocal.gui.pali_text +
"";
html += "" + gLocal.gui.my_read + "";
$("#main_menu").html(html);
}
function loadContribution() {
$.getJSON("/api/v2/sent_history_contribution", function () {
console.log("success");
})
.done(function (data) {
let html = "";
html += "";
for (const item of data.data) {
html += "
";
html += item.username.nickname;
html += "—";
html += item.count;
html += "