| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373 |
- var _lang = "";
- var _langsetting = "";
- var _channelType = 'translation'
- var _progress = 0.9;
- var _view = "community";
- var main_tag = "";
- var list_tag = new Array();
- var currTagLevel0 = new Array();
- var allTags = new Array();
- var arrMyTerm = new Array();
- var _listView="list";
- var gBreadCrumbs=['','','','','','','','',''];
- var _nextPageStart = 0;
- var _pageSize = 20;
- var _channel = "";
- var _palicanonCategory,_palicanonCategoryCurrent,_palicanonCategoryPath;
- var _tags = "";
- var _channelList;
- palicanon_load_term();
- function getLangSetting(setting){
- switch (setting) {
- case 'auto':
- switch (getCookie("language")) {
- case 'zh-cn':
- return 'zh';
- break;
- case 'zh-tw':
- return 'zh';
- break;
- case '':
- return '';
- break;
- }
- break;
- default:
- return setting;
- break;
- }
- }
- function updateSetting(){
- _langsetting = $("#setting_lang").val();
- _lang = getLangSetting(_langsetting);
- _channelType = $("#setting_channel_type").val();
- _progress = $("#setting_progress").val();
- localStorage.setItem("pc_filter_setting",JSON.stringify({
- lang : _lang,
- lang_setting: $("#setting_lang").val(),
- channel_type : _channelType,
- progress:_progress,
- }))
- switch (_view) {
- case 'community':
- _nextPageStart = 0;
- LoadAllChannel();
- communityGetChapter();
- break;
- case 'category':
-
- break;
- default:
- break;
- }
-
- }
- /*
- 载入过滤器设置
- */
- function loadFilterSetting(){
- if (localStorage.getItem ("pc_filter_setting")) {
- let setting = JSON.parse(localStorage.getItem("pc_filter_setting"));
- _langsetting = setting.lang_setting;
- _lang = getLangSetting(_langsetting);
- _channel_type = setting.channel_type;
- _progress = setting.progress;
- }
- _nextPageStart = 0;
- }
- function community_onload() {
- $("#main_view").addClass("community");
- $("span[tag]").click(function () {
- $(this).siblings().removeClass("select");
- $(this).addClass("select");
- main_tag = $(this).attr("tag");
- list_tag = new Array();
- tag_changed();
- render_selected_filter_list();
- });
- $("#tag_input").keypress(function () {
- tag_render_others();
- });
- render_main_tag();
- render_selected_filter_list();
- communityGetChapter();
- LoadAllChannel();
- LoadAllLanguage();
- }
- function palicanon_onload() {
- $("#main_view").addClass("category");
- $("span[tag]").click(function () {
- $(this).siblings().removeClass("select");
- $(this).addClass("select");
- main_tag = $(this).attr("tag");
- list_tag = new Array();
- tag_changed();
- render_selected_filter_list();
- });
- $("#tag_input").keypress(function () {
- tag_render_others();
- });
- render_main_tag();
- LoadAllChannel();
- LoadAllLanguage();
- }
- function palicanon_load_term() {
- let lang =getCookie("language");
- switch (lang) {
- case 'zh-cn':
- lang = 'zh-hans';
- break;
- case 'zh-tw':
- lang = 'zh-hant';
- break;
- case '':
- lang = 'en';
- break;
- }
- $.get(
- "/api/v2/terms",
- {
- view:'hot-meaning',
- language: lang,
- },
- function (data) {
- if (data.ok) {
- arrMyTerm = data.data.rows;
- render_main_tag();
- } else {
- alert(data.message);
- }
- }
- );
- }
- function render_main_tag() {
- $("#main_tag")
- .children()
- .each(function () {
- $(this).html(tag_get_local_word($(this).attr("tag")));
- });
- }
- function tag_changed() {
- _nextPageStart= 0;
- let strTags = "";
- if (list_tag.length > 0) {
- _tags = list_tag.join();
- } else {
- _tags = "";
- }
- console.log(_tags);
- let lang = getCookie("language");
- switch (lang) {
- case 'zh-cn':
- lang = 'zh-hans';
- break;
- case 'zh-tw':
- lang = 'zh-hant';
- break;
- case '':
- lang = 'en';
- break;
- }
- switch (_view) {
- case "community":
- communityGetChapter()
- break;
- case "category":
- if(_tags == ""){
- updatePalicanonCategoryList();
- $("#palicanon-category").show();
- $("#chapter_shell").hide();
- }else{
- palicanonGetChapter(_tags,lang);
- }
- break;
- case "my":
- break;
- default:
- break;
- }
- gBreadCrumbs =['','','','','','','','',''];
- RenderBreadCrumbs();
- updataHistory();
- }
- function updataHistory(){
- let url = "?view="+_view;
- if(_tags !== ""){
- url += "&tag=" + _tags;
- }
- if(_channel !== ""){
- url += "&channel=" + _channel;
- }
- history.pushState({view:_view,tag:_tags,channel:_channel}, 'title', url);
- }
- function communityGetChapter(offset=0){
- next_page_loader_show();
- $.getJSON(
- "/api/v2/progress?view=chapter",
- {
- tags: _tags,
- lang: _lang,
- channel: _channel,
- channel_type: _channelType,
- offset: offset
- }
- )
- .done(function (data, status) {
- $("#filter_bar_left").html(data.data.count+"个章节");
- let arrChapterData = data.data.rows;
- let arrChapterList = new Array();
- let html = "";
- allTags = new Array();
- let arrChapter = new Array();
- for (const iterator of arrChapterData) {
- arrChapterList.push({
- book:iterator.book,
- para:iterator.para,
- level:2,
- title:iterator.toc,
- progress:{lang:'en',all_trans:iterator.progress},
- tag:'',
- trans_title:iterator.title,
- channel_id:iterator.channel_id,
- type:'article',
- channel_info:iterator.channel,
- path:JSON.parse(iterator.path),
- views:iterator.views,
- likes:iterator.likes,
- tags:iterator.tags,
- summary:iterator.summary,
- created_at:iterator.created_at
- });
- }
- for (const iterator of arrChapterList) {
- arrChapter.push(iterator);
- }
-
- if(_nextPageStart==0){
- palicanon_chapter_list_apply(0);
- $("#list-1").html(render_chapter_list(arrChapter));
- }else{
- $("#list-1").append(render_chapter_list(arrChapter));
- }
- next_page_loader_hide();
- })
- .fail(function(jqXHR, textStatus, errorThrown){
- switch (jqXHR.status) {
- case 404:
- $("#list-1").html("未找到");
- next_page_loader_hide();
- break;
- case 500:
- console.error('/api/v2/progress?view=chapter',textStatus);
- break;
- default:
- break;
- }
- });
- communityLoadChapterTag();
- }
- function communityLoadChapterTag(strTags="",lang=""){
- $.getJSON(
- "/api/v2/progress?view=chapter-tag",
- {
- tags: _tags,
- lang: _lang,
- channel:_channel
- },
- function (data, status) {
- let tagData = data.data.rows;
- allTags = new Array();
- let maxCount = tagData[0].count;
- for (const tag of tagData) {
- if(tag.count < maxCount){
- allTags[tag.name] = tag.count;
- }
- }
- tag_render_others();
- });
- }
- function palitextGetChapter(strTags=""){
- if(_tags==""){
- return;
- }
- $.getJSON(
- "/api/v2/palitext?view=chapter",
- {
- tags: _tags
- }
- )
- .done(function (data, status) {
- let arrChapterData = data.data.rows;
- let arrChapterList = new Array();
- let arrChapter = new Array();
- let lastParent = -1;
- for (let index = 0; index < arrChapterData.length; index++) {
- arrChapterData[index].children = new Array();
- }
- for (const it of arrChapterData) {
- if(arrChapterList.length==0){
- arrChapterList.push(it);
- continue;
- }
- if(lastParent>=0){
- //判断是否为这个章节的子章节
- if(arrChapterList[lastParent].book==it.book && arrChapterList[lastParent].paragraph == it.parent){
- arrChapterList[lastParent].children.push(it)
- }else{
- arrChapterList.push(it);
- lastParent = -1;
- }
- }else{
- //判断是否为最末尾章节的子章节
- if(arrChapterList[arrChapterList.length-1].book==it.book && arrChapterList[arrChapterList.length-1].paragraph == it.parent){
- lastParent = arrChapterList.length-1;
- arrChapterList[arrChapterList.length-1].children.push(it);
- }else{
- arrChapterList.push(it);
- }
- }
- }
- palicanon_chapter_list_apply(0);
- $("#list-1").html(render_chapter_list(arrChapterList));
-
- })
- .fail(function(jqXHR, textStatus, errorThrown){
- switch (jqXHR.status) {
- case 404:
- $("#list-1").html("未找到");
- next_page_loader_hide();
- break;
- case 500:
- console.error('/api/v2/progress?view=chapter',textStatus);
- break;
- default:
- break;
- }
- });
- palitextLoadChapterTag(strTags);
- }
- function palitextLoadChapterTag(strTags=""){
- $.getJSON(
- "/api/v2/palitext?view=chapter-tag",
- {
- tags: strTags,
- },
- function (data, status) {
- let tagData = data.data.rows;
- allTags = new Array();
- let maxCount = tagData[0].count;
- for (const tag of tagData) {
- if(tag.count < maxCount){
- allTags[tag.name] = tag.count;
- }
- }
- tag_render_others();
- });
- }
- function palicanonGetChapter(strTags,lang){
- palitextGetChapter(strTags);
- }
- function viewChanged(obj){
- _listView = $(obj).val();
- updateFirstListView();
- }
- function updateFirstListView(){
- if(_listView == "list"){
- $("#list_shell_1").removeClass("book_view");
- $("#list_shell_1").addClass("list_view");
- }else{
- $("#list_shell_1").addClass("book_view");
- $("#list_shell_1").removeClass("list_view");
- }
- }
- function palicanon_load_chapter(book, para, div_index = 1) {
- let lang = getCookie("language");
- if (lang == "zh-cn") {
- lang = "zh-hans";
- } else if (lang == "zh-tw") {
- lang = "zh-hant";
- } else if (lang == "") {
- lang = "en";
- }
- $.get(
- "../palicanon/get_chapter_info.php",
- {
- book: book,
- para: para,
- lang: lang,
- },
- function (data, status) {
- palicanon_chapter_list_apply(div_index);
- let arrChapterInfo = JSON.parse(data);
- let html = render_chapter_head(arrChapterInfo, div_index);
- $("#chapter_head_" + (parseInt(div_index) + 1)).html(html);
- let lang = getCookie("language");
- if (lang == "zh-cn") {
- lang = "zh-hans";
- } else if (lang == "zh-tw") {
- lang = "zh-hant";
- } else if (lang == "") {
- lang = "en";
- }
- $.get(
- "./get_chapter_children.php",
- {
- book: book,
- para: para,
- lang: lang,
- },
- function (data, status) {
- let arrChapterList = JSON.parse(data);
- $("#list-" + (parseInt(div_index) + 1)).html(render_chapter_list(arrChapterList));
-
- }
- );
- //获取章节的channel列表
- loadChapterChannel({
- book:book,
- para:para,
- readonly:true,
- target:$("#chapter_head_" + (parseInt(div_index) + 1)).find('.progress').first()
- });
- }
- );
- }
- function render_chapter_head(chapter_info, parent) {
- let html = "";
- html = "<div class='chapter_head_tool_bar'>";
- html +=
- "<div><span class='chapter_back_button' id='chapter_back_" +
- (parent + 1) +
- "' onclick=\"chapter_back('" +
- parent +
- "')\">back</span></div>";
- html +=
- "<div><button class='chapter_close_button' id='chapter_close_" +
- (parent + 1) +
- "' onclick=\"chapter_back('" +
- parent +
- "')\">⬅</button></div>";
- html += "</div>";
- let link = "../reader/?view=chapter&book=" + chapter_info.book + "&par=" + chapter_info.paragraph;
- html += "<div class='title'>";
- let sToc = chapter_info.toc;
- html += " <div class='title_1'>";
- if (typeof chapter_info.trans_title == "undefined") {
- html += "<a href='" + link + "' target='_blank'>" ;
- if(sToc == ""){
- html += "[unnamed]" ;
- }else{
- switch (getCookie('language')) {
- case 'my':
- html += roman_to_my(sToc);
- break;
- case 'si':
- html += roman_to_si(sToc);
- break;
- default:
- html += sToc ;
- break;
- }
- }
- html += "</a>";
- } else {
- html += "<a href='" + link + "' target='_blank'>" + chapter_info.trans_title + "</a>";
- }
- html += "</div>";
- html += "<div class='title_2'>" + sToc + "</div>";
- html += "</div>";
- html += "<div class='res res_more'>";
- html += "<h2>译文</h2>";
- html += "<div class='progress' id='chapter_progress'>";
- 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 += ' <div class="item">';
- html += '<svg class="progress_circle" width="30" height="30" viewbox="0,0,30,30">';
- html += '<circle class="progress_bg" cx="15" cy="15" r="12" stroke-width="5" fill="none"></circle>';
- html +=
- '<circle class="progress_color" cx="15" cy="15" r="12" stroke-width="5" fill="none" stroke-dasharray="' +
- stroke1 +
- " " +
- stroke2 +
- '"></circle>';
- html += "</svg>";
- html += "<div class='lang'>" + iterator.lang + "-" + parseInt(iterator.all_trans * 100) + "%</div>";
- html += " </div>";
- }
- } else {
- html += "无译文";
- }
- html += "</div>";
- html += "</div>";
- 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 += "<div id='chapter_head_" + (iDiv + 1) + "' class='chapter_head'></div>";
- html += "<ul id='list-" + (iDiv + 1) + "' class='grid' level='" + (iDiv + 1) + "'>";
- html += "</ul>";
- html += "<div id='more_chapter'>";
- html += '<div id="page_loader" class="lds-ellipsis" style="visibility: hidden;"><div></div><div></div><div></div><div></div></div>';
- html += "<div id='more_chapter_line'></div>";
- html += "<button id='btn_more_chapter' onclick='next_page()'>More</button>";
- html += "</div>";
- $("#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 += '<svg class="progress_circle" width="16" height="16" viewbox="0,0,30,30">';
- html += '<circle class="progress_bg" cx="15" cy="15" r="12" stroke-width="5" fill="none"></circle>';
- html +=
- '<circle class="progress_color" cx="15" cy="15" r="12" stroke-width="5" fill="none" stroke-dasharray="' +
- stroke1 +
- " " +
- stroke2 +
- '"></circle>';
- html += "</svg>";
- return html;
-
- }
- function palicanon_render_chapter_row(chapter) {
- 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 +='<li class="' + levelClass +'" book="' + chapter.book + '" para="' + para + '"';
- if(typeof chapter.type !== "undefined" && chapter.type==='article'){
- html += ' channel="' + chapter.channel_id + '" type="' + chapter.type + '"';
- }
- html += ' >';
-
- html += '<div class="main">';
- html += '<div class="left">';
- html += "<div class='left_items'>";
- if(typeof chapter.views != "undefined"){
- html += "<div class='left_item'>";
- html += "<span class='item'>";
- html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#eye'>";
- html += "</svg>" ;
- html += "<span class='text'>";
- html += chapter.views;
- html += "</span>";
- html += "</span>";
- html += "</div>"
- }
- if(typeof chapter.likes != "undefined"){
- html += "<div class='left_item'>";
- html += "<span class='item'>";
- html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#heart'>";
- html += "</svg>" ;
- html += "<span class='text'>";
- html += chapter.likes;
- html += "</span>";
- html += "</span>";
- html += "</div>"
- }
- //完成度
- if(chapter.progress && chapter.progress.all_trans){
- html += "<div class='left_item'>";
- html += "<span class='item'>";
- html += renderProgress(chapter.progress.all_trans);
- html += "<span class='text'>";
- if(chapter.progress){
- html += parseInt(chapter.progress.all_trans*100+1)+"%";
- }else{
- html += "无";
- }
- html += "</span>";
- html += "</span>";
- html += "</div>"
- }
- html += "<div class='left_item'></div>"
- html += "</div>";//end of left_items
- html += "<div class='chapter_icon'>";
- html += '<span class="" style="margin-right: 1em;padding: 4px 0;">';
- html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
- if(typeof chapter.type !== "undefined" && chapter.type==='article'){
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal-text'>";
- }else{
- if (chapter.level == 1) {
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal'>";
- }else{
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#folder2-open'>";
- }
- }
- html += "</svg>" ;
- html += "</span>";
- html += "</div>";
- html += '</div>';//end of left
- html += '<div class="right">';
- html += '<div class="head_bar">';
- html += '<div class="title" >';
- html += '<div class="title_left" onclick="chapter_onclick(this)">';
-
- let sPaliTitle = chapter.title;
- if(chapter.title==""){
- sPaliTitle = "unnamed";
- }
- if (typeof chapter.trans_title == "undefined" || chapter.trans_title == "") {
- html += " <div class='title_1'>" ;
- switch (getCookie('language')) {
- case 'my':
- html += roman_to_my(sPaliTitle);
- break;
- case 'si':
- html += roman_to_si(sPaliTitle);
- break;
- default:
- html += sPaliTitle ;
- break;
- }
-
- html += "</div>";
- } else {
- html += " <div class='title_1'>" + chapter.trans_title + "</div>";
- }
- html += '<div class="title_2" lang="pali">' + sPaliTitle + "</div>";
- html += '<div class="title_2" lang="pali">';
- //书名
- 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 += "<span class='item'>";
- html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journals'>";
- html += "</svg>" ;
- html += arrPath[0].title;
- html += "</span>";
- }
-
- }
- let chapterPara;
- if(chapter.paragraph){
- }
- html += "</div>";
- html += "</div>";
- html += '<div class="title_right" >';
- html += "<img class='chapter_dynamic_svg' src='/storage/images/chapter_dynamic/";
- html += chapter.book + "/";
- if(chapter.paragraph){
- html += chapter.paragraph;
- }else{
- html += chapter.para;
- }
- if(chapter.channel_id){
- html += "/ch_" + chapter.channel_id;
- }else{
- html += "/globle";
- }
- html += ".svg' />";
- html += "</div>";
- html += "</div>";
- html += '<div class="resource">';
- if(chapter.summary){
- html += chapter.summary;
- }
- html += "</div>";
- html += '<div class="more_info">';
- //最下面一栏,左侧的标签列表
- html += "<div class='chapter_tag'>";
- if(chapter.tags){
- html += renderChapterTags(chapter.tags);
- }
-
- html += "</div>";
- html += "<div class='palicanon_chapter_info'>"
- if(typeof chapter.type !== "undefined" && chapter.type==='article'){
- html += "<span class='item channel'>";
- html += "<svg class='small_icon' style='width:16px;height:16px;fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#person-circle'>";
- html += "</svg>" ;
- html += "<span class='text' onclick=\"select_channel('"+chapter.channel_id+"')\">";
- html += chapter.channel_info.name;
- html += "</span>";
- html += "</span>";
- }
- if(chapter.created_at){
- html += "<span class='item'>";
- html += "<svg class='small_icon' style='width:16px;height:16px;fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#clock'>";
- html += "</svg>" ;
- html += "<span class='text'>";
- html += getPassDataTime(new Date(chapter.created_at));
- html += "</span>";
- html += "</span>";
- }
- if(chapter.children && chapter.children.length>0){
- html += "<span class='item' onclick=\"subchapter_slideToggle(this)\">";
- html += "<span class='text'>";
- html += "展开折叠子章节 " + chapter.children.length;
- html += "</span>";
- html += "</span>";
- }
- html += "</div>";
- html += "</div>";
- html += "</div>";//end of head bar
- html += "</div>";
- html += "</div>";//end of main
- html += "<div class='subchapter'>";
- if(chapter.children){
- html += "<ul class='subchapter_inner'>";
- for (const subchapter of chapter.children) {
- html +=palicanon_render_chapter_row(subchapter);
- }
- html += "</ul>";
- }
- html += "</div>";
- html += "</li>";
- 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 =
- '<button class="canon-tag" onclick ="tag_click(\'' + key + "')\" >" + key + "("+count+ ")"+"</button>";
- }
- } else {
- let keyname = tag_get_local_word(key);
- strOthersTag =
- '<button class="canon-tag" title="' +
- key +
- '" onclick ="tag_click(\'' +
- key +
- "')\" >" +
- keyname + "("+count+ ")"+
- "</button>";
- }
- 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 += '<tag onclick="tag_set(\''+iterator.name+'\')">';
- html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#tag'>";
- html += "</svg>"
- html += '<span class="textt" title="' + iterator.name + '">' + tag_get_local_word(iterator.name) + "</span>";
- //html += '<span class="tag-delete" onclick ="tag_remove(\'' + iterator + "')\">✕</span>";
- html += "</tag>";
- }
- 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 += '<tag>';
- strListTag += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
- strListTag += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#tag'>";
- strListTag += "</svg>"
- strListTag += '<span class="textt" title="' + iterator + '">' + tag_get_local_word(iterator) + "</span>";
- strListTag += '<span class="tag-delete" onclick ="tag_remove(\'' + iterator + "')\">✕</span></tag>";
- }
- }
- strListTag +="</div>";
- $("#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 += '<tag>';
- html += '<span class="textt" title="">版本:' + item.channel.name + "</span>";
- html += '<span class="tag-delete" onclick ="channel_tag_remove(\'' + item.channel_id + "')\">✕</span>";
- html += "</tag>";
- }
- }
- }
- html +="</div>";
- $("#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 = "<ul class='chapter_list'>";
- if(_palicanonCategoryPath.length>1){
- html += "<li onclick=\"updatePalicanonCategoryList('__prev__')\">";
- html += "上一级";
- html += "</li>";
- }
- for (const item of _palicanonCategoryCurrent) {
- html += "<li onclick=\"updatePalicanonCategoryList('"+item.name+"')\">";
- html += "<div class='left_icon'>";
- html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#folder'>";
- html += "</svg>" ;
- html += "</div>";
- html += "<div class='title'>";
- html += '<div class="title_left" onclick="chapter_onclick(this)">';
- html += '<div class="title_1">'+item.name+'</div>';
- html += '<div class="title_2" lang="pali">'+item.name+'</div>';
- html += "</div>";
- html += '<div class="title_right">';
- html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#chevron-right'>";
- html += "</svg>" ;
- html += '</div>';
- html += "</div>";
- html += "</li>";
- }
- html += "</ul>";
- return html;
- }
- function loadTagCategory(name="defualt"){
- $.getJSON("./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("./category/index.json",function(result){
- let indexFilename = localStorage.getItem('palicanon_tag_category');
- if(!indexFilename){
- indexFilename = "defualt";
- }
- let html="";
- for (const iterator of result) {
- html += "<option ";
- if(indexFilename==iterator.file){
- html += " selected ";
- }
- html += " value='"+iterator.file+"'>"+iterator.name+"</option>";
- }
- $("#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 += "<span>";
- html += '<a onclick="chapter_back(1)" title="'+gLocal.gui.close+'">';
- html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#arrow-left-square'>";
- html += "</svg>" ;
- html += '</a>';
- html += "</span>";
- for (const iterator of gBreadCrumbs) {
- if(iterator.title1){
- html += "<span>";
- html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
- html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#chevron-right'>";
- html += "</svg>" ;
- html += "</span>";
- html += "<span>";
- html += '<a onclick="chapter_back('+(iterator.level+1)+')">';
- html += iterator.title1;
- html += '</a>';
- html += "</span>";
- }
- }
- $("#bread-crumbs").html(html);
- }
- function select_channel(id,obj=null){
- _channel = id;
- updataHistory();
- communityGetChapter(0);
- 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 += "<ul>"
- _channelList = data.data.rows;
- for (const iterator of data.data.rows) {
- if(iterator.channel){
- html += "<li onclick=\"select_channel('"+iterator.channel.uid+"',this)\">"
- html += iterator.channel.name+"("+iterator.count+")";
- html += "</li>"
- }
- }
- html += "</ul>";
- $("#filter-author").html(html);
- refresh_selected_channel();
- }
- );
- }
- function LoadAllLanguage(){
- $.getJSON(
- "/api/v2/progress?view=lang",
- {},
- function (data, status) {
- let html = "";
- html += "<option value='auto'>自动</option>";
- html += "<option value=''>全部</option>";
- for (const iterator of data.data.rows) {
- if(iterator.lang!=''){
- html += "<option value='"+iterator.lang+"' ";
- if(_langsetting==iterator.lang){
- html +=" selected ";
- }
- html +=">";
- html += iterator.lang+"("+iterator.count+")";
- html += "</option>"
- }
- }
- $("#setting_lang").html(html);
- }
- );
- }
- function ReanderMainMenu(){
- let html ="";
- html += "<span ";
- if(_view=="community"){
- html += "class='select'";
- }
- html +="><a href='index.php?view=community'>社区</a></span>";
- html += "<span ";
- if(_view=="category"){
- html += "class='select'";
- }
- html +="><a href='index.php?view=category' >分类</a></span>";
- html += "<span ";
- if(_view=="my"){
- html += "class='select'";
- }
- html +="><a href='index.php?view=my' >我的</a></span>";
- $("#main_menu").html(html);
- }
- function loadUserRecent(){
- $.getJSON(
- "/api/v2/view?view=user-recent", function() {
- console.log( "success" );
- }
- )
- .done(function(data) {
- let html = "";
- html += "<ol>";
- for (const item of data.data) {
- html += "<li>";
- html += item.title;
- html += "</li>";
- }
- html += "</ol>";
- $("#user_recent").find('.list').first().html(html);
- })
- .fail(function() {
- console.log( "error" );
- });
- }
- function loadContribution(){
- $.getJSON(
- "/api/v2/sent_history?view=contribution", function() {
- console.log( "success" );
- }
- )
- .done(function(data) {
- let html = "";
- html += "<ol>";
- for (const item of data.data) {
- html += "<li>";
- html += item.username.nickname;
- html += "—";
- html += item.count;
- html += "</li>";
- }
- html += "</ol>";
- $("#contribution").find('.list').first().html(html);
- })
- .fail(function() {
- console.log( "error" );
- });
- }
|