var _display = "para"; var _mode = "read"; var _direction = "row"; var _word = ""; var _channal = ""; var _lang = ""; var _author = ""; var _arrData = new Array(); var _channalData; var MAX_NOTE_NEST = 2; var gBuildinDictIsOpen = false; var note_renderer = new marked.Renderer(); note_renderer.code = function(code, language) { if (language == "mermaid") return '
' + code + "
"; else return "
" + code + "
"; }; /* {{203-1654-23-45@11@en@*}} 203-1654-23-45@11@en@*
pali text
*/ /* 解析百科字符串 {{203-1654-23-45@11@en@*}} */ function note_create() { $.post("../ucenter/get_setting.php", {}, function (data, status) { setting = JSON.parse(data); }); wbw_channal_list_init(); note_sent_edit_dlg_init(); term_edit_dlg_init(); pali_sim_dlg_init(); related_para_dlg_init(); term_get_all_pali(); } function note_sent_edit_dlg_init() { $("body").append( '
' ); guide_init(); $("#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,channel="",editor="",lang="en") { if (input) { let output = "
"; //output += marked(input); output += marked(term_std_str_to_tran(input, channel, editor, lang), { renderer: note_renderer }); output += "
"; let newString = output.replace(/\{\{/g, ''); return newString; } else { return ""; } } 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(callback = null) { let Params={ maxSentenceOneRequest:0 }; note_update_background_style(); let objNotes = document.querySelectorAll("note"); let arrSentInfo = new Array(); let noteCounter = 0; 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 }); } } noteCounter++; if(Params.maxSentenceOneRequest>0 && noteCounter>=Params.maxSentenceOneRequest){ break; } } } 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 (_mode && _mode == "read") { //阅读模式 strHtml += render_read_mode_sent(iterator); $("#" + id).html(strHtml); } else { //编辑模式 strHtml += note_json_html(iterator); $("#" + id).html(strHtml); } } //句子渲染完毕 //处理标签作为气泡注释 popup_init(); //刷新句子链接递归,有加层数限制。 //note_refresh_new(); //将新的数据添加到数据总表 _arrData = _arrData.concat(sentData); note_ref_init(); //获取术语字典 term_get_dict(callback); //刷新channel列表 note_channal_list(); //显示不同的巴利语脚本 refresh_pali_script(); //把巴利语单词用分隔用于点词查询等 splite_pali_word(); //处理编辑框消息 tran_sent_textarea_event_init(); //处理鼠标移入显示菜单消息 setSentToolBarEvent(); //初始化mermaid mermaid.initialize({startOnLoad:true}); //初始化气泡 guide_init(); } catch (e) { console.error(e); } } } ); } else { term_get_dict(callback); } return arrSentInfo.length; } //渲染巴利原文句子 function render_pali_sent(palitext){ let output = ""; output = ""; if(palitext.book<1000){ output += palitext.palitext; } else{ output += marked(palitext.palitext); } output +=""; return output; } //渲染阅读模式句子 function render_read_mode_sent(iterator) { let id = iterator.id; let strPalitext =render_pali_sent(iterator); if ( $("#" + id) .parent() .parent() .children(".para_div").length == 0 ) { let tranDivHtml = ""; if (_channal != "") { let arrChannal = _channal.split(","); for (let index = arrChannal.length - 1; index >= 0; index--) { const iChannal = arrChannal[index]; tranDivHtml += "
"; } } else { tranDivHtml = "
"; } $("#" + id) .parent() .parent() .prepend( "
"+ "
"+ "
"+ "
"+ "
"+ "
" + tranDivHtml + "
" ); } $("#" + id) .parent() .parent() .children(".para_div") .find(".palitext") .first() .append(strPalitext); let htmlSent = ""; htmlSent += "
"; htmlSent += "
"; htmlSent += "
" + strPalitext + "
"; htmlSent += ""; htmlSent += iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end; htmlSent += ""; htmlSent += "
"; htmlSent += "
"; htmlSent += "
"; for (const oneTran of iterator.translation) { let html = ""; //将绝对链接转换为 用户连接的主机链接 //oneTran.text = oneTran.text.replace(/www-[A-z]*.wikipali.org/g,location.host); html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang)); html += ""; htmlSent += html; let channelId = "0"; if (_channal != "") { channelId = oneTran.channal; } $("#" + id) .parent() .parent() .find(".tran_div_channel[channal='" + channelId + "']") .append(html); } htmlSent += "
"; htmlSent += "
"; //note_body htmlSent += "
"; htmlSent += "" + iterator.ref + ""; htmlSent += "" + iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end + ""; htmlSent += "
"; //note_foot return htmlSent; } //生成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.uid == one.uid) { 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(); let lang=new Object(); let currLang=_lang; let firstChannel=""; if(_channal!=""){ firstChannel = _channal.split(",")[0]; } for (const iterator of _channalData) { lang[iterator.lang]=1; if(iterator.id==firstChannel){ currLang = iterator.lang; } } let htmlLangSelect=""; let isLangMatched=false; for (const key in lang) { if (lang.hasOwnProperty.call(lang, key)) { let strLang = key; if(gLocal.language.hasOwnProperty.call(gLocal.language, key)){ strLang = gLocal.language[key]; } htmlLangSelect += "