note.js 59 KB

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