note.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. var _display = "";
  2. var _word = "";
  3. var _channal = "";
  4. var _lang = "";
  5. var _author = "";
  6. var _arrData = new Array();
  7. var _channalData;
  8. var MAX_NOTE_NEST = 2;
  9. /*
  10. {{203-1654-23-45@11@en@*}}
  11. <note>203-1654-23-45@11@en@*</note>
  12. <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
  13. <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*>
  14. <div class=text>
  15. pali text
  16. </div>
  17. <tran>
  18. </tran>
  19. <ref>
  20. </ref>
  21. </note>
  22. */
  23. /*
  24. 解析百科字符串
  25. {{203-1654-23-45@11@en@*}}
  26. <note id=12345 info="203-1654-23-45@11@en@*"><note>
  27. <note id="guid" book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
  28. */
  29. function note_create() {
  30. wbw_channal_list_init();
  31. note_sent_edit_dlg_init();
  32. term_edit_dlg_init();
  33. }
  34. function note_sent_edit_dlg_init() {
  35. $("body").append(
  36. '<div id="note_sent_edit_dlg" title="' + gLocal.gui.edit + '"><div id="edit_dialog_content"></div></div>'
  37. );
  38. $("#note_sent_edit_dlg").dialog({
  39. autoOpen: false,
  40. width: 550,
  41. buttons: [
  42. {
  43. text: gLocal.gui.save,
  44. click: function () {
  45. note_sent_save();
  46. $(this).dialog("close");
  47. },
  48. },
  49. {
  50. text: gLocal.gui.cancel,
  51. click: function () {
  52. $(this).dialog("close");
  53. },
  54. },
  55. ],
  56. });
  57. }
  58. function note_init(input) {
  59. let newString = input.replace(/\{\{/g, '<note info="');
  60. newString = newString.replace(/\}\}/g, '"></note>');
  61. let output = "<div>";
  62. output += marked(newString);
  63. output += "</div>";
  64. return output;
  65. }
  66. function note_update_background_style() {
  67. var mSentsBook = new Array();
  68. var mBgIndex = 1;
  69. $("note[info]").each(function () {
  70. let info = $(this).attr("info").split("-");
  71. if (info.length >= 2) {
  72. let book = info[0];
  73. $(this).attr("book", book);
  74. if (!mSentsBook[book]) {
  75. mSentsBook[book] = mBgIndex;
  76. mBgIndex++;
  77. }
  78. $(this).addClass("bg_color_" + mSentsBook[book]);
  79. }
  80. });
  81. }
  82. //
  83. function note_refresh_new() {
  84. note_update_background_style();
  85. let objNotes = document.querySelectorAll("note");
  86. let arrSentInfo = new Array();
  87. for (const iterator of objNotes) {
  88. let id = iterator.id;
  89. if (id == null || id == "") {
  90. //查看这个节点是第几层note嵌套。大于预定层数退出。
  91. let layout = 1;
  92. let parent = iterator.parentNode;
  93. while (parent.nodeType == 1) {
  94. if (parent.nodeName == "NOTE") {
  95. layout++;
  96. if (layout > MAX_NOTE_NEST) {
  97. return false;
  98. }
  99. } else if (parent.nodeName == "BODY") {
  100. break;
  101. }
  102. parent = parent.parentNode;
  103. }
  104. id = com_guid();
  105. iterator.id = id;
  106. if (iterator.hasAttribute("info")) {
  107. let info = iterator.getAttribute("info");
  108. if (info != null || info != "") {
  109. /*
  110. let arrInfo = info.split("-");
  111. if (arrInfo.length >= 2) {
  112. let book = arrInfo[0];
  113. let para = arrInfo[1];
  114. }
  115. */
  116. arrSentInfo.push({ id: id, data: info });
  117. }
  118. }
  119. }
  120. }
  121. if (arrSentInfo.length > 0) {
  122. let setting = new Object();
  123. setting.lang = "";
  124. setting.channal = _channal;
  125. $.post(
  126. "../term/note.php",
  127. {
  128. setting: JSON.stringify(setting),
  129. data: JSON.stringify(arrSentInfo),
  130. },
  131. function (data, status) {
  132. if (status == "success") {
  133. try {
  134. let sentData = JSON.parse(data);
  135. for (const iterator of sentData) {
  136. let id = iterator.id;
  137. let strHtml = "<a name='" + id + "'></a>";
  138. if (_display && _display == "para") {
  139. //段落模式
  140. let strPalitext =
  141. "<pali book='" +
  142. iterator.book +
  143. "' para='" +
  144. iterator.para +
  145. "' begin='" +
  146. iterator.begin +
  147. "' end='" +
  148. iterator.end +
  149. "' >" +
  150. iterator.palitext +
  151. "</pali>";
  152. let divPali = $("#" + id)
  153. .parent()
  154. .children(".palitext");
  155. if (divPali.length == 0) {
  156. if (_channal != "") {
  157. let arrChannal = _channal.split(",");
  158. for (let index = arrChannal.length - 1; index >= 0; index--) {
  159. const iChannal = arrChannal[index];
  160. $("#" + id)
  161. .parent()
  162. .prepend("<div class='tran_div' channal='" + iChannal + "'></div>");
  163. }
  164. }
  165. $("#" + id)
  166. .parent()
  167. .prepend("<div class='palitext'></div>");
  168. }
  169. $("#" + id)
  170. .parent()
  171. .children(".palitext")
  172. .first()
  173. .append(strPalitext);
  174. let htmlTran = "";
  175. for (const oneTran of iterator.translation) {
  176. let html =
  177. "<span class='tran' lang='" +
  178. oneTran.lang +
  179. "' channal='" +
  180. oneTran.channal +
  181. "'>";
  182. html += marked(
  183. term_std_str_to_tran(
  184. oneTran.text,
  185. oneTran.channal,
  186. oneTran.editor,
  187. oneTran.lang
  188. )
  189. );
  190. html += "</span>";
  191. if (_channal == "") {
  192. htmlTran += html;
  193. } else {
  194. $("#" + id)
  195. .siblings(".tran_div[channal='" + oneTran.channal + "']")
  196. .append(html);
  197. }
  198. }
  199. $("#" + id).html(htmlTran);
  200. } else {
  201. //句子模式
  202. strHtml += note_json_html(iterator);
  203. $("#" + id).html(strHtml);
  204. }
  205. }
  206. //刷新句子链接递归,有加层数限制。
  207. note_refresh_new();
  208. _arrData = _arrData.concat(sentData);
  209. note_ref_init();
  210. term_get_dict();
  211. note_channal_list();
  212. } catch (e) {
  213. console.error(e);
  214. }
  215. }
  216. }
  217. );
  218. } else {
  219. //term_get_dict();
  220. }
  221. }
  222. //生成channel列表
  223. function note_channal_list() {
  224. console.log("note_channal_list start");
  225. let arrSentInfo = new Array();
  226. $("note").each(function () {
  227. let info = $(this).attr("info");
  228. if (info && info != "") {
  229. arrSentInfo.push({ id: "", data: info });
  230. }
  231. });
  232. if (arrSentInfo.length > 0) {
  233. $.post(
  234. "../term/channal_list.php",
  235. {
  236. setting: "",
  237. data: JSON.stringify(arrSentInfo),
  238. },
  239. function (data, status) {
  240. if (status == "success") {
  241. try {
  242. let active = JSON.parse(data);
  243. _channalData = active;
  244. for (const iterator of _my_channal) {
  245. let found = false;
  246. for (const one of active) {
  247. if (iterator.id == one.id) {
  248. found = true;
  249. break;
  250. }
  251. }
  252. if (found == false) {
  253. _channalData.push(iterator);
  254. }
  255. }
  256. let strHtml = "";
  257. strHtml += "<div class='channel_select'>";
  258. strHtml += "<button onclick='onChannelChange()'>确定</button>";
  259. strHtml += "<button onclick='onChannelMultiSelectCancel()'>取消</button>";
  260. strHtml += "</div>";
  261. for (const iterator of _channalData) {
  262. if (_channal.indexOf(iterator.id) >= 0) {
  263. strHtml += render_channal_list(iterator);
  264. }
  265. }
  266. for (const iterator of _channalData) {
  267. if (_channal.indexOf(iterator.id) == -1) {
  268. strHtml += render_channal_list(iterator);
  269. }
  270. }
  271. $("#channal_list").html(strHtml);
  272. set_more_button_display();
  273. } catch (e) {
  274. console.error(e);
  275. }
  276. }
  277. }
  278. );
  279. }
  280. }
  281. function find_channal(id) {
  282. for (const iterator of _channalData) {
  283. if (id == iterator.id) {
  284. return iterator;
  285. }
  286. }
  287. return false;
  288. }
  289. function render_channal_list(channalinfo) {
  290. let output = "";
  291. let checked = "";
  292. let selected = "noselect";
  293. if (_channal.indexOf(channalinfo.id) >= 0) {
  294. checked = "checked";
  295. selected = "selected";
  296. }
  297. output += "<div class='list_with_head " + selected + "'>";
  298. output +=
  299. '<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
  300. output += "<div class='head'>";
  301. output += "<span class='head_img'>";
  302. output += channalinfo.nickname.slice(0, 2);
  303. output += "</span>";
  304. output += "</div>";
  305. output += "<div style='width: 100%;overflow-x: hidden;'>";
  306. output += "<div class='channal_list' >";
  307. // output += "<a href='../wiki/wiki.php?word=" + _word;
  308. // output += "&channal=" + channalinfo.id + "' >";
  309. output += "<a onclick=\"set_channal('" + channalinfo.id + "')\">";
  310. output += channalinfo["name"];
  311. output += "</a>";
  312. output += "@" + channalinfo["nickname"];
  313. output += "</div>";
  314. output += "<div class='userinfo_channal'>";
  315. output += channalinfo["username"];
  316. output += "</div>";
  317. if (channalinfo["final"]) {
  318. //进度
  319. output += "<div>";
  320. let article_len = channalinfo["article_len"];
  321. let svg_width = article_len;
  322. let svg_height = parseInt(article_len / 10);
  323. output += '<svg viewBox="0 0 ' + svg_width + " " + svg_height + '" width="100%" >';
  324. let curr_x = 0;
  325. let allFinal = 0;
  326. for (const iterator of channalinfo["final"]) {
  327. let stroke_width = parseInt(iterator.len);
  328. output += "<rect ";
  329. output += ' x="' + curr_x + '"';
  330. output += ' y="0"';
  331. output += ' height="' + svg_height + '"';
  332. output += ' width="' + stroke_width + '"';
  333. if (iterator.final == true) {
  334. allFinal += stroke_width;
  335. output += ' class="progress_bar_done" ';
  336. } else {
  337. output += ' class="progress_bar_undone" ';
  338. }
  339. output += "/>";
  340. curr_x += stroke_width;
  341. }
  342. output +=
  343. "<rect x='0' y='0' width='" + svg_width + "' height='" + svg_height / 5 + "' class='progress_bar_bg' />";
  344. output +=
  345. "<rect x='0' y='0' width='" +
  346. allFinal +
  347. "' height='" +
  348. svg_height / 5 +
  349. "' class='progress_bar_percent' style='stroke-width: 0; fill: rgb(100, 228, 100);'/>";
  350. output += '<text x="0" y="' + svg_height + '" font-size="' + svg_height * 0.8 + '">';
  351. output += channalinfo["count"] + "/" + channalinfo["all"];
  352. output += "</text>";
  353. output += "<svg>";
  354. output += "</div>";
  355. //进度结束
  356. }
  357. output += "</div>";
  358. output += "</div>";
  359. return output;
  360. }
  361. function onChannelMultiSelectStart() {
  362. $(".channel_select").show();
  363. }
  364. function onChannelMultiSelectCancel() {
  365. $(".channel_select").hide();
  366. }
  367. function onChannelChange() {
  368. let channal_list = new Array();
  369. $("[channal_id]").each(function () {
  370. if (this.checked) {
  371. channal_list.push($(this).attr("channal_id"));
  372. }
  373. });
  374. set_channal(channal_list.join());
  375. }
  376. //点击引用 需要响应的事件
  377. function note_ref_init() {
  378. $("chapter").click(function () {
  379. let bookid = $(this).attr("book");
  380. let para = $(this).attr("para");
  381. window.open("../reader/?view=chapter&book=" + bookid + "&para=" + para, "_blank");
  382. });
  383. $("para").click(function () {
  384. let bookid = $(this).attr("book");
  385. let para = $(this).attr("para");
  386. window.open("../reader/?view=para&book=" + bookid + "&para=" + para, "_blank");
  387. });
  388. }
  389. /*
  390. id
  391. palitext
  392. tran
  393. ref
  394. */
  395. function note_json_html(in_json) {
  396. let output = "";
  397. output += '<div class="note_tool_bar" style=" position: relative;">';
  398. output +=
  399. '<div class="case_dropdown note_tool_context" style="position: absolute; right: 0;width:1.5em;text-align: right;">';
  400. output += "<svg class='icon' >";
  401. output += "<use xlink:href='../studio/svg/icon.svg#ic_more'></use>";
  402. output += "</svg>";
  403. output += "<div class='case_dropdown-content sent_menu'>";
  404. if (typeof _reader_view != "undefined" && _reader_view != "sent") {
  405. output += "<a onclick='junp_to(this)'>跳转至此句</a>";
  406. }
  407. output +=
  408. "<a onclick=\"copy_ref('" +
  409. in_json.book +
  410. "','" +
  411. in_json.para +
  412. "','" +
  413. in_json.begin +
  414. "','" +
  415. in_json.end +
  416. "')\">" +
  417. gLocal.gui.copy_link +
  418. "</a>";
  419. output += "<a onclick='copy_text(this)'>" + gLocal.gui.copy + "“" + gLocal.gui.pāli + "”</a>";
  420. output +=
  421. "<a onclick=\"edit_in_studio('" +
  422. in_json.book +
  423. "','" +
  424. in_json.para +
  425. "','" +
  426. in_json.begin +
  427. "','" +
  428. in_json.end +
  429. "')\">" +
  430. gLocal.gui.edit_now +
  431. "</a>";
  432. output += "<a onclick='add_to_list()'>" + gLocal.gui.add_to_edit_list + "</a>";
  433. output += "</div>";
  434. output += "</div>";
  435. output += " </div>";
  436. output += "<div class='palitext'>" + in_json.palitext + "</div>";
  437. //output += "<div class='translation_div'>";
  438. for (const iterator of in_json.translation) {
  439. output += "<div class='tran' lang='" + iterator.lang + "'>";
  440. output +=
  441. "<div class='text' id='tran_text_" +
  442. in_json.book +
  443. "_" +
  444. in_json.para +
  445. "_" +
  446. in_json.begin +
  447. "_" +
  448. in_json.end +
  449. "_" +
  450. iterator.channal +
  451. "'>";
  452. if (iterator.text == "") {
  453. output +=
  454. "<span style='color:var(--border-line-color);'>" +
  455. iterator.channalinfo.name +
  456. "-" +
  457. iterator.channalinfo.lang +
  458. "</span>";
  459. } else {
  460. //note_init处理句子链接 marked不处理
  461. //output += marked(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  462. output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  463. }
  464. output += "</div>";
  465. //句子工具栏
  466. output += "<div class='tran_text_tool_bar'>";
  467. output += "<span class = 'tip_buttom' ";
  468. output +=
  469. " onclick=\"note_edit_sentence('" +
  470. in_json.book +
  471. "' ,'" +
  472. in_json.para +
  473. "' ,'" +
  474. in_json.begin +
  475. "' ,'" +
  476. in_json.end +
  477. "' ,'" +
  478. iterator.channal +
  479. "')\"";
  480. output += ">" + gLocal.gui.edit + "</span>";
  481. output += "<span class = 'tip_buttom' ";
  482. output += " onclick=\"history_show('" + iterator.id + "')\"";
  483. output += ">" + gLocal.gui.timeline + "</span>";
  484. output += "<span class = 'tip_buttom'>" + gLocal.gui.extension + "</span>";
  485. output += "<span class = 'tip_buttom'>" + gLocal.gui.like + "</span>";
  486. output += "<span class = 'tip_buttom'>" + gLocal.gui.comment + "</span>";
  487. output += "<span class = 'tip_buttom'>" + gLocal.gui.copy + "</span>";
  488. output += "<span class = 'tip_buttom'>" + gLocal.gui.digest + "</span>";
  489. output += "<span class = 'tip_buttom'>" + gLocal.gui.share_to + "</span>";
  490. output += "</div>";
  491. //句子工具栏结束
  492. output += "</div>";
  493. }
  494. //output += "</div>";
  495. output += "<div class='other_tran_div' sent='";
  496. output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
  497. output += "'>";
  498. output += "<div class='tool_bar'>";
  499. output += "<span class='more_tran icon_expand'></span>";
  500. output += "<span>其他译文</span>";
  501. output += "(<span class='other_tran_num'></span>)";
  502. output += "</div>";
  503. output += "<div class='other_tran'>";
  504. output += "</div>";
  505. output += "</div>";
  506. output += "<div class='bottm_tool_button ' ";
  507. output += "book='" + in_json.book + "' ";
  508. output += "para='" + in_json.para + "' ";
  509. output += "begin='" + in_json.begin + "' ";
  510. output += "end='" + in_json.end + "' ";
  511. output += " style='left:0;'>";
  512. output += "<div class='add_new icon_add'></div>";
  513. //output += "<div class='more_tran icon_expand'></div>";
  514. output += "</div>";
  515. output += "<div class='ref'>" + in_json.ref;
  516. output +=
  517. "<span class='sent_no'>" +
  518. in_json.book +
  519. "-" +
  520. in_json.para +
  521. "-" +
  522. in_json.begin +
  523. "-" +
  524. in_json.end +
  525. "<span>" +
  526. "</div>";
  527. return output;
  528. }
  529. function set_more_button_display() {
  530. $(".other_tran_div").each(function () {
  531. const sentid = $(this).attr("sent").split("-");
  532. const book = sentid[0];
  533. const para = sentid[1];
  534. const begin = sentid[2];
  535. const end = sentid[3];
  536. let count = 0;
  537. for (const iterator of _channalData) {
  538. if (iterator.final) {
  539. for (const onesent of iterator.final) {
  540. let id = onesent.id.split("-");
  541. if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
  542. if (_channal.indexOf(iterator.id) == -1) {
  543. count++;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. if (count > 0) {
  550. $(this).find(".other_tran_num").html(count);
  551. $(this)
  552. .find(".tool_bar")
  553. .click(function () {
  554. const sentid = $(this).parent().attr("sent").split("-");
  555. const book = sentid[0];
  556. const para = sentid[1];
  557. const begin = sentid[2];
  558. const end = sentid[3];
  559. let sentId = book + "-" + para + "-" + begin + "-" + end;
  560. if ($(this).siblings(".other_tran").first().css("display") == "none") {
  561. $(".other_tran_div[sent='" + sentId + "']")
  562. .children(".other_tran")
  563. .slideDown();
  564. $(this).children(".more_tran ").css("transform", "unset");
  565. $.get(
  566. "../usent/get.php",
  567. {
  568. book: book,
  569. para: para,
  570. begin: begin,
  571. end: end,
  572. },
  573. function (data, status) {
  574. let arrSent = JSON.parse(data);
  575. let html = "";
  576. for (const iterator of arrSent) {
  577. if (_channal.indexOf(iterator.channal) == -1) {
  578. html += "<div>" + marked(iterator.text) + "</div>";
  579. }
  580. }
  581. let sentId =
  582. arrSent[0].book +
  583. "-" +
  584. arrSent[0].paragraph +
  585. "-" +
  586. arrSent[0].begin +
  587. "-" +
  588. arrSent[0].end;
  589. $(".other_tran_div[sent='" + sentId + "']")
  590. .children(".other_tran")
  591. .html(html);
  592. }
  593. );
  594. } else {
  595. $(".other_tran_div[sent='" + sentId + "']")
  596. .children(".other_tran")
  597. .slideUp();
  598. $(this).children(".more_tran ").css("transform", "rotate(-90deg)");
  599. }
  600. });
  601. } else {
  602. //隐藏自己
  603. //$(this).hide();
  604. }
  605. });
  606. }
  607. function note_edit_sentence(book, para, begin, end, channal) {
  608. let channalInfo;
  609. for (const iterator of _channalData) {
  610. if (iterator.id == channal) {
  611. channalInfo = iterator;
  612. break;
  613. }
  614. }
  615. for (const iterator of _arrData) {
  616. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  617. for (const tran of iterator.translation) {
  618. if (tran.channal == channal) {
  619. let html = "";
  620. html += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
  621. html +=
  622. "<textarea id='edit_dialog_text' sent_id='" +
  623. tran.id +
  624. "' book='" +
  625. iterator.book +
  626. "' para='" +
  627. iterator.para +
  628. "' begin='" +
  629. iterator.begin +
  630. "' end='" +
  631. iterator.end +
  632. "' channal='" +
  633. tran.channal +
  634. "' style='width:100%;min-height:260px;'>" +
  635. tran.text +
  636. "</textarea>";
  637. $("#edit_dialog_content").html(html);
  638. $("#note_sent_edit_dlg").dialog("open");
  639. return;
  640. }
  641. }
  642. }
  643. }
  644. alert("未找到句子");
  645. }
  646. function note_sent_save() {
  647. let id = $("#edit_dialog_text").attr("sent_id");
  648. let book = $("#edit_dialog_text").attr("book");
  649. let para = $("#edit_dialog_text").attr("para");
  650. let begin = $("#edit_dialog_text").attr("begin");
  651. let end = $("#edit_dialog_text").attr("end");
  652. let channal = $("#edit_dialog_text").attr("channal");
  653. let text = $("#edit_dialog_text").val();
  654. $.post(
  655. "../usent/sent_post.php",
  656. {
  657. id: id,
  658. book: book,
  659. para: para,
  660. begin: begin,
  661. end: end,
  662. channal: channal,
  663. text: text,
  664. lang: "zh",
  665. },
  666. function (data) {
  667. let result = JSON.parse(data);
  668. if (result.status > 0) {
  669. alert("error" + result.message);
  670. } else {
  671. ntf_show("success");
  672. if (result.text == "") {
  673. let channel_info = "Empty";
  674. let thisChannel = find_channal(result.channal);
  675. if (thisChannel) {
  676. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  677. }
  678. $(
  679. "#tran_text_" +
  680. result.book +
  681. "_" +
  682. result.para +
  683. "_" +
  684. result.begin +
  685. "_" +
  686. result.end +
  687. "_" +
  688. result.channal
  689. ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  690. } else {
  691. $(
  692. "#tran_text_" +
  693. result.book +
  694. "_" +
  695. result.para +
  696. "_" +
  697. result.begin +
  698. "_" +
  699. result.end +
  700. "_" +
  701. result.channal
  702. ).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
  703. term_updata_translation();
  704. for (const iterator of _arrData) {
  705. if (
  706. iterator.book == result.book &&
  707. iterator.para == result.para &&
  708. iterator.begin == result.begin &&
  709. iterator.end == result.end
  710. ) {
  711. for (const tran of iterator.translation) {
  712. if (tran.channal == result.channal) {
  713. tran.text = result.text;
  714. break;
  715. }
  716. }
  717. }
  718. }
  719. }
  720. }
  721. }
  722. );
  723. }
  724. function copy_ref(book, para, begin, end) {
  725. let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
  726. copy_to_clipboard(strRef);
  727. }
  728. function edit_in_studio(book, para, begin, end) {
  729. wbw_channal_list_open(book, [para]);
  730. }