note.js 59 KB

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