| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026 |
- 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;
- /*
- {{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() {
- $.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();
- }
- 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 output = "<div>";
- output += marked(input);
- output += "</div>";
- let newString = output.replace(/\{\{/g, '<span class="note_shell"><note info="');
- newString = newString.replace(/\}\}/g, '" ></note></span>');
- 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) {
- 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 (_mode && _mode == "read") {
- //阅读模式
- strHtml += render_read_mode_sent(iterator);
- $("#" + id).html(strHtml);
- } 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();
- //处理编辑框消息
- tran_sent_textarea_event_init();
- if (callback) {
- callback();
- }
- } catch (e) {
- console.error(e);
- }
- }
- }
- );
- } else {
- //term_get_dict();
- }
- }
- //渲染阅读模式句子
- function render_read_mode_sent(iterator) {
- let id = iterator.id;
- let strPalitext =
- "<pali book='" +
- iterator.book +
- "' para='" +
- iterator.para +
- "' begin='" +
- iterator.begin +
- "' end='" +
- iterator.end +
- "' >" +
- iterator.palitext +
- "</pali>";
- 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 += "<div class='tran_div_channel' channal='" + iChannal + "'></div>";
- }
- } else {
- tranDivHtml = "<div class='tran_div_channel' channal='0'></div>";
- }
- $("#" + id)
- .parent()
- .parent()
- .prepend(
- "<div class='para_div'><div class='palitext_div'><div class='palitext palitext1'></div><div class='palitext palitext2'></div></div><div class='para_tran_div'>" +
- tranDivHtml +
- "</div></div>"
- );
- }
- $("#" + id)
- .parent()
- .parent()
- .children(".para_div")
- .find(".palitext")
- .first()
- .append(strPalitext);
- let htmlSent = "";
- htmlSent += "<div class='note_body'>";
- htmlSent += "<div class='palitext_div'>";
- htmlSent += "<div class='palitext palitext1'>" + strPalitext + "</div>";
- htmlSent += "<span class='sent_no_read_mode'>";
- htmlSent += iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
- htmlSent += "<span>";
- htmlSent += "<div class='palitext palitext2'></div>";
- htmlSent += "</div>";
- htmlSent += "<div class='sent_tran_div'>";
- for (const oneTran of iterator.translation) {
- let html = "<span class='tran_sent' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
- html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang));
- html += "</span>";
- htmlSent += html;
- let channelId = "0";
- if (_channal != "") {
- channelId = oneTran.channal;
- }
- $("#" + id)
- .parent()
- .parent()
- .find(".tran_div_channel[channal='" + channelId + "']")
- .append(html);
- }
- htmlSent += "</div>";
- htmlSent += "</div>"; //note_body
- htmlSent += "<div class='note_foot'>";
- htmlSent += "<span>" + iterator.ref + "</span>";
- htmlSent +=
- "<span class='sent_id'>" +
- iterator.book +
- "-" +
- iterator.para +
- "-" +
- iterator.begin +
- "-" +
- iterator.end +
- "</span>";
- htmlSent += "</div>"; //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.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="tool_bar">';
- output += '<div class="right">';
- output += '<div class="pop_menu">';
- output += render_icon_button("copy", "commit_init({src:'" + channalinfo.id + "'})", gLocal.gui.copy_to);
- output += render_icon_button("ic_mode_edit", "", gLocal.gui.modify);
- output += "</div>";
- output += "</div>";
- output += "</div>";
- 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 / 15);
- 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>";
- let strPalitext =
- "<pali book='" +
- in_json.book +
- "' para='" +
- in_json.para +
- "' begin='" +
- in_json.begin +
- "' end='" +
- in_json.end +
- "' >" +
- in_json.palitext +
- "</pali>";
- output += "<div class='note_body'>";
- output += "<div class='palitext_div'>";
- output += "<div class='palitext palitext_roma'>" + strPalitext + "</div>";
- output += "<div class='palitext palitext1'></div>";
- output += "<div class='palitext palitext2'></div>";
- output += "</div>";
- //译文开始
- output += "<div class='sent_tran_div'>";
- for (const iterator of in_json.translation) {
- output += render_one_sent_tran_a(iterator);
- }
- output += "</div>";
- //译文结束
- output += "</div>"; /**note_body end */
- //工具栏开始
- 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 +
- "'><svg class='icon' style='fill: var(--box-bg-color1)'><use xlink:href=\"../studio/svg/icon.svg#more_tran\"></svg>" +
- gLocal.gui.translation +
- "</span>";
- output += "<span class='other_tran_num'></span>";
- output += "</span>";
- output += "<span class='separate_line'></span>";
- //手工义注
- output += "<span class='other_bar disable'>";
- output +=
- "<span class='other_tran_span commentray' title='📔" +
- gLocal.gui.vannana +
- "'>🪔" +
- gLocal.gui.commentary +
- "</span>";
- output += "<span class='other_comm_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'>";
- output += "<span class='book_name tooltip'>" + in_json.booktitle;
- output += "<span class='tooltiptext tooltip-bottom'>";
- output += in_json.ref;
- output += "</span>";
- 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 += "</span>";
- output += "</div>";
- //工具栏结束
- //未选择的其他译文开始
- output += "<div class='other_tran'>";
- output += "</div>";
- output += "</div>";
- return output;
- }
- //设置取消输入框的编辑模式
- function sent_tran_set_edit_mode(obj, isEditMode) {
- $(".sent_tran").removeClass("edit_mode");
- if (isEditMode) {
- let jqObj = $(obj);
- while (!jqObj.hasClass("sent_tran")) {
- jqObj = jqObj.parent();
- if (!jqObj) {
- return;
- }
- }
- jqObj.addClass("edit_mode");
- }
- }
- 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");
- }
- }
- //采纳 pr
- 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: false,
- });
- }
- function render_icon_button(icon_id, event, tiptitle) {
- let html = "";
- html += "<button class='icon_btn tooltip' onclick=\"" + event + '">';
- html += '<svg class="icon" >';
- html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + icon_id + '"></use>';
- html += "</svg>";
- html += "<span class='tooltiptext tooltip-top'>";
- html += tiptitle;
- html += "</span>";
- html += "</button>";
- return html;
- }
- function render_one_sent_tran_a(iterator, diff = false) {
- let mChannel = get_channel_by_id(iterator.channal);
- let tranText;
- let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
- if (iterator.text == "") {
- if (typeof iterator.channalinfo == "undefined") {
- tranText =
- "<span style='color:var(--border-line-color);'>" +
- "空" +
- "@" +
- iterator.editor_name.nickname +
- "</span>";
- } else {
- tranText =
- "<span style='color:var(--border-line-color);'>" +
- iterator.channalinfo.name +
- "-" +
- iterator.channalinfo.lang +
- "</span>";
- }
- } else {
- if (diff) {
- let orgText = "";
- for (const oneSent of _arrData) {
- if (
- oneSent.book == iterator.book &&
- oneSent.para == iterator.para &&
- oneSent.begin == iterator.begin &&
- oneSent.end == iterator.end
- ) {
- for (const tran of oneSent.translation) {
- if (tran.channal == iterator.channal) {
- orgText = tran.text;
- break;
- }
- }
- break;
- }
- }
- tranText = str_diff(orgText, iterator.text);
- } 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 += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.modify);
- //删除按钮
- html += render_icon_button("ic_delete", "sent_pr_del(this)", gLocal.gui.delete);
- } else {
- //非提交人
- if (parseInt(iterator.mypower) >= 20) {
- //有权限 采纳按钮
- html += render_icon_button(
- "accept_copy",
- "sent_pr_merge('" + iterator.id + "')",
- gLocal.gui.accept_copy
- );
- }
- //点赞按钮
- html += render_icon_button("like", "sent_pr_like(this)", gLocal.gui.like);
- }
- } else {
- //非pr列表里的句子
- //编辑按钮
- if (parseInt(iterator.mypower) < 20) {
- html += render_icon_button("my_idea", "sent_tran_edit(this)", gLocal.gui.suggest);
- } else {
- html += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.edit);
- }
- //推送按钮
- 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 += render_icon_button(commitIcon, "sent_commit('" + iterator.channal + "','" + sid + "')", commitTipText);
- //推送按钮结束
- //更多按钮
- 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 += "<span class='icon_sent_status icon_sent_loading'>";
- html +=
- "<svg class='icon icon_spin' style='fill: var(--detail-color); '>" +
- "<use xlink='http://www.w3.org/1999/xlink' href='../studio/svg/icon.svg#loading'></use>" +
- "</svg>";
- html += "</span>";
- html += "<span class='icon_sent_status icon_sent_error' title='再次发送' onclick='tran_sent_save(this)'>";
- html +=
- "<svg class='icon' style='fill: red; '>" +
- "<use xlink='http://www.w3.org/1999/xlink' href='../term/error.svg'></use>" +
- "</svg>";
- html += "</span>";
- 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 channel_name" title="' + iterator.editor_name.nickname + gLocal.gui.recent_update + '">';
- if (typeof iterator.channalinfo == "undefined") {
- html += "unkown";
- } else {
- html += iterator.channalinfo.name;
- }
- html += "</span>";
- html += '<span class="name editor_name" title="' + iterator.channalinfo.name + gLocal.gui.recent_update + '">';
- if (typeof iterator.channalinfo == "undefined") {
- html += "unkown";
- } else {
- html += iterator.editor_name.nickname;
- }
- html += "</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 class='tran_sent_textarea' dbid='" + iterator.id + "' ";
- html += "sid='" + sid + "' ";
- html += "channel='" + iterator.channal + "' ";
- if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
- html += ' is_pr="true" onchange1="note_pr_save(this)"';
- } else {
- html += 'is_pr="false" onchange1="note_sent_save_a(this)"';
- }
- html += ">" + iterator.text + "</textarea>";
- html += "</div>";
- html += '<div class="edit_tool">';
- //html += ""
- html += '<span style="display: inline-flex;">';
- html += '<span class="keybutton" >ESC</span> = ';
- html += "<a onclick='tran_sent_edit_cancel(this)'>" + gLocal.gui.cancel + "</a>";
- html += "</span>";
- html += "<span style='display: inline-flex;'>";
- html += '<span class="keybutton" >Ctrl/⌘</span>';
- html += "➕";
- html += '<span class="keybutton" >Enter</span> = ';
- if (parseInt(iterator.mypower) < 20) {
- html += "<a onclick='tran_sent_save(this)'>";
- html += gLocal.gui.submit + "<b>" + gLocal.gui.suggest + gLocal.gui.translation + "</b>";
- html += "</a></span><span style='display: inline-flex;'>";
- } else {
- html += "<a onclick='tran_sent_save(this)'>";
- html += gLocal.gui.save;
- html += "</a></span><span style='display: inline-flex;'>";
- }
- html += '<span class="keybutton" >Enter</span> = ';
- html += gLocal.gui.next_line;
- html += "</span><span style='display: inline-flex;'>MarkDown✅</span>";
- 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 + " ";
- if (typeof iterator.channalinfo == "undefined") {
- html += "unkown";
- } else {
- html += "<a title='" + iterator.channalinfo.summary + "'>" + iterator.channalinfo.name + "@</a>";
- }
- html += "</span>";
- } else {
- html += '<span class="channel">' + gLocal.gui.no_updated + " @";
- if (typeof iterator.channalinfo == "undefined") {
- html += "unkown";
- } else {
- html += "<a title='" + iterator.channalinfo.owner + "'>" + iterator.channalinfo.name + "@</a>";
- }
- html += "</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 tran_sent_textarea_event_init() {
- let textarea = document.querySelectorAll(".tran_sent_textarea");
- for (let iterator of textarea) {
- iterator.onkeydown = function (e) {
- let menu = document.querySelector("#menu");
- switch (e.key) {
- case "Enter":
- if (menu && menu.style.display == "block") {
- let value = textarea.value;
- let selectionStart = textarea.selectionStart;
- let str1 = value.slice(0, selectionStart);
- let str2 = value.slice(selectionStart);
- textarea.value = str1 + data[menuFocusIndex] + "]]" + str2;
- menu.style.display = "none";
- return false;
- } else {
- if (e.ctrlKey) {
- //回车存盘
- tran_sent_save(e.currentTarget);
- return false;
- }
- }
- break;
- case "Escape":
- tran_sent_edit_cancel(e.currentTarget);
- break;
- default:
- break;
- }
- };
- }
- }
- 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 =
- "<a href='../channal/my_channal_index.php' target='_blank'><button>" +
- gLocal.gui.new +
- " " +
- gLocal.gui.channel +
- "</button></a>";
- html += "<div style='display:flex; max-width: 70vw; white-space: normal;'>";
- var first_lang = "";
- for (const iterator of _my_channal) {
- if (iterator.lang) {
- first_lang = iterator.lang;
- break;
- }
- }
- //母语channel列表
- html += "<ul class='channel_list lang_0' >";
- html += "<li>";
- html += gLocal.language[first_lang];
- html += "</li>";
- for (const iterator of _my_channal) {
- if (iterator.status > 0 && first_lang.indexOf(iterator.lang) != -1 && iterator.lang != 0) {
- if (_channal.indexOf(iterator.id) < 0) {
- html += '<li class="channel_name" onclick="';
- html +=
- "new_sentence('" +
- $(obj).parent().attr("book") +
- "' ,'" +
- $(obj).parent().attr("para") +
- "' ,'" +
- $(obj).parent().attr("begin") +
- "' ,'" +
- $(obj).parent().attr("end") +
- "' ,'" +
- iterator.id +
- "',this)";
- html += '" title="' + iterator.nickname;
- html += '">' + iterator.name;
- if (parseInt(iterator.power) < 20) {
- html += "(建议)";
- }
- html += "</li>";
- }
- }
- }
- //非母语channel列表
- html += "</ul>";
- html += "<ul class='channel_list lang_1'>";
- html += "<li>";
- html += gLocal.gui.other;
- html += "</li>";
- for (const iterator of _my_channal) {
- if (iterator.status > 0 && first_lang.indexOf(iterator.lang) == -1 && iterator.lang != 0) {
- if (_channal.indexOf(iterator.id) < 0) {
- html += '<li class="channel_name" onclick="';
- html +=
- "new_sentence('" +
- $(obj).parent().attr("book") +
- "' ,'" +
- $(obj).parent().attr("para") +
- "' ,'" +
- $(obj).parent().attr("begin") +
- "' ,'" +
- $(obj).parent().attr("end") +
- "' ,'" +
- iterator.id +
- "',this)";
- html += '" title="' + iterator.nickname;
- html += '">' + iterator.name;
- if (parseInt(iterator.power) < 20) {
- html += "(建议)";
- }
- html += "</li>";
- }
- }
- }
- html += "</ul>";
- //协作channel列表-带中文
- html += "<ul class='channel_list lang_2'>";
- html += "<li>";
- html += "协作";
- html += "</li>";
- for (const iterator of _my_channal) {
- if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == true) {
- if (_channal.indexOf(iterator.id) < 0) {
- html += '<li class="channel_name" onclick="';
- html +=
- "new_sentence('" +
- $(obj).parent().attr("book") +
- "' ,'" +
- $(obj).parent().attr("para") +
- "' ,'" +
- $(obj).parent().attr("begin") +
- "' ,'" +
- $(obj).parent().attr("end") +
- "' ,'" +
- iterator.id +
- "',this)";
- html += '" title="' + iterator.nickname;
- html += '">' + iterator.name;
- if (parseInt(iterator.power) < 20) {
- html += "(建议)";
- }
- html += "</li>";
- }
- }
- }
- html += "</ul>";
- //协作channel列表-不带中文
- html += "<ul class='channel_list lang_3'>";
- html += "<li>";
- html += "collaborate";
- html += "</li>";
- for (const iterator of _my_channal) {
- if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == false) {
- if (_channal.indexOf(iterator.id) < 0) {
- html += '<li class="channel_name" onclick="';
- html +=
- "new_sentence('" +
- $(obj).parent().attr("book") +
- "' ,'" +
- $(obj).parent().attr("para") +
- "' ,'" +
- $(obj).parent().attr("begin") +
- "' ,'" +
- $(obj).parent().attr("end") +
- "' ,'" +
- iterator.id +
- "',this)";
- html += '" title="' + iterator.nickname;
- html += '">' + iterator.name;
- if (parseInt(iterator.power) < 20) {
- html += "(建议)";
- }
- html += "</li>";
- }
- }
- }
- html += "</ul>";
- html += "</div>";
- $(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 checkStringIsChinese(str) {
- var pattern = new RegExp("[\u4E00-\u9FA5]+");
- if (pattern.test(str)) {
- return true;
- }
- return false;
- }
- 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>";
- let sentId =
- arrSent[0].book +
- "-" +
- arrSent[0].paragraph +
- "-" +
- arrSent[0].begin +
- "-" +
- arrSent[0].end;
- $(".other_tran_div[sent='" + sentId + "']")
- .children(".other_tran")
- .html(html);
- //初始化文本编辑框消息处理
- tran_sent_textarea_event_init();
- }
- );
- } 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 tran_sent_edit_cancel(obj) {
- sent_tran_set_edit_mode(obj, false);
- }
- function tran_sent_save(obj) {
- let sentDiv = find_sent_tran_div(obj);
- if (sentDiv) {
- let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
- let isPr = $(textarea).attr("is_pr");
- if (isPr == "true") {
- note_pr_save(textarea);
- } else {
- note_sent_save_a(textarea);
- }
- sent_tran_set_edit_mode(textarea, false);
- } else {
- console.error("sent div not found");
- }
- }
- //保存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).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);
- /*
- var jqxhr = $.post("example.php", function() {
- alert("success");
- })
- .success(function() { alert("second success"); })
- .error(function() { alert("error"); })
- .complete(function() { alert("complete"); });*/
- /*
- function (data, status) {
- alert("异常!" + data.responseText);
- switch (status) {
- case "timeout":
- break;
- case "error":
- break;
- case "notmodified":
- break;
- case "parsererror":
- break;
- default:
- break;
- }
- */
- var jqxhr = $.post(
- "../usent/sent_post.php",
- {
- id: id,
- book: book,
- para: para,
- begin: begin,
- end: end,
- channal: channal,
- text: text,
- lang: "zh",
- },
- sent_save_callback
- )
- .success(function () {
- //alert("second success");
- })
- .error(function (xhr, error, data) {
- let sid = book + "-" + para + "-" + begin + "-" + end;
- let sent_tran_div = $(".sent_tran[channel='" + channal + "'][sid='" + sid + "']");
- if (sent_tran_div) {
- sent_tran_div.removeClass("loading");
- sent_tran_div.addClass("error");
- }
- switch (error) {
- case "timeout":
- alert("服务器长时间没有回应。请稍后重试。");
- break;
- case "error":
- alert("与服务器通讯失败,您可能没有连接到网络。请稍后重试。");
- break;
- case "notmodified":
- break;
- default:
- break;
- }
- })
- .complete(function (xhr, data) {
- //请求完成后回调函数 (请求成功或失败之后均调用)。
- switch (data) {
- case "error":
- break;
- case "success":
- break;
- default:
- break;
- }
- });
- if (sent_tran_div) {
- $(sent_tran_div).addClass("loading");
- }
- }
- function update_sent_tran(sentData) {}
- 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 (sent_tran_div) {
- sent_tran_div.removeClass("loading");
- }
- 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;
- }
- }
- }
- }
- }
- }
- } 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 jqObj = $(obj);
- while (!jqObj.hasClass("sent_tran")) {
- jqObj = jqObj.parent();
- if (!jqObj) {
- return false;
- }
- }
- return jqObj;
- /*
- 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 pr'>";
- for (const iterator of result) {
- html += render_one_sent_tran_a(iterator, true);
- }
- 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;
- }
- //设置显示方向
- function setDirection(obj) {
- if (obj.value == "row") {
- $("#contents").removeClass("vertical");
- $("#contents").addClass("horizontal");
- _direction = "row";
- } else {
- $("#contents").removeClass("horizontal");
- $("#contents").addClass("vertical");
- _direction = "col";
- }
- }
- //设置逐段或逐句模式
- function setDisplay(obj) {
- if (obj.value == "para") {
- $("#contents").removeClass("sent_mode");
- $("#contents").addClass("para_mode");
- _display = "para";
- } else {
- $("#contents").removeClass("para_mode");
- $("#contents").addClass("sent_mode");
- _display = "sent";
- }
- }
|