var _display = ""; var _word = ""; var _channal = ""; var _lang = ""; var _author = ""; var _arrData; var _channalData; /* {{203-1654-23-45@11@en@*}} 203-1654-23-45@11@en@*
pali text
*/ /* 解析百科字符串 {{203-1654-23-45@11@en@*}} */ function note_create() { $("#dialog").dialog({ autoOpen: false, width: 550, buttons: [ { text: "Save", click: function () { note_sent_save(); $(this).dialog("close"); }, }, { text: "Cancel", click: function () { $(this).dialog("close"); }, }, ], }); } function note_init(input) { let output = "
"; let newString = input.replace(/\{\{/g, ''); output = marked(newString); output += "
"; return output; } function note_update_background_style() { var mSentsBook = new Array(); var mBgIndex = 1; $("note").each(function () { let info = $(this).attr("info").split("-"); if (info.length >= 2) { let book = info[0]; $(this).attr("book", book); if (!mSentsBook[book]) { mSentsBook[book] = mBgIndex; mBgIndex++; } $(this).addClass("bg_color_" + mSentsBook[book]); } }); } // function note_refresh_new() { note_update_background_style(); let objNotes = document.querySelectorAll("note"); let arrSentInfo = new Array(); for (const iterator of objNotes) { let id = iterator.id; if (id == null || id == "") { id = com_guid(); iterator.id = id; let info = iterator.getAttributeNode("info").value; let arrInfo = info.split("-"); if (arrInfo.length >= 2) { let book = arrInfo[0]; let para = arrInfo[1]; } if (info && info != "") { arrSentInfo.push({ id: id, data: info }); } } } if (arrSentInfo.length > 0) { let setting = new Object(); setting.lang = ""; setting.channal = _channal; $.post( "../term/note.php", { setting: JSON.stringify(setting), data: JSON.stringify(arrSentInfo), }, function (data, status) { if (status == "success") { try { _arrData = JSON.parse(data); for (const iterator of _arrData) { let id = iterator.id; let strHtml = ""; if (_display && _display == "para") { //段落模式 let strPalitext = "" + iterator.palitext + ""; let divPali = $("#" + id) .parent() .children(".palitext"); if (divPali.length == 0) { $("#" + id) .parent() .prepend("
"); } $("#" + id) .parent() .children(".palitext") .first() .append(strPalitext); let htmlTran = ""; for (const oneTran of iterator.translation) { htmlTran += "" + marked(term_std_str_to_tran(oneTran.text)) + ""; } $("#" + id).html(htmlTran); } else { //句子模式 strHtml += note_json_html(iterator); $("#" + id).html(strHtml); } } $(".palitext").click(function () { let sentid = $(this).parent().attr("info").split("-"); window.open( "../pcdl/reader.php?view=sent&book=" + sentid[0] + "¶=" + sentid[1] + "&begin=" + sentid[2] + "&end=" + sentid[3] ); }); $("pali").click(function () { window.open( "../pcdl/reader.php?view=sent&book=" + $(this).attr("book") + "¶=" + $(this).attr("para") + "&begin=" + $(this).attr("begin") + "&end=" + $(this).attr("end") ); }); note_ref_init(); term_get_dict(); note_channal_list(); } catch (e) { console.error(e); } } } ); } } function note_channal_list() { console.log("note_channal_list start"); let objNotes = document.querySelectorAll("note"); let arrSentInfo = new Array(); $("note").each(function () { let info = $(this).attr("info"); if (info && info != "") { arrSentInfo.push({ id: "", data: info }); } }); /* for (const iterator of objNotes) { { let info = iterator.getAttributeNode("info").value; if (info && info != "") { arrSentInfo.push({ id: "", data: info }); } } } */ if (arrSentInfo.length > 0) { $.post( "../term/channal_list.php", { setting: "", data: JSON.stringify(arrSentInfo), }, function (data, status) { if (status == "success") { try { let active = JSON.parse(data); _channalData = active; for (const iterator of _my_channal) { let found = false; for (const one of active) { if (iterator.id == one.id) { found = true; break; } } if (found == false) { _channalData.push(iterator); } } let strHtml = ""; for (const iterator of _channalData) { if (_channal.indexOf(iterator.id) >= 0) { strHtml += render_channal_list(iterator); } } for (const iterator of _channalData) { if (_channal.indexOf(iterator.id) == -1) { strHtml += render_channal_list(iterator); } } $("#channal_list").html(strHtml); $("[channal_id]").change(function () { let channal_list = new Array(); $("[channal_id]").each(function () { if (this.checked) { channal_list.push($(this).attr("channal_id")); } }); set_channal(channal_list.join()); }); } catch (e) { console.error(e); } } } ); } } function find_channal(id) { for (const iterator of _channalData) { if (id == iterator.id) { return iterator; } } return false; } function render_channal_list(channalinfo) { let output = ""; output += "
"; let checked = ""; if (_channal.indexOf(channalinfo.id) >= 0) { checked = "checked"; } output += '
"; output += "
"; output += ""; output += channalinfo.nickname.slice(0, 2); output += ""; output += "
"; output += "
"; output += "
"; // output += ""; output += ""; output += channalinfo["nickname"]; output += "/" + channalinfo["name"]; output += ""; output += "
"; output += "
"; output += "@" + channalinfo["username"]; output += "
"; output += "
"; output += ""; output += channalinfo["count"] + "/" + channalinfo["all"]; output += ""; output += "
"; output += "
"; output += "
"; return output; } function note_ref_init() { $("chapter").click(function () { let bookid = $(this).attr("book"); let para = $(this).attr("para"); window.open( "../pcdl/reader.php?view=chapter&book=" + bookid + "¶=" + para, "_blank" ); }); $("para").click(function () { let bookid = $(this).attr("book"); let para = $(this).attr("para"); window.open( "../pcdl/reader.php?view=para&book=" + bookid + "¶=" + para, "_blank" ); }); } /* id palitext tran ref */ function note_json_html(in_json) { let output = ""; output += "
" + in_json.palitext + "
"; for (const iterator of in_json.translation) { output += "
"; output += ""; output += "
"; if (iterator.text == "") { //let channal = find_channal(iterator.channal); output += "新建译文"; } else { output += marked(term_std_str_to_tran(iterator.text)); } output += "
"; output += "
"; } output += "
" + in_json.ref; output += "" + in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "" + "
"; return output; } function note_edit_sentence(book, para, begin, end, channal) { let channalInfo; for (const iterator of _channalData) { if (iterator.id == channal) { channalInfo = iterator; break; } } for (const iterator of _arrData) { if ( iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end ) { for (const tran of iterator.translation) { if (tran.channal == channal) { let html = ""; html += "
" + channalInfo.nickname + "/" + channalInfo.name + "
"; html += ""; $("#edit_dialog_content").html(html); break; } } } } $("#dialog").dialog("open"); } function note_sent_save() { let id = $("#edit_dialog_text").attr("sent_id"); let book = $("#edit_dialog_text").attr("book"); let para = $("#edit_dialog_text").attr("para"); let begin = $("#edit_dialog_text").attr("begin"); let end = $("#edit_dialog_text").attr("end"); let channal = $("#edit_dialog_text").attr("channal"); let text = $("#edit_dialog_text").val(); $.post( "../usent/sent_post.php", { id: id, book: book, para: para, begin: begin, end: end, channal: channal, text: text, lang: "zh", }, function (data) { let result = JSON.parse(data); if (result.status > 0) { alert("error" + result.message); } else { alert("成功"); $( "#tran_text_" + result.book + "_" + result.para + "_" + result.begin + "_" + result.end + "_" + result.channal ).html(marked(result.text)); for (const iterator of _arrData) { if ( iterator.book == result.book && iterator.para == result.para && iterator.begin == result.begin && iterator.end == result.end ) { for (const tran of iterator.translation) { if (tran.channal == result.channal) { tran.text = result.text; break; } } } } } } ); }