note.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885
  1. var _display = "";
  2. var _mode = "read";
  3. var _word = "";
  4. var _channal = "";
  5. var _lang = "";
  6. var _author = "";
  7. var _arrData = new Array();
  8. var _channalData;
  9. var MAX_NOTE_NEST = 2;
  10. var gBuildinDictIsOpen = false;
  11. /*
  12. {{203-1654-23-45@11@en@*}}
  13. <note>203-1654-23-45@11@en@*</note>
  14. <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
  15. <note id=guid book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*>
  16. <div class=text>
  17. pali text
  18. </div>
  19. <tran>
  20. </tran>
  21. <ref>
  22. </ref>
  23. </note>
  24. */
  25. /*
  26. 解析百科字符串
  27. {{203-1654-23-45@11@en@*}}
  28. <note id=12345 info="203-1654-23-45@11@en@*"><note>
  29. <note id="guid" book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
  30. */
  31. function note_create() {
  32. wbw_channal_list_init();
  33. note_sent_edit_dlg_init();
  34. term_edit_dlg_init();
  35. pali_sim_dlg_init();
  36. related_para_dlg_init();
  37. }
  38. function note_sent_edit_dlg_init() {
  39. $("body").append(
  40. '<div id="note_sent_edit_dlg" title="' +
  41. gLocal.gui.edit +
  42. '"><guide gid="markdown_guide"></guide><div id="edit_dialog_content"></div></div>'
  43. );
  44. guide_init();
  45. $("#note_sent_edit_dlg").dialog({
  46. autoOpen: false,
  47. width: 550,
  48. buttons: [
  49. {
  50. text: gLocal.gui.save,
  51. click: function () {
  52. note_sent_save();
  53. $(this).dialog("close");
  54. },
  55. },
  56. {
  57. text: gLocal.gui.cancel,
  58. click: function () {
  59. $(this).dialog("close");
  60. },
  61. },
  62. ],
  63. });
  64. }
  65. function note_init(input) {
  66. if (input) {
  67. let output = "<div>";
  68. output += marked(input);
  69. output += "</div>";
  70. let newString = output.replace(/\{\{/g, '<span class="note_shell"><note info="');
  71. newString = newString.replace(/\}\}/g, '" ></note></span>');
  72. return newString;
  73. } else {
  74. return "";
  75. }
  76. }
  77. function note_update_background_style() {
  78. var mSentsBook = new Array();
  79. var mBgIndex = 1;
  80. $("note[info]").each(function () {
  81. let info = $(this).attr("info").split("-");
  82. if (info.length >= 2) {
  83. let book = info[0];
  84. $(this).attr("book", book);
  85. if (!mSentsBook[book]) {
  86. mSentsBook[book] = mBgIndex;
  87. mBgIndex++;
  88. }
  89. $(this).addClass("bg_color_" + mSentsBook[book]);
  90. }
  91. });
  92. }
  93. //
  94. function note_refresh_new() {
  95. note_update_background_style();
  96. let objNotes = document.querySelectorAll("note");
  97. let arrSentInfo = new Array();
  98. for (const iterator of objNotes) {
  99. let id = iterator.id;
  100. if (id == null || id == "") {
  101. //查看这个节点是第几层note嵌套。大于预定层数退出。
  102. let layout = 1;
  103. let parent = iterator.parentNode;
  104. while (parent.nodeType == 1) {
  105. if (parent.nodeName == "NOTE") {
  106. layout++;
  107. if (layout > MAX_NOTE_NEST) {
  108. return false;
  109. }
  110. } else if (parent.nodeName == "BODY") {
  111. break;
  112. }
  113. parent = parent.parentNode;
  114. }
  115. id = com_guid();
  116. iterator.id = id;
  117. if (iterator.hasAttribute("info")) {
  118. let info = iterator.getAttribute("info");
  119. if (info != null || info != "") {
  120. /*
  121. let arrInfo = info.split("-");
  122. if (arrInfo.length >= 2) {
  123. let book = arrInfo[0];
  124. let para = arrInfo[1];
  125. }
  126. */
  127. arrSentInfo.push({ id: id, data: info });
  128. }
  129. }
  130. }
  131. }
  132. if (arrSentInfo.length > 0) {
  133. let setting = new Object();
  134. setting.lang = "";
  135. setting.channal = _channal;
  136. $.post(
  137. "../term/note.php",
  138. {
  139. setting: JSON.stringify(setting),
  140. data: JSON.stringify(arrSentInfo),
  141. },
  142. function (data, status) {
  143. if (status == "success") {
  144. try {
  145. let sentData = JSON.parse(data);
  146. for (const iterator of sentData) {
  147. let id = iterator.id;
  148. let strHtml = "<a name='" + id + "'></a>";
  149. if (_mode && _mode == "read") {
  150. //阅读模式
  151. strHtml += render_read_mode_sent(iterator);
  152. $("#" + id).html(strHtml);
  153. } else {
  154. //编辑模式
  155. strHtml += note_json_html(iterator);
  156. $("#" + id).html(strHtml);
  157. }
  158. }
  159. //处理<code>标签作为气泡注释
  160. popup_init();
  161. //刷新句子链接递归,有加层数限制。
  162. //note_refresh_new();
  163. //将新的数据添加到数据总表
  164. _arrData = _arrData.concat(sentData);
  165. note_ref_init();
  166. //获取术语字典
  167. term_get_dict();
  168. //刷新channel列表
  169. note_channal_list();
  170. //显示不同的巴利语脚本
  171. refresh_pali_script();
  172. //把巴利语单词用<w>分隔用于点词查询等
  173. splite_pali_word();
  174. //处理编辑框消息
  175. tran_sent_textarea_event_init();
  176. } catch (e) {
  177. console.error(e);
  178. }
  179. }
  180. }
  181. );
  182. } else {
  183. //term_get_dict();
  184. }
  185. }
  186. //渲染阅读模式句子
  187. function render_read_mode_sent(iterator) {
  188. let id = iterator.id;
  189. let strPalitext =
  190. "<pali book='" +
  191. iterator.book +
  192. "' para='" +
  193. iterator.para +
  194. "' begin='" +
  195. iterator.begin +
  196. "' end='" +
  197. iterator.end +
  198. "' >" +
  199. iterator.palitext +
  200. "</pali>";
  201. if (
  202. $("#" + id)
  203. .parent()
  204. .parent()
  205. .children(".para_div").length == 0
  206. ) {
  207. let tranDivHtml = "";
  208. if (_channal != "") {
  209. let arrChannal = _channal.split(",");
  210. for (let index = arrChannal.length - 1; index >= 0; index--) {
  211. const iChannal = arrChannal[index];
  212. tranDivHtml += "<div class='tran_div_channel' channal='" + iChannal + "'></div>";
  213. }
  214. } else {
  215. tranDivHtml = "<div class='tran_div_channel' channal='0'></div>";
  216. }
  217. $("#" + id)
  218. .parent()
  219. .parent()
  220. .prepend(
  221. "<div class='para_div'><div class='palitext_div'><div class='palitext palitext1'></div><div class='palitext palitext2'></div></div><div class='para_tran_div'>" +
  222. tranDivHtml +
  223. "</div></div>"
  224. );
  225. }
  226. $("#" + id)
  227. .parent()
  228. .parent()
  229. .children(".para_div")
  230. .find(".palitext")
  231. .first()
  232. .append(strPalitext);
  233. let htmlSent = "";
  234. htmlSent += "<div class='note_body'>";
  235. htmlSent += "<div class='palitext_div'>";
  236. htmlSent += "<div class='palitext palitext1'>" + strPalitext + "</div>";
  237. htmlSent += "<div class='palitext palitext2'></div>";
  238. htmlSent += "</div>";
  239. htmlSent += "<div class='sent_tran_div'>";
  240. for (const oneTran of iterator.translation) {
  241. let html = "<span class='tran_sent' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
  242. html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang));
  243. html += "</span>";
  244. htmlSent += html;
  245. let channelId = "0";
  246. if (_channal != "") {
  247. channelId = oneTran.channal;
  248. }
  249. $("#" + id)
  250. .parent()
  251. .parent()
  252. .find(".tran_div_channel[channal='" + channelId + "']")
  253. .append(html);
  254. }
  255. htmlSent += "</div>";
  256. htmlSent += "</div>"; //note_body
  257. htmlSent += "<div class='note_foot'>";
  258. htmlSent += "<span>" + iterator.ref + "</span>";
  259. htmlSent +=
  260. "<span class='sent_id'>" +
  261. iterator.book +
  262. "-" +
  263. iterator.para +
  264. "-" +
  265. iterator.begin +
  266. "-" +
  267. iterator.end +
  268. "</span>";
  269. htmlSent += "</div>"; //note_foot
  270. return htmlSent;
  271. }
  272. //生成channel列表
  273. function note_channal_list() {
  274. console.log("note_channal_list start");
  275. let arrSentInfo = new Array();
  276. $("note").each(function () {
  277. let info = $(this).attr("info");
  278. if (info && info != "") {
  279. arrSentInfo.push({ id: "", data: info });
  280. }
  281. });
  282. if (arrSentInfo.length > 0) {
  283. $.post(
  284. "../term/channal_list.php",
  285. {
  286. setting: "",
  287. data: JSON.stringify(arrSentInfo),
  288. },
  289. function (data, status) {
  290. if (status == "success") {
  291. try {
  292. let active = JSON.parse(data);
  293. _channalData = active;
  294. for (const iterator of _my_channal) {
  295. let found = false;
  296. for (const one of active) {
  297. if (iterator.id == one.id) {
  298. found = true;
  299. break;
  300. }
  301. }
  302. if (found == false) {
  303. _channalData.push(iterator);
  304. }
  305. }
  306. let strHtml = "";
  307. for (const iterator of _channalData) {
  308. if (_channal.indexOf(iterator.id) >= 0) {
  309. strHtml += render_channal_list(iterator);
  310. }
  311. }
  312. for (const iterator of _channalData) {
  313. if (_channal.indexOf(iterator.id) == -1) {
  314. strHtml += render_channal_list(iterator);
  315. }
  316. }
  317. $("#channal_list").html(strHtml);
  318. set_more_button_display();
  319. } catch (e) {
  320. console.error(e);
  321. }
  322. }
  323. }
  324. );
  325. }
  326. }
  327. function find_channal(id) {
  328. for (const iterator of _channalData) {
  329. if (id == iterator.id) {
  330. return iterator;
  331. }
  332. }
  333. return false;
  334. }
  335. function render_channal_list(channalinfo) {
  336. let output = "";
  337. let checked = "";
  338. let selected = "noselect";
  339. if (_channal.indexOf(channalinfo.id) >= 0) {
  340. checked = "checked";
  341. selected = "selected";
  342. }
  343. output += "<div class='list_with_head " + selected + "'>";
  344. output +=
  345. '<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
  346. output += "<div class='head'>";
  347. output += "<span class='head_img'>";
  348. if (parseInt(channalinfo.power) == 30) {
  349. output += gLocal.gui.your.slice(0, 1);
  350. } else {
  351. output += channalinfo.nickname.slice(0, 1);
  352. }
  353. output += "</span>";
  354. output += "</div>";
  355. output += "<div style='width: 100%;overflow-x: hidden;'>";
  356. output += "<div class='channal_list' >";
  357. // output += "<a href='../wiki/wiki.php?word=" + _word;
  358. // output += "&channal=" + channalinfo.id + "' >";
  359. switch (parseInt(channalinfo.status)) {
  360. case 10:
  361. output += "🔐";
  362. break;
  363. case 20:
  364. output += "🌐";
  365. break;
  366. case 30:
  367. output += "🌐";
  368. break;
  369. default:
  370. break;
  371. }
  372. if (parseInt(channalinfo.power) >= 20) {
  373. //if (parseInt(channalinfo.power) != 30)
  374. {
  375. output += "✏️";
  376. }
  377. }
  378. //✋
  379. output += "<a onclick=\"set_channal('" + channalinfo.id + "')\">";
  380. output += channalinfo["name"];
  381. output += "</a>";
  382. if (parseInt(channalinfo.power) == 30) {
  383. output += "@" + gLocal.gui.your;
  384. } else {
  385. output += "@" + channalinfo["nickname"];
  386. }
  387. output += "</div>";
  388. output += "<div class='userinfo_channal'>";
  389. output += channalinfo["username"];
  390. output += "</div>";
  391. //绘制句子进度
  392. if (channalinfo["final"]) {
  393. //进度
  394. output += "<div>";
  395. let article_len = channalinfo["article_len"];
  396. let svg_width = article_len;
  397. let svg_height = parseInt(article_len / 15);
  398. output += '<svg viewBox="0 0 ' + svg_width + " " + svg_height + '" width="100%" >';
  399. let curr_x = 0;
  400. let allFinal = 0;
  401. for (const iterator of channalinfo["final"]) {
  402. let stroke_width = parseInt(iterator.len);
  403. output += "<rect ";
  404. output += ' x="' + curr_x + '"';
  405. output += ' y="0"';
  406. output += ' height="' + svg_height + '"';
  407. output += ' width="' + stroke_width + '"';
  408. if (iterator.final == true) {
  409. allFinal += stroke_width;
  410. output += ' class="progress_bar_done" ';
  411. } else {
  412. output += ' class="progress_bar_undone" ';
  413. }
  414. output += "/>";
  415. curr_x += stroke_width;
  416. }
  417. output +=
  418. "<rect x='0' y='0' width='" + svg_width + "' height='" + svg_height / 5 + "' class='progress_bar_bg' />";
  419. output +=
  420. "<rect x='0' y='0' width='" +
  421. allFinal +
  422. "' height='" +
  423. svg_height / 5 +
  424. "' class='progress_bar_percent' style='stroke-width: 0; fill: rgb(100, 228, 100);'/>";
  425. output += '<text x="0" y="' + svg_height + '" font-size="' + svg_height * 0.8 + '">';
  426. output += channalinfo["count"] + "/" + channalinfo["all"] + "@" + curr_x;
  427. output += "</text>";
  428. output += "<svg>";
  429. output += "</div>";
  430. //进度结束
  431. }
  432. output += "</div>";
  433. output += "</div>";
  434. return output;
  435. }
  436. function onChannelMultiSelectStart() {
  437. $(".channel_select").show();
  438. }
  439. function onChannelMultiSelectCancel() {
  440. $(".channel_select").hide();
  441. }
  442. function onChannelChange() {
  443. let channal_list = new Array();
  444. $("[channal_id]").each(function () {
  445. if (this.checked) {
  446. channal_list.push($(this).attr("channal_id"));
  447. }
  448. });
  449. set_channal(channal_list.join());
  450. }
  451. //点击引用 需要响应的事件
  452. function note_ref_init() {
  453. $("chapter").click(function () {
  454. let bookid = $(this).attr("book");
  455. let para = $(this).attr("para");
  456. window.open("../reader/?view=chapter&book=" + bookid + "&para=" + para, "_blank");
  457. });
  458. $("para").click(function () {
  459. let bookid = $(this).attr("book");
  460. let para = $(this).attr("para");
  461. window.open("../reader/?view=para&book=" + bookid + "&para=" + para, "_blank");
  462. });
  463. }
  464. /*
  465. 生成编辑模式句子块
  466. id
  467. palitext
  468. tran
  469. ref
  470. */
  471. function note_json_html(in_json) {
  472. let output = "";
  473. output += '<div class="note_tool_bar" style=" position: relative;">';
  474. output += '<div class="case_dropdown note_tool_context" >';
  475. output += "<svg class='icon' >";
  476. output += "<use xlink:href='../studio/svg/icon.svg#ic_more'></use>";
  477. output += "</svg>";
  478. output += "<div class='case_dropdown-content sent_menu'>";
  479. if (typeof _reader_view != "undefined" && _reader_view != "sent") {
  480. output += "<a onclick='junp_to(this)'>" + gLocal.gui.jump_to_this_sent + "</a>";
  481. }
  482. output +=
  483. "<a onclick='related_para_dlg_open(" +
  484. in_json.book +
  485. "," +
  486. in_json.para +
  487. ")'>" +
  488. gLocal.gui.related_para +
  489. "</a>";
  490. output +=
  491. "<a onclick='goto_nissaya(" +
  492. in_json.book +
  493. "," +
  494. in_json.para +
  495. "," +
  496. in_json.begin +
  497. "," +
  498. in_json.end +
  499. ")'>" +
  500. gLocal.gui.show_nissaya +
  501. "</a>";
  502. output +=
  503. "<a onclick=\"copy_ref('" +
  504. in_json.book +
  505. "','" +
  506. in_json.para +
  507. "','" +
  508. in_json.begin +
  509. "','" +
  510. in_json.end +
  511. "')\">" +
  512. gLocal.gui.copy_link +
  513. "</a>";
  514. output += "<a onclick='copy_text(this)'>" + gLocal.gui.copy + "“" + gLocal.gui.pāli + "”</a>";
  515. output +=
  516. "<a onclick=\"edit_in_studio('" +
  517. in_json.book +
  518. "','" +
  519. in_json.para +
  520. "','" +
  521. in_json.begin +
  522. "','" +
  523. in_json.end +
  524. "')\">" +
  525. gLocal.gui.edit_now +
  526. "</a>";
  527. output += "<a onclick='add_to_list()'>" + gLocal.gui.add_to_edit_list + "</a>";
  528. output += "<a onclick='slider_show(this)'>Slider Show</a>";
  529. output += "</div>";
  530. output += "</div>";
  531. output += " </div>";
  532. let strPalitext =
  533. "<pali book='" +
  534. in_json.book +
  535. "' para='" +
  536. in_json.para +
  537. "' begin='" +
  538. in_json.begin +
  539. "' end='" +
  540. in_json.end +
  541. "' >" +
  542. in_json.palitext +
  543. "</pali>";
  544. output += "<div class='note_body'>";
  545. output += "<div class='palitext_div'>";
  546. output += "<div class='palitext palitext_roma'>" + strPalitext + "</div>";
  547. output += "<div class='palitext palitext1'></div>";
  548. output += "<div class='palitext palitext2'></div>";
  549. output += "</div>";
  550. //译文开始
  551. output += "<div class='sent_tran_div'>";
  552. for (const iterator of in_json.translation) {
  553. output += render_one_sent_tran_a(iterator);
  554. }
  555. output += "</div>";
  556. //译文结束
  557. output += "</div>"; /**note_body end */
  558. //工具栏开始
  559. output += "<div class='other_tran_div' sent='";
  560. output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
  561. output += "<div class='tool_bar' sent='";
  562. output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
  563. output += "<span class='tool_left'>";
  564. //第一个按钮
  565. //新增译文按钮开始
  566. output += "<span class='' ";
  567. output += "book='" + in_json.book + "' ";
  568. output += "para='" + in_json.para + "' ";
  569. output += "begin='" + in_json.begin + "' ";
  570. output += "end='" + in_json.end + "' ";
  571. output += " >";
  572. output += "<span class='' onclick='add_new_tran_button_click(this)' title='" + gLocal.gui.add_tran + "'>➕</span>";
  573. output += "<div class='tran_text_tool_bar'>";
  574. output += "</div>";
  575. output += "</span>";
  576. //新增译文按钮结束
  577. output += "<span class='separate_line'></span>";
  578. //第二个按钮
  579. output += "<span class='more_tran icon_expand'></span>";
  580. //其他译文工具条
  581. output += "<span class='other_bar' >";
  582. output +=
  583. "<span class='other_tran_span' title='🧲" +
  584. gLocal.gui.other +
  585. gLocal.gui.translation +
  586. "'><svg class='icon' style='fill: var(--box-bg-color1)'><use xlink:href=\"../studio/svg/icon.svg#more_tran\"></svg>" +
  587. gLocal.gui.translation +
  588. "</span>";
  589. output += "<span class='other_tran_num'></span>";
  590. output += "</span>";
  591. output += "<span class='separate_line'></span>";
  592. //手工义注
  593. output += "<span class='other_bar'>";
  594. output +=
  595. "<span class='other_tran_span commentray' title='📔" +
  596. gLocal.gui.vannana +
  597. "'>🪔" +
  598. gLocal.gui.commentary +
  599. "</span>";
  600. output += "<span class='other_tran_num'></span>";
  601. output += "</span>";
  602. output += "<span class='separate_line'></span>";
  603. //第三个按钮 相似句
  604. if (parseInt(in_json.sim) > 0) {
  605. output += "<span class='other_bar' >";
  606. output +=
  607. "<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
  608. in_json.pali_sent_id +
  609. "')\" title='" +
  610. gLocal.gui.similar_sentences +
  611. "'>🧬" +
  612. gLocal.gui.similar +
  613. "</span>";
  614. output += "<span class='similar_sent_num'>" + in_json.sim + "</span>";
  615. output += "</span>";
  616. output += "<span class='separate_line'></span>";
  617. }
  618. //第三个按钮 相似句结束
  619. output += "</span>";
  620. output += "<span class='tool_right'>";
  621. //出处路径开始
  622. output += "<span class='ref'>";
  623. output += "<span class='book_name tooltip'>" + in_json.booktitle;
  624. output += "<span class='tooltiptext tooltip-bottom'>";
  625. output += in_json.ref;
  626. output += "</span>";
  627. output += "<span class='sent_no'>";
  628. output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
  629. output += "<span>";
  630. output += "</span>";
  631. output += "</span>";
  632. //出处路径结束
  633. output += "</span>";
  634. output += "</div>";
  635. //工具栏结束
  636. //未选择的其他译文开始
  637. output += "<div class='other_tran'>";
  638. output += "</div>";
  639. output += "</div>";
  640. return output;
  641. }
  642. //设置取消输入框的编辑模式
  643. function sent_tran_set_edit_mode(obj, isEditMode) {
  644. $(".sent_tran").removeClass("edit_mode");
  645. if (isEditMode) {
  646. let jqObj = $(obj);
  647. while (!jqObj.hasClass("sent_tran")) {
  648. jqObj = jqObj.parent();
  649. if (!jqObj) {
  650. return;
  651. }
  652. }
  653. jqObj.addClass("edit_mode");
  654. }
  655. }
  656. function sent_tran_edit(obj) {
  657. let jqObj = $(obj);
  658. while (!jqObj.hasClass("sent_tran")) {
  659. jqObj = jqObj.parent();
  660. if (!jqObj) {
  661. return;
  662. }
  663. }
  664. if (jqObj.hasClass("edit_mode")) {
  665. jqObj.removeClass("edit_mode");
  666. } else {
  667. $(".sent_tran").removeClass("edit_mode");
  668. jqObj.addClass("edit_mode");
  669. }
  670. }
  671. function sent_pr_merge(id) {
  672. $.post(
  673. "../usent/sent_pr_merge.php",
  674. {
  675. id: id,
  676. },
  677. function (data) {
  678. let result = JSON.parse(data);
  679. if (result.status > 0) {
  680. alert("error" + result.message);
  681. } else {
  682. ntf_show("成功采纳");
  683. }
  684. }
  685. );
  686. }
  687. function sent_commit(src, id) {
  688. commit_init({
  689. src: src,
  690. sent: [id],
  691. express: true,
  692. });
  693. }
  694. function render_one_sent_tran_a(iterator) {
  695. let mChannel = get_channel_by_id(iterator.channal);
  696. let tranText;
  697. let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
  698. if (iterator.text == "") {
  699. if (typeof iterator.channalinfo == "undefined") {
  700. tranText =
  701. "<span style='color:var(--border-line-color);'>" +
  702. "空" +
  703. "@" +
  704. iterator.editor_name.nickname +
  705. "</span>";
  706. } else {
  707. tranText =
  708. "<span style='color:var(--border-line-color);'>" +
  709. iterator.channalinfo.name +
  710. "-" +
  711. iterator.channalinfo.lang +
  712. "</span>";
  713. }
  714. } else {
  715. //note_init处理句子链接
  716. tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  717. }
  718. let html = "";
  719. html += "<div class='sent_tran ";
  720. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  721. html += " pr ";
  722. }
  723. html += "' dbid='" + iterator.id + "' channel='" + iterator.channal + "' sid='" + sid + "'>";
  724. html += "<div class='sent_tran_inner'>";
  725. html += '<div class="tool_bar">';
  726. html += ' <div class="right">';
  727. //句子菜单
  728. html += '<div class="pop_menu">';
  729. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  730. //在pr 列表中的译文
  731. if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
  732. //提交人
  733. //修改按钮
  734. html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
  735. html += '<svg class="icon" >';
  736. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
  737. html += "</svg>";
  738. html += "<span class='tooltiptext tooltip-top'>";
  739. html += gLocal.gui.modify;
  740. html += "</span>";
  741. html += "</button>";
  742. //删除按钮
  743. html += "<button class='icon_btn tooltip' onclick='sent_pr_del(this)'>";
  744. html += '<svg class="icon" >';
  745. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_delete"></use>';
  746. html += "</svg>";
  747. html += "<span class='tooltiptext tooltip-top'>";
  748. html += gLocal.gui.delete;
  749. html += "</span>";
  750. html += "</button>";
  751. } else {
  752. //非提交人
  753. if (parseInt(iterator.mypower) >= 20) {
  754. //有权限 采纳按钮
  755. html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
  756. html += '<svg class="icon" >';
  757. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#accept_copy"></use>';
  758. html += "</svg>";
  759. html += "<span class='tooltiptext tooltip-top'>";
  760. html += gLocal.gui.accept_copy;
  761. html += "</span>";
  762. html += "</button>";
  763. }
  764. //点赞按钮
  765. html += "<button class='icon_btn tooltip' onclick='sent_pr_like(this)'>";
  766. html += '<svg class="icon" >';
  767. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
  768. html += "</svg>";
  769. html += "<span class='tooltiptext tooltip-top'>";
  770. html += gLocal.gui.like;
  771. html += "</span>";
  772. html += "</button>";
  773. }
  774. } else {
  775. //非pr列表里的句子
  776. //编辑按钮
  777. html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
  778. html += '<svg class="icon" >';
  779. if (parseInt(iterator.mypower) < 20) {
  780. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#my_idea"></use>';
  781. } else {
  782. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
  783. }
  784. html += "</svg>";
  785. html += "<span class='tooltiptext tooltip-top'>";
  786. if (parseInt(iterator.mypower) < 20) {
  787. html += gLocal.gui.suggest;
  788. } else {
  789. html += gLocal.gui.edit;
  790. }
  791. html += "</span>";
  792. html += "</button>";
  793. //推送按钮
  794. let commitIcon = "";
  795. let commitTipText = "";
  796. if (parseInt(iterator.mypower) >= 30 && parseInt(iterator.status) < 30) {
  797. //我的私有资源 公开发布
  798. commitIcon = "publish";
  799. commitTipText = gLocal.gui.publish;
  800. } else {
  801. if (parseInt(iterator.mypower) < 20) {
  802. //只读资源 采纳
  803. commitIcon = "accept_copy";
  804. commitTipText = gLocal.gui.accept_copy;
  805. } else {
  806. //其他资源 复制到
  807. commitIcon = "copy";
  808. commitTipText = gLocal.gui.copy_to;
  809. }
  810. }
  811. html += "<button class='icon_btn tooltip' ";
  812. html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
  813. html += '<svg class="icon" >';
  814. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + commitIcon + '"></use>';
  815. html += "</svg>";
  816. html += "<span class='tooltiptext tooltip-top'>";
  817. html += commitTipText;
  818. html += "</span>";
  819. html += "</button>";
  820. //推送按钮结束
  821. //更多按钮
  822. html += '<div class="case_dropdown">';
  823. html += "<button class='icon_btn'>";
  824. html += '<svg class="icon" >';
  825. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_more"></use>';
  826. html += "</svg>";
  827. html += "</button>";
  828. html += '<div class="case_dropdown-content menu_space_between" style="right:0;">';
  829. //时间线
  830. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  831. html += "<span>" + gLocal.gui.timeline + "</span>";
  832. html += '<svg class="icon" >';
  833. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use>';
  834. html += "</svg>";
  835. html += "</a>";
  836. //复制
  837. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  838. html += "<span>" + gLocal.gui.copy + "</span>";
  839. html += '<svg class="icon" >';
  840. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use>';
  841. html += "</svg>";
  842. html += "</a>";
  843. //点赞
  844. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  845. html += "<span>" + gLocal.gui.like + "</span>";
  846. html += '<svg class="icon" >';
  847. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
  848. html += "</svg>";
  849. html += "</a>";
  850. //分享
  851. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  852. html += "<span>" + gLocal.gui.share_to + "</span>";
  853. html += '<svg class="icon" >';
  854. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use>';
  855. html += "</svg>";
  856. html += "</a>";
  857. html += "</div>";
  858. html += "</div>";
  859. //更多按钮结束
  860. }
  861. html += "</div>";
  862. //句子菜单结束
  863. html += "</div>";
  864. html += "</div>";
  865. //tool_bar 结束
  866. html += '<div class="left_bar" >';
  867. html += ' <div class="face">';
  868. if (iterator.id != "") {
  869. html += '<span class="head_img">' + iterator.editor_name.nickname.slice(0, 1) + "</span>";
  870. }
  871. html += "</div>";
  872. html +=
  873. '<div class="date" title="' +
  874. getFullDataTime(iterator.update_time) +
  875. '">' +
  876. getDataTime(iterator.update_time) +
  877. "</div>";
  878. html += "</div>";
  879. html += '<div class="body">';
  880. html += '<div class="head_bar">';
  881. html += '<div class="info">';
  882. html += '<span class="name" title="' + iterator.editor_name.nickname + gLocal.gui.recent_update + '">';
  883. if (typeof iterator.channalinfo == "undefined") {
  884. html += "unkown";
  885. } else {
  886. html += iterator.channalinfo.name;
  887. }
  888. html += "</span>";
  889. html += '<span class="date">' + getPassDataTime(iterator.update_time) + "</span>";
  890. html += "</div>";
  891. html += "<div class='preview'>" + tranText + "</div>";
  892. html += "</div>";
  893. html += '<div class="edit">';
  894. html += '<div class="input">';
  895. html += "<textarea class='tran_sent_textarea' dbid='" + iterator.id + "' ";
  896. html += "sid='" + sid + "' ";
  897. html += "channel='" + iterator.channal + "' ";
  898. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  899. html += ' is_pr="true" onchange1="note_pr_save(this)"';
  900. } else {
  901. html += 'is_pr="false" onchange1="note_sent_save_a(this)"';
  902. }
  903. html += ">" + iterator.text + "</textarea>";
  904. html += "</div>";
  905. html += '<div class="edit_tool">';
  906. //html += ""
  907. html +=
  908. '<span style="display: inline-flex;"><svg class="icon" style="width: 25px;height: 18px;"><svg id="ESC_button" viewBox="0 0 210 150" version="1.1"><filter inkscape:label="Button" inkscape:menu="Bevels" inkscape:menu-tooltip="Soft bevel, slightly depressed middle" style="color-interpolation-filters:sRGB;" id="filter1808"><feMorphology in="SourceAlpha" radius="6.6" result="result1" id="feMorphology1784" /><feGaussianBlur stdDeviation="8.9" in="result1" id="feGaussianBlur1786" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.3 0" result="result91" id="feColorMatrix1788" /><feComposite in="result0" operator="out" result="result2" in2="result91" id="feComposite1790" /><feGaussianBlur stdDeviation="1.7" result="result4" id="feGaussianBlur1792" /><feDiffuseLighting surfaceScale="10" id="feDiffuseLighting1796"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1794" /></feDiffuseLighting><feBlend in2="SourceGraphic" mode="multiply" id="feBlend1798" /><feComposite in2="SourceAlpha" operator="in" result="result3" id="feComposite1800" /><feSpecularLighting in="result4" surfaceScale="5" specularExponent="17.9" id="feSpecularLighting1804"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1802" /></feSpecularLighting><feComposite in2="result3" operator="atop" id="feComposite1806" /></filter></defs><sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.4865144" inkscape:cx="57.142857" inkscape:cy="96.638595" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" showgrid="false" inkscape:window-width="1920" inkscape:window-height="1001" inkscape:window-x="-9" inkscape:window-y="-9" inkscape:window-maximized="1" /><rect ry="58.781078" style="fill:#999999;fill-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;filter:url(#filter1808)" id="rect1264" width="210" height="150" x="0" y="0" /><text xml:space="preserve" id="text1266" style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1268);fill:#000000;fill-opacity:1;stroke:none;" transform="matrix(1.1320886,0,0,1.1287136,-1.7621172,25.458127)"><tspan x="30" y="70"><tspan style="font-size:70.5556px;fill:#ffffff">ESC</tspan></tspan></text></svg></svg>&nbsp;=&nbsp;';
  909. html +=
  910. "<a onclick='tran_sent_edit_cancel(this)'>" +
  911. gLocal.gui.cancel +
  912. "</a></span><span style='display: inline-flex;'>";
  913. html +=
  914. '<svg class="icon" style="width: 30px;height: 18px;"><svg id="ESC_button" viewBox="0 0 250 150" version="1.1"><filter inkscape:label="Button" inkscape:menu="Bevels" inkscape:menu-tooltip="Soft bevel, slightly depressed middle" style="color-interpolation-filters:sRGB;" id="filter1808"><feMorphology in="SourceAlpha" radius="6.6" result="result1" id="feMorphology1784" /><feGaussianBlur stdDeviation="8.9" in="result1" id="feGaussianBlur1786" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.3 0" result="result91" id="feColorMatrix1788" /><feComposite in="result0" operator="out" result="result2" in2="result91" id="feComposite1790" /><feGaussianBlur stdDeviation="1.7" result="result4" id="feGaussianBlur1792" /><feDiffuseLighting surfaceScale="10" id="feDiffuseLighting1796"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1794" /></feDiffuseLighting><feBlend in2="SourceGraphic" mode="multiply" id="feBlend1798" /><feComposite in2="SourceAlpha" operator="in" result="result3" id="feComposite1800" /><feSpecularLighting in="result4" surfaceScale="5" specularExponent="17.9" id="feSpecularLighting1804"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1802" /></feSpecularLighting><feComposite in2="result3" operator="atop" id="feComposite1806" /></filter></defs><sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.4865144" inkscape:cx="57.142857" inkscape:cy="96.638595" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" showgrid="false" inkscape:window-width="1920" inkscape:window-height="1001" inkscape:window-x="-9" inkscape:window-y="-9" inkscape:window-maximized="1" /><rect ry="58.781078" style="fill:#999999;fill-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;filter:url(#filter1808)" id="rect1264" width="250" height="150" x="0" y="0" /><text xml:space="preserve" id="text1266" style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1268);fill:#000000;fill-opacity:1;stroke:none;" transform="matrix(1.1320886,0,0,1.1287136,-1.7621172,25.458127)"><tspan x="30" y="70"><tspan style="font-size:70.5556px;fill:#ffffff">Shift</tspan></tspan></text></svg></svg>';
  915. html += "➕";
  916. html +=
  917. '<svg class="icon" style="width: 32px;height: 18px;"><svg id="ESC_button" style="width: 32px;height: 18px;" viewBox="0 0 260 150" version="1.1"><filter inkscape:label="Button" inkscape:menu="Bevels" inkscape:menu-tooltip="Soft bevel, slightly depressed middle" style="color-interpolation-filters:sRGB;" id="filter1808"><feMorphology in="SourceAlpha" radius="6.6" result="result1" id="feMorphology1784" /><feGaussianBlur stdDeviation="8.9" in="result1" id="feGaussianBlur1786" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.3 0" result="result91" id="feColorMatrix1788" /><feComposite in="result0" operator="out" result="result2" in2="result91" id="feComposite1790" /><feGaussianBlur stdDeviation="1.7" result="result4" id="feGaussianBlur1792" /><feDiffuseLighting surfaceScale="10" id="feDiffuseLighting1796"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1794" /></feDiffuseLighting><feBlend in2="SourceGraphic" mode="multiply" id="feBlend1798" /><feComposite in2="SourceAlpha" operator="in" result="result3" id="feComposite1800" /><feSpecularLighting in="result4" surfaceScale="5" specularExponent="17.9" id="feSpecularLighting1804"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1802" /></feSpecularLighting><feComposite in2="result3" operator="atop" id="feComposite1806" /></filter></defs><sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.4865144" inkscape:cx="57.142857" inkscape:cy="96.638595" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" showgrid="false" inkscape:window-width="1920" inkscape:window-height="1001" inkscape:window-x="-9" inkscape:window-y="-9" inkscape:window-maximized="1" /><rect ry="58.781078" style="fill:#999999;fill-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;filter:url(#filter1808)" id="rect1264" width="260" height="150" x="0" y="0" /><text xml:space="preserve" id="text1266" style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1268);fill:#000000;fill-opacity:1;stroke:none;" transform="matrix(1.1320886,0,0,1.1287136,-1.7621172,25.458127)"><tspan x="30" y="70"><tspan style="font-size:70.5556px;fill:#ffffff">Enter</tspan></tspan></text></svg></svg>&nbsp;=&nbsp;';
  918. if (parseInt(iterator.mypower) < 20) {
  919. html += "<a onclick='tran_sent_save(this)'>";
  920. html += gLocal.gui.submit + "<b>" + gLocal.gui.suggest + gLocal.gui.translation + "</b>";
  921. html += "</a></span><span style='display: inline-flex;'>";
  922. } else {
  923. html += "<a onclick='tran_sent_save(this)'>";
  924. html += gLocal.gui.save;
  925. html += "</a></span><span style='display: inline-flex;'>";
  926. }
  927. html +=
  928. '<svg class="icon" style="width: 32px;height: 18px;"><svg id="ESC_button" style="width: 32px;height: 18px;" viewBox="0 0 260 150" version="1.1"><filter inkscape:label="Button" inkscape:menu="Bevels" inkscape:menu-tooltip="Soft bevel, slightly depressed middle" style="color-interpolation-filters:sRGB;" id="filter1808"><feMorphology in="SourceAlpha" radius="6.6" result="result1" id="feMorphology1784" /><feGaussianBlur stdDeviation="8.9" in="result1" id="feGaussianBlur1786" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.3 0" result="result91" id="feColorMatrix1788" /><feComposite in="result0" operator="out" result="result2" in2="result91" id="feComposite1790" /><feGaussianBlur stdDeviation="1.7" result="result4" id="feGaussianBlur1792" /><feDiffuseLighting surfaceScale="10" id="feDiffuseLighting1796"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1794" /></feDiffuseLighting><feBlend in2="SourceGraphic" mode="multiply" id="feBlend1798" /><feComposite in2="SourceAlpha" operator="in" result="result3" id="feComposite1800" /><feSpecularLighting in="result4" surfaceScale="5" specularExponent="17.9" id="feSpecularLighting1804"><feDistantLight azimuth="225" elevation="45" id="feDistantLight1802" /></feSpecularLighting><feComposite in2="result3" operator="atop" id="feComposite1806" /></filter></defs><sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="2.4865144" inkscape:cx="57.142857" inkscape:cy="96.638595" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" showgrid="false" inkscape:window-width="1920" inkscape:window-height="1001" inkscape:window-x="-9" inkscape:window-y="-9" inkscape:window-maximized="1" /><rect ry="58.781078" style="fill:#999999;fill-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;filter:url(#filter1808)" id="rect1264" width="260" height="150" x="0" y="0" /><text xml:space="preserve" id="text1266" style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect1268);fill:#000000;fill-opacity:1;stroke:none;" transform="matrix(1.1320886,0,0,1.1287136,-1.7621172,25.458127)"><tspan x="30" y="70"><tspan style="font-size:70.5556px;fill:#ffffff">Enter</tspan></tspan></text></svg></svg>';
  929. //html += "<button>Enter</button>"
  930. html += "&nbsp;=&nbsp;";
  931. html += gLocal.gui.next_line;
  932. html += "</span><span style='display: inline-flex;'>MarkDown✅</span>";
  933. html += "</div>";
  934. html += "</div>";
  935. html += '<div class="foot_bar">';
  936. html += '<div class="info">';
  937. if (iterator.id != "") {
  938. html += '<span class="date"> ' + getPassDataTime(iterator.update_time) + "</span>";
  939. }
  940. if (iterator.id != "") {
  941. html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
  942. }
  943. if (iterator.id != "") {
  944. html += '<span class="channel">' + gLocal.gui.updated + " ";
  945. if (typeof iterator.channalinfo == "undefined") {
  946. html += "unkown";
  947. } else {
  948. html += "<a title='" + iterator.channalinfo.owner + "'>" + iterator.channalinfo.name + "@</a>";
  949. }
  950. html += "</span>";
  951. } else {
  952. html += '<span class="channel">' + gLocal.gui.no_updated + " @";
  953. if (typeof iterator.channalinfo == "undefined") {
  954. html += "unkown";
  955. } else {
  956. html += "<a title='" + iterator.channalinfo.owner + "'>" + iterator.channalinfo.name + "@</a>";
  957. }
  958. html += "</span>";
  959. }
  960. html += '<ul class="tag_list">';
  961. if (iterator.pr_all && parseInt(iterator.pr_all) > 0) {
  962. html +=
  963. "<li onclick=\"note_pr_show('" +
  964. iterator.channal +
  965. "','" +
  966. sid +
  967. "')\"><span class='icon'>✋</span><span class='num'>" +
  968. iterator.pr_new +
  969. "/" +
  970. iterator.pr_all +
  971. "</span></li>";
  972. }
  973. html += "</ul>";
  974. html += "</div>"; //end of info
  975. html += "</div>"; //end of foot bar
  976. html += "</div>";
  977. html += "</div>";
  978. //sent_tran_inner结束
  979. html += '<div class="pr_content"></div>';
  980. html += "</div>";
  981. return html;
  982. }
  983. function tran_sent_textarea_event_init() {
  984. let textarea = document.querySelectorAll(".tran_sent_textarea");
  985. for (let iterator of textarea) {
  986. iterator.onkeydown = function (e) {
  987. let menu = document.querySelector("#menu");
  988. switch (e.key) {
  989. case "Enter":
  990. if (menu && menu.style.display == "block") {
  991. let value = textarea.value;
  992. let selectionStart = textarea.selectionStart;
  993. let str1 = value.slice(0, selectionStart);
  994. let str2 = value.slice(selectionStart);
  995. textarea.value = str1 + data[menuFocusIndex] + "]]" + str2;
  996. menu.style.display = "none";
  997. return false;
  998. } else {
  999. if (e.shiftKey) {
  1000. //回车存盘
  1001. tran_sent_save(e.currentTarget);
  1002. return false;
  1003. }
  1004. }
  1005. break;
  1006. case "Escape":
  1007. tran_sent_edit_cancel(e.currentTarget);
  1008. break;
  1009. default:
  1010. break;
  1011. }
  1012. };
  1013. }
  1014. }
  1015. function render_one_sent_tran(book, para, begin, end, iterator) {
  1016. let output = "";
  1017. output += "<div class='tran' lang='" + iterator.lang + "' style='display:flex;'>";
  1018. //译文工具按钮开始
  1019. output += "<div class='tran_text_tool_botton' onclick='tool_bar_show(this)'>";
  1020. output +=
  1021. "<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>";
  1022. //译文工具栏开始
  1023. output += "<div class='tran_text_tool_bar'>";
  1024. output += "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom' ";
  1025. output +=
  1026. " onclick=\"note_edit_sentence('" +
  1027. book +
  1028. "' ,'" +
  1029. para +
  1030. "' ,'" +
  1031. begin +
  1032. "' ,'" +
  1033. end +
  1034. "' ,'" +
  1035. iterator.channal +
  1036. "')\"";
  1037. output +=
  1038. ">" +
  1039. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use></svg>';
  1040. output += gLocal.gui.edit + "</li>";
  1041. output += "<li class = 'tip_buttom' ";
  1042. output += " onclick=\"history_show('" + iterator.id + "')\" >";
  1043. output +=
  1044. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use></svg>';
  1045. output += gLocal.gui.timeline + "</li>";
  1046. output +=
  1047. "<li class = 'tip_buttom'>" +
  1048. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use></svg>';
  1049. output += gLocal.gui.copy + "</li></div>";
  1050. output +=
  1051. "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  1052. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use></svg>';
  1053. output += gLocal.gui.like + "</li>";
  1054. output +=
  1055. "<li class = 'tip_buttom'>" +
  1056. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#comment"></use></svg>';
  1057. output += gLocal.gui.comment + "</li>";
  1058. output +=
  1059. "<li class = 'tip_buttom'>" +
  1060. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_shopping_cart"></use></svg>';
  1061. output += gLocal.gui.digest + "</li></div>";
  1062. output +=
  1063. "<div style='margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  1064. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use></svg>';
  1065. output += gLocal.gui.share_to + "</li>";
  1066. output += "</div></div>";
  1067. //译文工具栏结束
  1068. output += "</div>";
  1069. //译文工具按钮结束
  1070. //译文正文开始
  1071. output +=
  1072. "<div class='text' id='tran_text_" +
  1073. book +
  1074. "_" +
  1075. para +
  1076. "_" +
  1077. begin +
  1078. "_" +
  1079. end +
  1080. "_" +
  1081. iterator.channal +
  1082. "'>";
  1083. if (iterator.text == "") {
  1084. output +=
  1085. "<span style='color:var(--border-line-color);'>" +
  1086. iterator.channalinfo.name +
  1087. "-" +
  1088. iterator.channalinfo.lang +
  1089. "</span>";
  1090. } else {
  1091. //note_init处理句子链接
  1092. output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  1093. }
  1094. output += "</div>";
  1095. //译文正文结束
  1096. output += "</div>";
  1097. //单个channal译文框结束
  1098. return output;
  1099. }
  1100. function add_new_tran_button_click(obj) {
  1101. let html = "<div style='display:flex; max-width: 40vw; white-space: normal;'>";
  1102. var first_lang = "";
  1103. for (const iterator of _my_channal) {
  1104. if (iterator.lang) {
  1105. first_lang = iterator.lang;
  1106. break;
  1107. }
  1108. }
  1109. html += "<ul class='channel_list lang_0' >";
  1110. html += "<li>";
  1111. html += first_lang;
  1112. html += "</li>";
  1113. for (const iterator of _my_channal) {
  1114. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) != -1 && iterator.lang != 0) {
  1115. if (_channal.indexOf(iterator.id) < 0) {
  1116. html += '<li class="channel_name" onclick="';
  1117. html +=
  1118. "new_sentence('" +
  1119. $(obj).parent().attr("book") +
  1120. "' ,'" +
  1121. $(obj).parent().attr("para") +
  1122. "' ,'" +
  1123. $(obj).parent().attr("begin") +
  1124. "' ,'" +
  1125. $(obj).parent().attr("end") +
  1126. "' ,'" +
  1127. iterator.id +
  1128. "',this)";
  1129. html += '" title="' + iterator.nickname;
  1130. html += '">' + iterator.name;
  1131. if (parseInt(iterator.power) < 20) {
  1132. html += "(建议)";
  1133. }
  1134. html += "</li>";
  1135. }
  1136. }
  1137. }
  1138. html += "</ul>";
  1139. html += "<ul class='channel_list lang_1'>";
  1140. html += "<li>";
  1141. html += gLocal.gui.other;
  1142. html += "</li>";
  1143. for (const iterator of _my_channal) {
  1144. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) == -1 && iterator.lang != 0) {
  1145. if (_channal.indexOf(iterator.id) < 0) {
  1146. html += '<li class="channel_name" onclick="';
  1147. html +=
  1148. "new_sentence('" +
  1149. $(obj).parent().attr("book") +
  1150. "' ,'" +
  1151. $(obj).parent().attr("para") +
  1152. "' ,'" +
  1153. $(obj).parent().attr("begin") +
  1154. "' ,'" +
  1155. $(obj).parent().attr("end") +
  1156. "' ,'" +
  1157. iterator.id +
  1158. "',this)";
  1159. html += '" title="' + iterator.nickname;
  1160. html += '">' + iterator.name;
  1161. if (parseInt(iterator.power) < 20) {
  1162. html += "(建议)";
  1163. }
  1164. html += "</li>";
  1165. }
  1166. }
  1167. }
  1168. html += "</ul>";
  1169. html += "<ul class='channel_list lang_2'>";
  1170. html += "<li>";
  1171. html += gLocal.gui.collaborate;
  1172. html += "</li>";
  1173. for (const iterator of _my_channal) {
  1174. if (iterator.status > 0 && iterator.lang == 0) {
  1175. if (_channal.indexOf(iterator.id) < 0) {
  1176. html += '<li class="channel_name" onclick="';
  1177. html +=
  1178. "new_sentence('" +
  1179. $(obj).parent().attr("book") +
  1180. "' ,'" +
  1181. $(obj).parent().attr("para") +
  1182. "' ,'" +
  1183. $(obj).parent().attr("begin") +
  1184. "' ,'" +
  1185. $(obj).parent().attr("end") +
  1186. "' ,'" +
  1187. iterator.id +
  1188. "',this)";
  1189. html += '" title="' + iterator.nickname;
  1190. html += '">' + iterator.name;
  1191. if (parseInt(iterator.power) < 20) {
  1192. html += "(建议)";
  1193. }
  1194. html += "</li>";
  1195. }
  1196. }
  1197. }
  1198. html += "</ul>";
  1199. html += "</div>";
  1200. $(obj).parent().children(".tran_text_tool_bar").first().html(html);
  1201. if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
  1202. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1203. } else {
  1204. $(obj).parent().children(".tran_text_tool_bar").first().show();
  1205. $(document).one("click", function () {
  1206. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1207. });
  1208. event.stopPropagation();
  1209. $(obj).parent().show();
  1210. }
  1211. }
  1212. function tool_bar_show(element) {
  1213. if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
  1214. $(element).find(".tran_text_tool_bar").css("display", "flex");
  1215. $(element).find(".icon_expand").css("transform", "rotate(-180deg)");
  1216. $(element).css("background-color", "var(--btn-bg-color)");
  1217. $(element).css("visibility", "visible");
  1218. $(document).one("click", function () {
  1219. $(element).find(".tran_text_tool_bar").hide();
  1220. $(element).css("background-color", "var(--nocolor)");
  1221. $(element).find(".icon_expand").css("transform", "unset");
  1222. $(element).css("visibility", "");
  1223. });
  1224. event.stopPropagation();
  1225. } else {
  1226. $(element).find(".tran_text_tool_bar").hide();
  1227. $(element).css("background-color", "var(--nocolor)");
  1228. $(element).find(".icon_expand").css("transform", "unset");
  1229. $(element).css("visibility", "");
  1230. }
  1231. }
  1232. function new_sentence(book, para, begin, end, channel, obj) {
  1233. let newsent = { id: "", text: "", lang: "", channal: channel };
  1234. for (let iterator of _arrData) {
  1235. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1236. let found = false;
  1237. for (const tran of iterator.translation) {
  1238. if (tran.channal == channel) {
  1239. found = true;
  1240. break;
  1241. }
  1242. }
  1243. if (!found) {
  1244. iterator.translation.push(newsent);
  1245. }
  1246. }
  1247. }
  1248. if ($(obj).parent().parent().css("display") == "block") {
  1249. $(obj).parent().parent().hide();
  1250. }
  1251. note_edit_sentence(book, para, begin, end, channel);
  1252. }
  1253. //显示更多译文按钮动作
  1254. function set_more_button_display() {
  1255. $(".other_tran_div").each(function () {
  1256. const sentid = $(this).attr("sent").split("-");
  1257. const book = sentid[0];
  1258. const para = sentid[1];
  1259. const begin = sentid[2];
  1260. const end = sentid[3];
  1261. let count = 0;
  1262. for (const iterator of _channalData) {
  1263. if (iterator.final) {
  1264. for (const onesent of iterator.final) {
  1265. let id = onesent.id.split("-");
  1266. if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
  1267. if (_channal.indexOf(iterator.id) == -1) {
  1268. count++;
  1269. }
  1270. }
  1271. }
  1272. }
  1273. }
  1274. if (count > 0) {
  1275. $(this).find(".other_tran_num").html(count);
  1276. $(this).find(".other_tran_num").attr("style", "display:inline-flex;");
  1277. $(this)
  1278. .find(".other_bar")
  1279. .click(function () {
  1280. const sentid = $(this).parent().parent().attr("sent").split("-");
  1281. const book = sentid[0];
  1282. const para = sentid[1];
  1283. const begin = sentid[2];
  1284. const end = sentid[3];
  1285. let sentId = $(this).parent().parent().attr("sent");
  1286. if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
  1287. $(".other_tran_div[sent='" + sentId + "']")
  1288. .children(".other_tran")
  1289. .slideDown();
  1290. $(this).siblings(".more_tran ").css("transform", "unset");
  1291. $.get(
  1292. "../usent/get.php",
  1293. {
  1294. book: book,
  1295. para: para,
  1296. begin: begin,
  1297. end: end,
  1298. },
  1299. function (data, status) {
  1300. let arrSent = JSON.parse(data);
  1301. let html = "<div class='compact'>";
  1302. for (const iterator of arrSent) {
  1303. if (_channal.indexOf(iterator.channal) == -1) {
  1304. html += render_one_sent_tran_a(iterator);
  1305. }
  1306. }
  1307. html += "</div>";
  1308. let sentId =
  1309. arrSent[0].book +
  1310. "-" +
  1311. arrSent[0].paragraph +
  1312. "-" +
  1313. arrSent[0].begin +
  1314. "-" +
  1315. arrSent[0].end;
  1316. $(".other_tran_div[sent='" + sentId + "']")
  1317. .children(".other_tran")
  1318. .html(html);
  1319. }
  1320. );
  1321. } else {
  1322. $(".other_tran_div[sent='" + sentId + "']")
  1323. .children(".other_tran")
  1324. .slideUp();
  1325. $(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
  1326. }
  1327. });
  1328. } else {
  1329. //隐藏自己
  1330. //$(this).hide();
  1331. $(this).find(".other_tran_span").addClass("disable"); //gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation
  1332. //$(this).find(".more_tran").hide();
  1333. }
  1334. });
  1335. }
  1336. function note_edit_sentence(book, para, begin, end, channal) {
  1337. let channalInfo;
  1338. for (const iterator of _channalData) {
  1339. if (iterator.id == channal) {
  1340. channalInfo = iterator;
  1341. break;
  1342. }
  1343. }
  1344. for (const iterator of _arrData) {
  1345. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1346. for (const tran of iterator.translation) {
  1347. if (tran.channal == channal) {
  1348. let html = "";
  1349. html += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
  1350. html +=
  1351. "<textarea id='edit_dialog_text' sent_id='" +
  1352. tran.id +
  1353. "' book='" +
  1354. book +
  1355. "' para='" +
  1356. para +
  1357. "' begin='" +
  1358. begin +
  1359. "' end='" +
  1360. end +
  1361. "' channal='" +
  1362. channal +
  1363. "' style='width:100%;min-height:260px;'>" +
  1364. tran.text +
  1365. "</textarea>";
  1366. $("#edit_dialog_content").html(html);
  1367. $("#note_sent_edit_dlg").dialog("open");
  1368. return;
  1369. }
  1370. }
  1371. }
  1372. }
  1373. alert("未找到句子");
  1374. }
  1375. function tran_sent_edit_cancel(obj) {
  1376. sent_tran_set_edit_mode(obj, false);
  1377. }
  1378. function tran_sent_save(obj) {
  1379. let sentDiv = find_sent_tran_div(obj);
  1380. if (sentDiv) {
  1381. let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
  1382. let isPr = $(textarea).attr("is_pr");
  1383. if (isPr == "true") {
  1384. note_pr_save(textarea);
  1385. } else {
  1386. note_sent_save_a(textarea);
  1387. }
  1388. sent_tran_set_edit_mode(textarea, false);
  1389. } else {
  1390. console.error("sent div not found");
  1391. }
  1392. }
  1393. //保存pr句子 新
  1394. function note_pr_save(obj) {
  1395. let id = $(obj).attr("dbid");
  1396. let sid = $(obj).attr("sid").split("-");
  1397. let book = sid[0];
  1398. let para = sid[1];
  1399. let begin = sid[2];
  1400. let end = sid[3];
  1401. let channel = $(obj).attr("channel");
  1402. let text = $(obj).val();
  1403. let sent_tran_div = find_sent_tran_div(obj);
  1404. $.post(
  1405. "../usent/pr_post.php",
  1406. {
  1407. id: id,
  1408. book: book,
  1409. para: para,
  1410. begin: begin,
  1411. end: end,
  1412. channel: channel,
  1413. text: text,
  1414. },
  1415. sent_save_callback
  1416. );
  1417. if (sent_tran_div) {
  1418. $(sent_tran_div).find(".preview").addClass("loading");
  1419. }
  1420. }
  1421. //保存译文句子 新
  1422. function note_sent_save_a(obj) {
  1423. let id = $(obj).attr("dbid");
  1424. let sid = $(obj).attr("sid").split("-");
  1425. let book = sid[0];
  1426. let para = sid[1];
  1427. let begin = sid[2];
  1428. let end = sid[3];
  1429. let channal = $(obj).attr("channel");
  1430. let text = $(obj).val();
  1431. let sent_tran_div = find_sent_tran_div(obj);
  1432. $.post(
  1433. "../usent/sent_post.php",
  1434. {
  1435. id: id,
  1436. book: book,
  1437. para: para,
  1438. begin: begin,
  1439. end: end,
  1440. channal: channal,
  1441. text: text,
  1442. lang: "zh",
  1443. },
  1444. sent_save_callback
  1445. );
  1446. if (sent_tran_div) {
  1447. $(sent_tran_div).find(".preview").addClass("loading");
  1448. }
  1449. }
  1450. function update_sent_tran(sentData) {}
  1451. function sent_save_callback(data) {
  1452. let result = JSON.parse(data);
  1453. if (result.status > 0) {
  1454. alert("error" + result.message);
  1455. } else {
  1456. let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
  1457. let sent_tran_div = $(
  1458. ".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
  1459. );
  1460. if (result.commit_type == 1 || result.commit_type == 2) {
  1461. ntf_show("成功修改");
  1462. if (sent_tran_div) {
  1463. let divPreview = sent_tran_div.find(".preview").first();
  1464. if (result.text == "") {
  1465. let channel_info = "Empty";
  1466. let thisChannel = find_channal(result.channal);
  1467. if (thisChannel) {
  1468. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1469. }
  1470. divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1471. } else {
  1472. divPreview.html(
  1473. marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
  1474. );
  1475. term_updata_translation();
  1476. popup_init();
  1477. for (const iterator of _arrData) {
  1478. if (
  1479. iterator.book == result.book &&
  1480. iterator.para == result.para &&
  1481. iterator.begin == result.begin &&
  1482. iterator.end == result.end
  1483. ) {
  1484. for (const tran of iterator.translation) {
  1485. if (tran.channal == result.channal) {
  1486. tran.text = result.text;
  1487. break;
  1488. }
  1489. }
  1490. }
  1491. }
  1492. }
  1493. sent_tran_div.find(".preview").removeClass("loading");
  1494. }
  1495. } else if (result.commit_type == 3) {
  1496. ntf_show("已经提交修改建议");
  1497. } else {
  1498. ntf_show("未提交");
  1499. }
  1500. }
  1501. }
  1502. //保存译文句子
  1503. function note_sent_save() {
  1504. let id = $("#edit_dialog_text").attr("sent_id");
  1505. let book = $("#edit_dialog_text").attr("book");
  1506. let para = $("#edit_dialog_text").attr("para");
  1507. let begin = $("#edit_dialog_text").attr("begin");
  1508. let end = $("#edit_dialog_text").attr("end");
  1509. let channal = $("#edit_dialog_text").attr("channal");
  1510. let text = $("#edit_dialog_text").val();
  1511. $.post(
  1512. "../usent/sent_post.php",
  1513. {
  1514. id: id,
  1515. book: book,
  1516. para: para,
  1517. begin: begin,
  1518. end: end,
  1519. channal: channal,
  1520. text: text,
  1521. lang: "zh",
  1522. },
  1523. function (data) {
  1524. let result = JSON.parse(data);
  1525. if (result.status > 0) {
  1526. alert("error" + result.message);
  1527. } else {
  1528. if (result.commit_type == 1 || result.commit_type == 2) {
  1529. ntf_show("成功修改");
  1530. if (result.text == "") {
  1531. let channel_info = "Empty";
  1532. let thisChannel = find_channal(result.channal);
  1533. if (thisChannel) {
  1534. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1535. }
  1536. $(
  1537. "#tran_text_" +
  1538. result.book +
  1539. "_" +
  1540. result.para +
  1541. "_" +
  1542. result.begin +
  1543. "_" +
  1544. result.end +
  1545. "_" +
  1546. result.channal
  1547. ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1548. } else {
  1549. $(
  1550. "#tran_text_" +
  1551. result.book +
  1552. "_" +
  1553. result.para +
  1554. "_" +
  1555. result.begin +
  1556. "_" +
  1557. result.end +
  1558. "_" +
  1559. result.channal
  1560. ).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
  1561. term_updata_translation();
  1562. for (const iterator of _arrData) {
  1563. if (
  1564. iterator.book == result.book &&
  1565. iterator.para == result.para &&
  1566. iterator.begin == result.begin &&
  1567. iterator.end == result.end
  1568. ) {
  1569. for (const tran of iterator.translation) {
  1570. if (tran.channal == result.channal) {
  1571. tran.text = result.text;
  1572. break;
  1573. }
  1574. }
  1575. }
  1576. }
  1577. }
  1578. } else if (result.commit_type == 3) {
  1579. ntf_show("已经提交修改建议");
  1580. } else {
  1581. ntf_show("未提交");
  1582. }
  1583. }
  1584. }
  1585. );
  1586. }
  1587. function copy_ref(book, para, begin, end) {
  1588. let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
  1589. copy_to_clipboard(strRef);
  1590. }
  1591. function goto_nissaya(book, para, begin = 0, end = 0) {
  1592. window.open("../nissaya/index.php?book=" + book + "&para=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
  1593. }
  1594. function edit_in_studio(book, para, begin, end) {
  1595. wbw_channal_list_open(book, [para]);
  1596. }
  1597. //显示和隐藏某个内容 如 巴利文
  1598. function setVisibility(key, value) {
  1599. switch (key) {
  1600. case "palitext":
  1601. if ($(value).is(":checked")) {
  1602. $(".palitext").show();
  1603. } else {
  1604. $(".palitext").hide();
  1605. }
  1606. break;
  1607. default:
  1608. break;
  1609. }
  1610. }
  1611. function note_show_pali_sim(SentId) {
  1612. pali_sim_dlg_open(SentId, 0, 20);
  1613. }
  1614. function set_pali_script(pos, script) {
  1615. if (script == "none") {
  1616. $(".palitext" + pos).html("");
  1617. } else {
  1618. $(".palitext" + pos).each(function () {
  1619. let html = $(this).siblings(".palitext_roma").first().html();
  1620. $(this).html(html);
  1621. });
  1622. $(".palitext" + pos)
  1623. .find("*")
  1624. .contents()
  1625. .filter(function () {
  1626. return this.nodeType != 1;
  1627. })
  1628. .wrap("<pl" + pos + "></pl" + pos + ">");
  1629. $(".palitext" + pos)
  1630. .contents()
  1631. .filter(function () {
  1632. return this.nodeType != 1;
  1633. })
  1634. .wrap("<pl" + pos + "></pl" + pos + ">");
  1635. $("pl" + pos).html(function (index, oldcontent) {
  1636. return roman_to_my(oldcontent);
  1637. });
  1638. }
  1639. }
  1640. function splite_pali_word() {
  1641. $("pali")
  1642. .contents()
  1643. .filter(function () {
  1644. return this.nodeType != 1;
  1645. })
  1646. .wrap("<pl></pl>");
  1647. $("pl").each(function () {
  1648. let html = $(this).html();
  1649. $(this).html("<w>" + html.replace(/\s/g, "</w> <w>") + "</w>");
  1650. });
  1651. $("w").click(function () {
  1652. let word = com_getPaliReal($(this).text());
  1653. if (gBuildinDictIsOpen) {
  1654. window.open("../dict/index.php?builtin=true&key=" + word, "dict");
  1655. }
  1656. });
  1657. }
  1658. function refresh_pali_script() {
  1659. if (_display && _display == "para") {
  1660. //段落模式
  1661. } else {
  1662. //句子模式
  1663. setting_get("lib.second_script", set_second_scrip);
  1664. }
  1665. }
  1666. function set_second_scrip(value) {
  1667. set_pali_script(2, value);
  1668. }
  1669. function slider_show(obj) {
  1670. $(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
  1671. }
  1672. function find_sent_tran_div(obj) {
  1673. let jqObj = $(obj);
  1674. while (!jqObj.hasClass("sent_tran")) {
  1675. jqObj = jqObj.parent();
  1676. if (!jqObj) {
  1677. return false;
  1678. }
  1679. }
  1680. return jqObj;
  1681. /*
  1682. let parent = obj.parentNode;
  1683. while (parent.nodeType == 1) {
  1684. if ($(parent).hasClass("sent_tran")) {
  1685. return parent;
  1686. } else if (parent.nodeName == "BODY") {
  1687. return false;
  1688. }
  1689. parent = parent.parentNode;
  1690. }
  1691. return false;
  1692. */
  1693. }
  1694. //显示或隐藏pr数据
  1695. function note_pr_show(channel, id) {
  1696. let obj = $(".sent_tran[channel='" + channel + "'][sid='" + id + "']").find(".pr_content");
  1697. let prHtml = obj.first().html();
  1698. if (prHtml == "") {
  1699. note_get_pr(channel, id);
  1700. } else {
  1701. obj.slideUp();
  1702. obj.html("");
  1703. }
  1704. }
  1705. //获取pr数据并显示
  1706. function note_get_pr(channel, id) {
  1707. let sid = id.split("-");
  1708. let book = sid[0];
  1709. let para = sid[1];
  1710. let begin = sid[2];
  1711. let end = sid[3];
  1712. $.post(
  1713. "../usent/get_pr.php",
  1714. {
  1715. book: book,
  1716. para: para,
  1717. begin: begin,
  1718. end: end,
  1719. channel: channel,
  1720. },
  1721. function (data) {
  1722. let result = JSON.parse(data);
  1723. if (result.length > 0) {
  1724. let html = "<div class='compact'>";
  1725. for (const iterator of result) {
  1726. html += render_one_sent_tran_a(iterator);
  1727. }
  1728. html += "</div>";
  1729. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1730. .find(".pr_content")
  1731. .html(html);
  1732. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1733. .find(".pr_content")
  1734. .slideDown();
  1735. } else {
  1736. }
  1737. }
  1738. );
  1739. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1740. .find(".pr_content")
  1741. .html("loading");
  1742. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1743. .find(".pr_content")
  1744. .show();
  1745. }
  1746. function get_channel_by_id(id) {
  1747. if (typeof _channalData != "undefined") {
  1748. for (const iterator of _channalData) {
  1749. if (iterator.id == id) {
  1750. return iterator;
  1751. }
  1752. }
  1753. }
  1754. if (typeof _my_channal != "undefined") {
  1755. for (const iterator of _my_channal) {
  1756. if (iterator.id == id) {
  1757. return iterator;
  1758. }
  1759. }
  1760. }
  1761. return false;
  1762. }
  1763. //设置显示方向
  1764. function setDirection(obj) {
  1765. if (obj.value == "row") {
  1766. $("#contents").removeClass("vertical");
  1767. $("#contents").addClass("horizontal");
  1768. } else {
  1769. $("#contents").removeClass("horizontal");
  1770. $("#contents").addClass("vertical");
  1771. }
  1772. }
  1773. //设置逐段或逐句模式
  1774. function setDisplay(obj) {
  1775. if (obj.value == "para") {
  1776. $("#contents").removeClass("sent_mode");
  1777. $("#contents").addClass("para_mode");
  1778. } else {
  1779. $("#contents").removeClass("para_mode");
  1780. $("#contents").addClass("sent_mode");
  1781. }
  1782. }