| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592 |
- var _display = "";
- var _word = "";
- var _channal = "";
- var _lang = "";
- var _author = "";
- var _arrData = new Array();
- var _channalData;
- var MAX_NOTE_NEST = 2;
- var gBuildinDictIsOpen = false;
- /*
- {{203-1654-23-45@11@en@*}}
- <note>203-1654-23-45@11@en@*</note>
- <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
- <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*>
- <div class=text>
- pali text
- </div>
- <tran>
- </tran>
- <ref>
- </ref>
- </note>
- */
- /*
- 解析百科字符串
- {{203-1654-23-45@11@en@*}}
- <note id=12345 info="203-1654-23-45@11@en@*"><note>
- <note id="guid" book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
- */
- function note_create() {
- wbw_channal_list_init();
- note_sent_edit_dlg_init();
- term_edit_dlg_init();
- pali_sim_dlg_init();
- related_para_dlg_init();
- }
- function note_sent_edit_dlg_init() {
- $("body").append(
- '<div id="note_sent_edit_dlg" title="' +
- gLocal.gui.edit +
- '"><guide gid="markdown_guide"></guide><div id="edit_dialog_content"></div></div>'
- );
- 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) {
- if (input) {
- let newString = input.replace(/\{\{/g, '<div class="note_shell"><note info="');
- newString = newString.replace(/\}\}/g, '" ></note></div>');
- let output = "<div>";
- output += marked(newString);
- output += "</div>";
- return output;
- } 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() {
- 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 = "<a name='" + id + "'></a>";
- if (_display && _display == "para") {
- //段落模式
- let strPalitext =
- "<pali book='" +
- iterator.book +
- "' para='" +
- iterator.para +
- "' begin='" +
- iterator.begin +
- "' end='" +
- iterator.end +
- "' >" +
- iterator.palitext +
- "</pali>";
- 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("<div class='tran_div' channal='" + iChannal + "'></div>");
- }
- }
- $("#" + id)
- .parent()
- .prepend("<div class='palitext'></div>");
- }
- $("#" + id)
- .parent()
- .children(".palitext")
- .first()
- .append(strPalitext);
- let htmlTran = "";
- for (const oneTran of iterator.translation) {
- let html =
- "<span class='tran' lang='" +
- oneTran.lang +
- "' channal='" +
- oneTran.channal +
- "'>";
- html += marked(
- term_std_str_to_tran(
- oneTran.text,
- oneTran.channal,
- oneTran.editor,
- oneTran.lang
- )
- );
- html += "</span>";
- 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);
- }
- }
- //处理<code>标签作为气泡注释
- popup_init();
- //刷新句子链接递归,有加层数限制。
- //note_refresh_new();
- //将新的数据添加到数据总表
- _arrData = _arrData.concat(sentData);
- note_ref_init();
- //获取术语字典
- term_get_dict();
- //刷新channel列表
- note_channal_list();
- //显示不同的巴利语脚本
- refresh_pali_script();
- //把巴利语单词用<w>分隔用于点词查询等
- splite_pali_word();
- } 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 += "<div class='list_with_head " + selected + "'>";
- output +=
- '<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
- output += "<div class='head'>";
- output += "<span class='head_img'>";
- if (parseInt(channalinfo.power) == 30) {
- output += gLocal.gui.your.slice(0, 1);
- } else {
- output += channalinfo.nickname.slice(0, 1);
- }
- output += "</span>";
- output += "</div>";
- output += "<div style='width: 100%;overflow-x: hidden;'>";
- output += "<div class='channal_list' >";
- // output += "<a href='../wiki/wiki.php?word=" + _word;
- // output += "&channal=" + channalinfo.id + "' >";
- switch (parseInt(channalinfo.status)) {
- case 10:
- output += "🔐";
- break;
- case 20:
- output += "🌐";
- break;
- case 30:
- output += "🌐";
- break;
- default:
- break;
- }
- if (parseInt(channalinfo.power) >= 20) {
- //if (parseInt(channalinfo.power) != 30)
- {
- output += "✏️";
- }
- }
- //✋
- output += "<a onclick=\"set_channal('" + channalinfo.id + "')\">";
- output += channalinfo["name"];
- output += "</a>";
- if (parseInt(channalinfo.power) == 30) {
- output += "@" + gLocal.gui.your;
- } else {
- output += "@" + channalinfo["nickname"];
- }
- output += "</div>";
- output += "<div class='userinfo_channal'>";
- output += channalinfo["username"];
- output += "</div>";
- if (channalinfo["final"]) {
- //进度
- output += "<div>";
- let article_len = channalinfo["article_len"];
- let svg_width = article_len;
- let svg_height = parseInt(article_len / 10);
- output += '<svg viewBox="0 0 ' + svg_width + " " + svg_height + '" width="100%" >';
- let curr_x = 0;
- let allFinal = 0;
- for (const iterator of channalinfo["final"]) {
- let stroke_width = parseInt(iterator.len);
- output += "<rect ";
- output += ' x="' + curr_x + '"';
- output += ' y="0"';
- output += ' height="' + svg_height + '"';
- output += ' width="' + stroke_width + '"';
- if (iterator.final == true) {
- allFinal += stroke_width;
- output += ' class="progress_bar_done" ';
- } else {
- output += ' class="progress_bar_undone" ';
- }
- output += "/>";
- curr_x += stroke_width;
- }
- output +=
- "<rect x='0' y='0' width='" + svg_width + "' height='" + svg_height / 5 + "' class='progress_bar_bg' />";
- output +=
- "<rect x='0' y='0' width='" +
- allFinal +
- "' height='" +
- svg_height / 5 +
- "' class='progress_bar_percent' style='stroke-width: 0; fill: rgb(100, 228, 100);'/>";
- output += '<text x="0" y="' + svg_height + '" font-size="' + svg_height * 0.8 + '">';
- output += channalinfo["count"] + "/" + channalinfo["all"] + "@" + curr_x;
- output += "</text>";
- output += "<svg>";
- output += "</div>";
- //进度结束
- }
- output += "</div>";
- output += "</div>";
- return output;
- }
- function onChannelMultiSelectStart() {
- $(".channel_select").show();
- }
- function onChannelMultiSelectCancel() {
- $(".channel_select").hide();
- }
- function onChannelChange() {
- let channal_list = new Array();
- $("[channal_id]").each(function () {
- if (this.checked) {
- channal_list.push($(this).attr("channal_id"));
- }
- });
- set_channal(channal_list.join());
- }
- //点击引用 需要响应的事件
- function note_ref_init() {
- $("chapter").click(function () {
- let bookid = $(this).attr("book");
- let para = $(this).attr("para");
- window.open("../reader/?view=chapter&book=" + bookid + "¶=" + para, "_blank");
- });
- $("para").click(function () {
- let bookid = $(this).attr("book");
- let para = $(this).attr("para");
- window.open("../reader/?view=para&book=" + bookid + "¶=" + para, "_blank");
- });
- }
- /*
- id
- palitext
- tran
- ref
- */
- function note_json_html(in_json) {
- let output = "";
- output += '<div class="note_tool_bar" style=" position: relative;">';
- output += '<div class="case_dropdown note_tool_context" >';
- output += "<svg class='icon' >";
- output += "<use xlink:href='../studio/svg/icon.svg#ic_more'></use>";
- output += "</svg>";
- output += "<div class='case_dropdown-content sent_menu'>";
- if (typeof _reader_view != "undefined" && _reader_view != "sent") {
- output += "<a onclick='junp_to(this)'>" + gLocal.gui.jump_to_this_sent + "</a>";
- }
- output +=
- "<a onclick='related_para_dlg_open(" +
- in_json.book +
- "," +
- in_json.para +
- ")'>" +
- gLocal.gui.related_para +
- "</a>";
- output +=
- "<a onclick='goto_nissaya(" +
- in_json.book +
- "," +
- in_json.para +
- "," +
- in_json.begin +
- "," +
- in_json.end +
- ")'>" +
- gLocal.gui.show_nissaya +
- "</a>";
- output +=
- "<a onclick=\"copy_ref('" +
- in_json.book +
- "','" +
- in_json.para +
- "','" +
- in_json.begin +
- "','" +
- in_json.end +
- "')\">" +
- gLocal.gui.copy_link +
- "</a>";
- output += "<a onclick='copy_text(this)'>" + gLocal.gui.copy + "“" + gLocal.gui.pāli + "”</a>";
- output +=
- "<a onclick=\"edit_in_studio('" +
- in_json.book +
- "','" +
- in_json.para +
- "','" +
- in_json.begin +
- "','" +
- in_json.end +
- "')\">" +
- gLocal.gui.edit_now +
- "</a>";
- output += "<a onclick='add_to_list()'>" + gLocal.gui.add_to_edit_list + "</a>";
- output += "<a onclick='slider_show(this)'>Slider Show</a>";
- output += "</div>";
- output += "</div>";
- output += " </div>";
- output += "<div class='palitext palitext_roma'>" + in_json.palitext + "</div>";
- output += "<div class='palitext palitext1'></div>";
- output += "<div class='palitext palitext2'></div>";
- //output += "<div id='translation_div'>";
- for (const iterator of in_json.translation) {
- output += render_one_sent_tran_a(iterator);
- //output += render_one_sent_tran(in_json.book, in_json.para, in_json.begin, in_json.end, iterator);
- }
- //所选全部译文结束
- //output += "</div>";
- //未选择的其他译文开始
- output += "<div class='other_tran_div' sent='";
- output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
- output += "<div class='tool_bar' sent='";
- output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
- output += "<span class='tool_left'>";
- //第一个按钮
- //新增译文按钮开始
- output += "<span class='' ";
- output += "book='" + in_json.book + "' ";
- output += "para='" + in_json.para + "' ";
- output += "begin='" + in_json.begin + "' ";
- output += "end='" + in_json.end + "' ";
- output += " >";
- output += "<span class='' onclick='add_new_tran_button_click(this)' title='"+gLocal.gui.add_tran+"'>➕</span>";
- output += "<div class='tran_text_tool_bar'>";
- output += "</div>";
- output += "</span>";
- //新增译文按钮结束
- output += "<span class='separate_line'></span>";
- //第二个按钮
- output += "<span class='more_tran icon_expand'></span>";
- //其他译文工具条
- output += "<span class='other_bar' >";
- output += "<span class='other_tran_span' title='" + gLocal.gui.other + gLocal.gui.translation + "'>🧲"+gLocal.gui.translation+"</span>";
- output += "<span class='other_tran_num'></span>";
- output += "</span>";
- output += "<span class='separate_line'></span>";
- //手工义注
- output += "<span class='other_bar' >";
- output += "<span class='other_tran_span commentray' title='📔" + gLocal.gui.vannana + "'>🪔"+gLocal.gui.commentary+"</span>";
- output += "<span class='other_tran_num'></span>";
- output += "</span>";
- output += "<span class='separate_line'></span>";
- //第三个按钮 相似句
- if (parseInt(in_json.sim) > 0) {
- output += "<span class='other_bar' >";
- output +=
- "<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
- in_json.pali_sent_id +
- "')\" title='" +
- gLocal.gui.similar_sentences +
- "'>🧬"+gLocal.gui.similar+"</span>";
- output += "<span class='similar_sent_num'>" + in_json.sim + "</span>";
- output += "</span>";
- output += "<span class='separate_line'></span>";
- }
- //第三个按钮 相似句结束
- output += "</span>";
- output += "<span class='tool_right'>";
- //出处路径开始
- output += "<span class='ref'>" + in_json.ref;
- output += "<span class='sent_no'>";
- output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
- output += "<span>";
- output += "</span>";
- //出处路径结束
- output += "</span>";
- output += "</div>";
- //工具栏结束
- //未选择的其他译文开始
- output += "<div class='other_tran'>";
- output += "</div>";
- output += "</div>";
- return output;
- }
- function sent_tran_edit(obj) {
- let jqObj = $(obj);
- while (!jqObj.hasClass("sent_tran")) {
- jqObj = jqObj.parent();
- if (!jqObj) {
- return;
- }
- }
- if (jqObj.hasClass("edit_mode")) {
- jqObj.removeClass("edit_mode");
- } else {
- $(".sent_tran").removeClass("edit_mode");
- jqObj.addClass("edit_mode");
- }
- }
- function sent_pr_merge(id) {
- $.post(
- "../usent/sent_pr_merge.php",
- {
- id: id,
- },
- function (data) {
- let result = JSON.parse(data);
- if (result.status > 0) {
- alert("error" + result.message);
- } else {
- ntf_show("成功采纳");
- }
- }
- );
- }
- function sent_commit(src, id) {
- commit_init({
- src: src,
- sent: [id],
- express: true,
- });
- }
- function render_one_sent_tran_a(iterator) {
- let mChannel = get_channel_by_id(iterator.channal);
- let tranText;
- let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
- if (iterator.text == "") {
- tranText =
- "<span style='color:var(--border-line-color);'>" +
- iterator.channalinfo.name +
- "-" +
- iterator.channalinfo.lang +
- "</span>";
- } else {
- //note_init处理句子链接
- tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
- }
- let html = "";
- html += "<div class='sent_tran ";
- if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
- html += " pr ";
- }
- html += "' dbid='" + iterator.id + "' channel='" + iterator.channal + "' sid='" + sid + "'>";
- html += "<div class='sent_tran_inner'>";
- html += '<div class="tool_bar">';
- html += ' <div class="right">';
- //句子菜单
- html += '<div class="pop_menu">';
- if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
- //在pr 列表中的译文
- if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
- //提交人
- //修改按钮
- html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += gLocal.gui.modify;
- html += "</span>";
- html += "</button>";
- //删除按钮
- html += "<button class='icon_btn tooltip' onclick='sent_pr_del(this)'>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_delete"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += gLocal.gui.delete;
- html += "</span>";
- html += "</button>";
- } else {
- //非提交人
- if (parseInt(iterator.mypower) >= 20) {
- //有权限 采纳按钮
- html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#accept_copy"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += gLocal.gui.accept_copy;
- html += "</span>";
- html += "</button>";
- }
- //点赞按钮
- html += "<button class='icon_btn tooltip' onclick='sent_pr_like(this)'>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += gLocal.gui.like;
- html += "</span>";
- html += "</button>";
- }
- } else {
- //非pr列表里的句子
- //编辑按钮
- html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
- html += '<svg class="icon" >';
- if (parseInt(iterator.mypower) < 20) {
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#my_idea"></use>';
- } else {
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
- }
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- if (parseInt(iterator.mypower) < 20) {
- html += gLocal.gui.suggest;
- } else {
- html += gLocal.gui.edit;
- }
- html += "</span>";
- html += "</button>";
- //推送按钮
- let commitIcon = "";
- let commitTipText = "";
- if (parseInt(iterator.mypower) >= 30 && parseInt(iterator.status) < 30) {
- //我的私有资源 公开发布
- commitIcon = "publish";
- commitTipText = gLocal.gui.publish;
- } else {
- if (parseInt(iterator.mypower) < 20) {
- //只读资源 采纳
- commitIcon = "accept_copy";
- commitTipText = gLocal.gui.accept_copy;
- } else {
- //其他资源 复制到
- commitIcon = "copy";
- commitTipText = gLocal.gui.copy_to;
- }
- }
- html += "<button class='icon_btn tooltip' ";
- html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + commitIcon + '"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += commitTipText;
- html += "</span>";
- html += "</button>";
- //推送按钮结束
- //更多按钮
- html += '<div class="case_dropdown">';
- html += "<button class='icon_btn'>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_more"></use>';
- html += "</svg>";
- html += "</button>";
- html += '<div class="case_dropdown-content menu_space_between" style="right:0;">';
- //时间线
- html += "<a onclick=\"history_show('" + iterator.id + "')\">";
- html += "<span>" + gLocal.gui.timeline + "</span>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use>';
- html += "</svg>";
- html += "</a>";
- //复制
- html += "<a onclick=\"history_show('" + iterator.id + "')\">";
- html += "<span>" + gLocal.gui.copy + "</span>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use>';
- html += "</svg>";
- html += "</a>";
- //点赞
- html += "<a onclick=\"history_show('" + iterator.id + "')\">";
- html += "<span>" + gLocal.gui.like + "</span>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
- html += "</svg>";
- html += "</a>";
- //分享
- html += "<a onclick=\"history_show('" + iterator.id + "')\">";
- html += "<span>" + gLocal.gui.share_to + "</span>";
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use>';
- html += "</svg>";
- html += "</a>";
- html += "</div>";
- html += "</div>";
- //更多按钮结束
- }
- html += "</div>";
- //句子菜单结束
- html += "</div>";
- html += "</div>";
- //tool_bar 结束
- html += '<div class="left_bar" >';
- html += ' <div class="face">';
- if (iterator.id != "") {
- html += '<span class="head_img">' + iterator.editor_name.nickname.slice(0, 1) + "</span>";
- }
- html += "</div>";
- html +=
- '<div class="date" title="' +
- getFullDataTime(iterator.update_time) +
- '">' +
- getDataTime(iterator.update_time) +
- "</div>";
- html += "</div>";
- html += '<div class="body">';
- html += '<div class="head_bar">';
- html += '<div class="info">';
- html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
- html += '<span class="date">' + getPassDataTime(iterator.update_time) + "</span>";
- html += "</div>";
- html += "<div class='preview'>" + tranText + "</div>";
- html += "</div>";
- html += '<div class="edit">';
- html += '<div class="input">';
- html += "<textarea dbid='" + iterator.id + "' ";
- html += "sid='" + sid + "' ";
- html += "channel='" + iterator.channal + "' ";
- if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
- html += 'onchange="note_pr_save(this)"';
- } else {
- html += 'onchange="note_sent_save_a(this)"';
- }
- html += ">" + iterator.text + "</textarea>";
- html += "</div>";
- html += '<div class="edit_tool">';
- if (parseInt(iterator.mypower) < 20) {
- html += "<b>提交修改建议</b> ";
- }
- html += "点击输入框外面自动<a onclick='sent_tran_edit(this)'>" + gLocal.gui.save + "</a> 支持markdown语法";
- html += "</div>";
- html += "</div>";
- html += '<div class="foot_bar">';
- html += '<div class="info">';
- if (iterator.id != "") {
- html += '<span class="date"> ' + getPassDataTime(iterator.update_time) + "</span>";
- }
- if (iterator.id != "") {
- html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
- }
- if (iterator.id != "") {
- html += '<span class="channel">' + gLocal.gui.updated + " @" + iterator.channalinfo.name + "</span>";
- } else {
- html += '<span class="channel">' + gLocal.gui.no_updated + " @" + iterator.channalinfo.name + "</span>";
- }
- html += '<ul class="tag_list">';
- if (iterator.pr_all && parseInt(iterator.pr_all) > 0) {
- html +=
- " <li onclick=\"note_pr_show('" +
- iterator.channal +
- "','" +
- sid +
- "')\"><span class='icon'>✋</span><span class='num'>" +
- iterator.pr_new +
- "/" +
- iterator.pr_all +
- "</span></li>";
- }
- html += "</ul>";
- html += "</div>"; //end of info
- html += "</div>"; //end of foot bar
- html += "</div>";
- html += "</div>";
- //sent_tran_inner结束
- html += '<div class="pr_content"></div>';
- html += "</div>";
- return html;
- }
- function render_one_sent_tran(book, para, begin, end, iterator) {
- let output = "";
- output += "<div class='tran' lang='" + iterator.lang + "' style='display:flex;'>";
- //译文工具按钮开始
- output += "<div class='tran_text_tool_botton' onclick='tool_bar_show(this)'>";
- output +=
- "<div class='icon_expand' style='width: 0.8em;height: 0.8em;min-width: 0.8em;min-height: 0.8em;transition: transform 0.5s ease;'></div>";
- //译文工具栏开始
- output += "<div class='tran_text_tool_bar'>";
- output += "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom' ";
- output +=
- " onclick=\"note_edit_sentence('" +
- book +
- "' ,'" +
- para +
- "' ,'" +
- begin +
- "' ,'" +
- end +
- "' ,'" +
- iterator.channal +
- "')\"";
- output +=
- ">" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use></svg>';
- output += gLocal.gui.edit + "</li>";
- output += "<li class = 'tip_buttom' ";
- output += " onclick=\"history_show('" + iterator.id + "')\" >";
- output +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use></svg>';
- output += gLocal.gui.timeline + "</li>";
- output +=
- "<li class = 'tip_buttom'>" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use></svg>';
- output += gLocal.gui.copy + "</li></div>";
- output +=
- "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom'>" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use></svg>';
- output += gLocal.gui.like + "</li>";
- output +=
- "<li class = 'tip_buttom'>" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#comment"></use></svg>';
- output += gLocal.gui.comment + "</li>";
- output +=
- "<li class = 'tip_buttom'>" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_shopping_cart"></use></svg>';
- output += gLocal.gui.digest + "</li></div>";
- output +=
- "<div style='margin: 0.3em 0;'><li class = 'tip_buttom'>" +
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use></svg>';
- output += gLocal.gui.share_to + "</li>";
- output += "</div></div>";
- //译文工具栏结束
- output += "</div>";
- //译文工具按钮结束
- //译文正文开始
- output +=
- "<div class='text' id='tran_text_" +
- book +
- "_" +
- para +
- "_" +
- begin +
- "_" +
- end +
- "_" +
- iterator.channal +
- "'>";
- if (iterator.text == "") {
- output +=
- "<span style='color:var(--border-line-color);'>" +
- iterator.channalinfo.name +
- "-" +
- iterator.channalinfo.lang +
- "</span>";
- } else {
- //note_init处理句子链接
- output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
- }
- output += "</div>";
- //译文正文结束
- output += "</div>";
- //单个channal译文框结束
- return output;
- }
- function add_new_tran_button_click(obj) {
- let html = "<ul>";
- for (const iterator of _my_channal) {
- if (iterator.status > 0) {
- if (_channal.indexOf(iterator.id) < 0) {
- html += '<li onclick="';
- html +=
- "new_sentence('" +
- $(obj).parent().attr("book") +
- "' ,'" +
- $(obj).parent().attr("para") +
- "' ,'" +
- $(obj).parent().attr("begin") +
- "' ,'" +
- $(obj).parent().attr("end") +
- "' ,'" +
- iterator.id +
- "',this)";
- html += '">' + iterator.name;
- if (parseInt(iterator.power) < 20) {
- html += "(建议)";
- }
- html += "</li>";
- }
- }
- }
- html += "</ul>";
- $(obj).parent().children(".tran_text_tool_bar").first().html(html);
- if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
- $(obj).parent().children(".tran_text_tool_bar").first().hide();
- } else {
- $(obj).parent().children(".tran_text_tool_bar").first().show();
- $(document).one("click", function () {
- $(obj).parent().children(".tran_text_tool_bar").first().hide();
- });
- event.stopPropagation();
- $(obj).parent().show();
- }
- }
- function tool_bar_show(element) {
- if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
- $(element).find(".tran_text_tool_bar").css("display", "flex");
- $(element).find(".icon_expand").css("transform", "rotate(-180deg)");
- $(element).css("background-color", "var(--btn-bg-color)");
- $(element).css("visibility", "visible");
- $(document).one("click", function () {
- $(element).find(".tran_text_tool_bar").hide();
- $(element).css("background-color", "var(--nocolor)");
- $(element).find(".icon_expand").css("transform", "unset");
- $(element).css("visibility", "");
- });
- event.stopPropagation();
- } else {
- $(element).find(".tran_text_tool_bar").hide();
- $(element).css("background-color", "var(--nocolor)");
- $(element).find(".icon_expand").css("transform", "unset");
- $(element).css("visibility", "");
- }
- }
- function new_sentence(book, para, begin, end, channel, obj) {
- let newsent = { id: "", text: "", lang: "", channal: channel };
- for (let iterator of _arrData) {
- if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
- let found = false;
- for (const tran of iterator.translation) {
- if (tran.channal == channel) {
- found = true;
- break;
- }
- }
- if (!found) {
- iterator.translation.push(newsent);
- }
- }
- }
- if ($(obj).parent().parent().css("display") == "block") {
- $(obj).parent().parent().hide();
- }
- note_edit_sentence(book, para, begin, end, channel);
- }
- //显示更多译文按钮动作
- function set_more_button_display() {
- $(".other_tran_div").each(function () {
- const sentid = $(this).attr("sent").split("-");
- const book = sentid[0];
- const para = sentid[1];
- const begin = sentid[2];
- const end = sentid[3];
- let count = 0;
- for (const iterator of _channalData) {
- if (iterator.final) {
- for (const onesent of iterator.final) {
- let id = onesent.id.split("-");
- if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
- if (_channal.indexOf(iterator.id) == -1) {
- count++;
- }
- }
- }
- }
- }
- if (count > 0) {
- $(this).find(".other_tran_num").html(count);
- $(this).find(".other_tran_num").attr("style", "display:inline-flex;");
- $(this)
- .find(".other_bar")
- .click(function () {
- const sentid = $(this).parent().parent().attr("sent").split("-");
- const book = sentid[0];
- const para = sentid[1];
- const begin = sentid[2];
- const end = sentid[3];
- let sentId = $(this).parent().parent().attr("sent");
- if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
- $(".other_tran_div[sent='" + sentId + "']")
- .children(".other_tran")
- .slideDown();
- $(this).siblings(".more_tran ").css("transform", "unset");
- $.get(
- "../usent/get.php",
- {
- book: book,
- para: para,
- begin: begin,
- end: end,
- },
- function (data, status) {
- let arrSent = JSON.parse(data);
- let html = "<div class='compact'>";
- for (const iterator of arrSent) {
- if (_channal.indexOf(iterator.channal) == -1) {
- html += render_one_sent_tran_a(iterator);
- //html += "<div>" + marked(iterator.text) + "</div>";
- }
- }
- html += "</div>";
- let sentId =
- arrSent[0].book +
- "-" +
- arrSent[0].paragraph +
- "-" +
- arrSent[0].begin +
- "-" +
- arrSent[0].end;
- $(".other_tran_div[sent='" + sentId + "']")
- .children(".other_tran")
- .html(html);
- }
- );
- } else {
- $(".other_tran_div[sent='" + sentId + "']")
- .children(".other_tran")
- .slideUp();
- $(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
- }
- });
- } else {
- //隐藏自己
- //$(this).hide();
- $(this)
- .find(".other_tran_span")
- .addClass("disable");//gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation
- //$(this).find(".more_tran").hide();
- }
- });
- }
- 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 += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
- html +=
- "<textarea id='edit_dialog_text' sent_id='" +
- tran.id +
- "' book='" +
- book +
- "' para='" +
- para +
- "' begin='" +
- begin +
- "' end='" +
- end +
- "' channal='" +
- channal +
- "' style='width:100%;min-height:260px;'>" +
- tran.text +
- "</textarea>";
- $("#edit_dialog_content").html(html);
- $("#note_sent_edit_dlg").dialog("open");
- return;
- }
- }
- }
- }
- alert("未找到句子");
- }
- function update_note_sent_tran(obj) {}
- //保存pr句子 新
- function note_pr_save(obj) {
- let id = $(obj).attr("dbid");
- let sid = $(obj).attr("sid").split("-");
- let book = sid[0];
- let para = sid[1];
- let begin = sid[2];
- let end = sid[3];
- let channel = $(obj).attr("channel");
- let text = $(obj).val();
- let sent_tran_div = find_sent_tran_div(obj);
- $.post(
- "../usent/pr_post.php",
- {
- id: id,
- book: book,
- para: para,
- begin: begin,
- end: end,
- channel: channel,
- text: text,
- },
- sent_save_callback
- );
- if (sent_tran_div) {
- $(sent_tran_div).find(".preview").addClass("loading");
- }
- }
- //保存译文句子 新
- function note_sent_save_a(obj) {
- let id = $(obj).attr("dbid");
- let sid = $(obj).attr("sid").split("-");
- let book = sid[0];
- let para = sid[1];
- let begin = sid[2];
- let end = sid[3];
- let channal = $(obj).attr("channel");
- let text = $(obj).val();
- let sent_tran_div = find_sent_tran_div(obj);
- $.post(
- "../usent/sent_post.php",
- {
- id: id,
- book: book,
- para: para,
- begin: begin,
- end: end,
- channal: channal,
- text: text,
- lang: "zh",
- },
- sent_save_callback
- );
- if (sent_tran_div) {
- $(sent_tran_div).find(".preview").addClass("loading");
- }
- }
- function sent_save_callback(data) {
- let result = JSON.parse(data);
- if (result.status > 0) {
- alert("error" + result.message);
- } else {
- let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
- let sent_tran_div = $(
- ".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
- );
- if (result.commit_type == 1 || result.commit_type == 2) {
- ntf_show("成功修改");
- if (sent_tran_div) {
- let divPreview = sent_tran_div.find(".preview").first();
- if (result.text == "") {
- let channel_info = "Empty";
- let thisChannel = find_channal(result.channal);
- if (thisChannel) {
- channel_info = thisChannel.name + "-" + thisChannel.nickname;
- }
- divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
- } else {
- divPreview.html(
- marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
- );
- term_updata_translation();
- popup_init();
- 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;
- }
- }
- }
- }
- }
- sent_tran_div.find(".preview").removeClass("loading");
- }
- } else if (result.commit_type == 3) {
- ntf_show("已经提交修改建议");
- } else {
- ntf_show("未提交");
- }
- }
- }
- //保存译文句子
- 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 {
- if (result.commit_type == 1 || result.commit_type == 2) {
- ntf_show("成功修改");
- if (result.text == "") {
- let channel_info = "Empty";
- let thisChannel = find_channal(result.channal);
- if (thisChannel) {
- channel_info = thisChannel.name + "-" + thisChannel.nickname;
- }
- $(
- "#tran_text_" +
- result.book +
- "_" +
- result.para +
- "_" +
- result.begin +
- "_" +
- result.end +
- "_" +
- result.channal
- ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
- } else {
- $(
- "#tran_text_" +
- result.book +
- "_" +
- result.para +
- "_" +
- result.begin +
- "_" +
- result.end +
- "_" +
- result.channal
- ).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
- term_updata_translation();
- 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;
- }
- }
- }
- }
- }
- } else if (result.commit_type == 3) {
- ntf_show("已经提交修改建议");
- } else {
- ntf_show("未提交");
- }
- }
- }
- );
- }
- function copy_ref(book, para, begin, end) {
- let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
- copy_to_clipboard(strRef);
- }
- function goto_nissaya(book, para, begin = 0, end = 0) {
- window.open("../nissaya/index.php?book=" + book + "¶=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
- }
- function edit_in_studio(book, para, begin, end) {
- wbw_channal_list_open(book, [para]);
- }
- //显示和隐藏某个内容 如 巴利文
- function setVisibility(key, value) {
- switch (key) {
- case "palitext":
- if ($(value).is(":checked")) {
- $(".palitext").show();
- } else {
- $(".palitext").hide();
- }
- break;
- default:
- break;
- }
- }
- function note_show_pali_sim(SentId) {
- pali_sim_dlg_open(SentId, 0, 20);
- }
- function set_pali_script(pos, script) {
- if (script == "none") {
- $(".palitext" + pos).html("");
- } else {
- $(".palitext" + pos).each(function () {
- let html = $(this).siblings(".palitext_roma").first().html();
- $(this).html(html);
- });
- $(".palitext" + pos)
- .find("*")
- .contents()
- .filter(function () {
- return this.nodeType != 1;
- })
- .wrap("<pl" + pos + "></pl" + pos + ">");
- $(".palitext" + pos)
- .contents()
- .filter(function () {
- return this.nodeType != 1;
- })
- .wrap("<pl" + pos + "></pl" + pos + ">");
- $("pl" + pos).html(function (index, oldcontent) {
- return roman_to_my(oldcontent);
- });
- }
- }
- function splite_pali_word() {
- $("pali")
- .contents()
- .filter(function () {
- return this.nodeType != 1;
- })
- .wrap("<pl></pl>");
- $("pl").each(function () {
- let html = $(this).html();
- $(this).html("<w>" + html.replace(/\s/g, "</w> <w>") + "</w>");
- });
- $("w").click(function () {
- let word = com_getPaliReal($(this).text());
- if (gBuildinDictIsOpen) {
- window.open("../dict/index.php?builtin=true&key=" + word, "dict");
- }
- });
- }
- function refresh_pali_script() {
- if (_display && _display == "para") {
- //段落模式
- } else {
- //句子模式
- setting_get("lib.second_script", set_second_scrip);
- }
- }
- function set_second_scrip(value) {
- set_pali_script(2, value);
- }
- function slider_show(obj) {
- $(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
- }
- function find_sent_tran_div(obj) {
- let parent = obj.parentNode;
- while (parent.nodeType == 1) {
- if ($(parent).hasClass("sent_tran")) {
- return parent;
- } else if (parent.nodeName == "BODY") {
- return false;
- }
- parent = parent.parentNode;
- }
- return false;
- }
- //显示或隐藏pr数据
- function note_pr_show(channel, id) {
- let obj = $(".sent_tran[channel='" + channel + "'][sid='" + id + "']").find(".pr_content");
- let prHtml = obj.first().html();
- if (prHtml == "") {
- note_get_pr(channel, id);
- } else {
- obj.slideUp();
- obj.html("");
- }
- }
- //获取pr数据并显示
- function note_get_pr(channel, id) {
- let sid = id.split("-");
- let book = sid[0];
- let para = sid[1];
- let begin = sid[2];
- let end = sid[3];
- $.post(
- "../usent/get_pr.php",
- {
- book: book,
- para: para,
- begin: begin,
- end: end,
- channel: channel,
- },
- function (data) {
- let result = JSON.parse(data);
- if (result.length > 0) {
- let html = "<div class='compact'>";
- for (const iterator of result) {
- html += render_one_sent_tran_a(iterator);
- }
- html += "</div>";
- $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
- .find(".pr_content")
- .html(html);
- $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
- .find(".pr_content")
- .slideDown();
- } else {
- }
- }
- );
- $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
- .find(".pr_content")
- .html("loading");
- $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
- .find(".pr_content")
- .show();
- }
- function get_channel_by_id(id) {
- if (typeof _channalData != "undefined") {
- for (const iterator of _channalData) {
- if (iterator.id == id) {
- return iterator;
- }
- }
- }
- if (typeof _my_channal != "undefined") {
- for (const iterator of _my_channal) {
- if (iterator.id == id) {
- return iterator;
- }
- }
- }
- return false;
- }
|