note.js 45 KB

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