var _display = "";
var _word = "";
var _channal = "";
var _lang = "";
var _author = "";
var _arrData = new Array();
var _channalData;
var MAX_NOTE_NEST = 2;
/*
{{203-1654-23-45@11@en@*}}
203-1654-23-45@11@en@*
pali text
*/
/*
解析百科字符串
{{203-1654-23-45@11@en@*}}
*/
function note_create() {
wbw_channal_list_init();
note_sent_edit_dlg_init();
term_edit_dlg_init();
}
function note_sent_edit_dlg_init() {
$("body").append(
'
'
);
$("#note_sent_edit_dlg").dialog({
autoOpen: false,
width: 550,
buttons: [
{
text: gLocal.gui.save,
click: function () {
note_sent_save();
$(this).dialog("close");
},
},
{
text: gLocal.gui.cancel,
click: function () {
$(this).dialog("close");
},
},
],
});
}
function note_init(input) {
let newString = input.replace(/\{\{/g, '');
let output = "
";
output += marked(newString);
output += "
";
return output;
}
function note_update_background_style() {
var mSentsBook = new Array();
var mBgIndex = 1;
$("note[info]").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 == "") {
//查看这个节点是第几层note嵌套。大于预定层数退出。
let layout = 1;
let parent = iterator.parentNode;
while (parent.nodeType == 1) {
if (parent.nodeName == "NOTE") {
layout++;
if (layout > MAX_NOTE_NEST) {
return false;
}
} else if (parent.nodeName == "BODY") {
break;
}
parent = parent.parentNode;
}
id = com_guid();
iterator.id = id;
if (iterator.hasAttribute("info")) {
let info = iterator.getAttribute("info");
if (info != null || info != "") {
/*
let arrInfo = info.split("-");
if (arrInfo.length >= 2) {
let book = arrInfo[0];
let para = arrInfo[1];
}
*/
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 {
let sentData = JSON.parse(data);
for (const iterator of sentData) {
let id = iterator.id;
let strHtml = "";
if (_display && _display == "para") {
//段落模式
let strPalitext =
"" +
iterator.palitext +
"";
let divPali = $("#" + id)
.parent()
.children(".palitext");
if (divPali.length == 0) {
if (_channal != "") {
let arrChannal = _channal.split(",");
for (let index = arrChannal.length - 1; index >= 0; index--) {
const iChannal = arrChannal[index];
$("#" + id)
.parent()
.prepend("");
}
}
$("#" + id)
.parent()
.prepend("");
}
$("#" + id)
.parent()
.children(".palitext")
.first()
.append(strPalitext);
let htmlTran = "";
for (const oneTran of iterator.translation) {
let html =
"";
html += marked(
term_std_str_to_tran(
oneTran.text,
oneTran.channal,
oneTran.editor,
oneTran.lang
)
);
html += "";
if (_channal == "") {
htmlTran += html;
} else {
$("#" + id)
.siblings(".tran_div[channal='" + oneTran.channal + "']")
.append(html);
}
}
$("#" + id).html(htmlTran);
} else {
//句子模式
strHtml += note_json_html(iterator);
$("#" + id).html(strHtml);
}
}
//处理标签作为气泡注释
popup_init();
//刷新句子链接递归,有加层数限制。
note_refresh_new();
_arrData = _arrData.concat(sentData);
note_ref_init();
term_get_dict();
note_channal_list();
} catch (e) {
console.error(e);
}
}
}
);
} else {
//term_get_dict();
}
}
//生成channel列表
function note_channal_list() {
console.log("note_channal_list start");
let arrSentInfo = new Array();
$("note").each(function () {
let info = $(this).attr("info");
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);
set_more_button_display();
} 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 = "";
let checked = "";
let selected = "noselect";
if (_channal.indexOf(channalinfo.id) >= 0) {
checked = "checked";
selected = "selected";
}
output += "