note.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586
  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)'>+" + 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 += "<span class='other_tran_span' >" + gLocal.gui.other + gLocal.gui.translation + "</span>";
  534. output += "<span class='other_tran_num'></span>";
  535. output += "</span>";
  536. output += "<span class='separate_line'></span>";
  537. //手工义注
  538. output += "<span class='other_bar' >";
  539. output += "<span class='other_tran_span commentray' >commentray</span>";
  540. output += "<span class='other_tran_num'></span>";
  541. output += "</span>";
  542. output += "<span class='separate_line'></span>";
  543. //第三个按钮 相似句
  544. if (parseInt(in_json.sim) > 0) {
  545. output += "<span class='other_bar' >";
  546. output +=
  547. "<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
  548. in_json.pali_sent_id +
  549. "')\">" +
  550. gLocal.gui.similar_sentences +
  551. "</span>";
  552. output += "<span class='similar_sent_num'>" + in_json.sim + "</span>";
  553. output += "</span>";
  554. }
  555. //第三个按钮 相似句结束
  556. output += "</span>";
  557. output += "<span class='tool_right'>";
  558. //出处路径开始
  559. output += "<span class='ref'>" + in_json.ref;
  560. output += "<span class='sent_no'>";
  561. output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
  562. output += "<span>";
  563. output += "</span>";
  564. //出处路径结束
  565. output += "</span>";
  566. output += "</div>";
  567. //工具栏结束
  568. //未选择的其他译文开始
  569. output += "<div class='other_tran'>";
  570. output += "</div>";
  571. output += "</div>";
  572. return output;
  573. }
  574. function sent_tran_edit(obj) {
  575. let jqObj = $(obj);
  576. while (!jqObj.hasClass("sent_tran")) {
  577. jqObj = jqObj.parent();
  578. if (!jqObj) {
  579. return;
  580. }
  581. }
  582. if (jqObj.hasClass("edit_mode")) {
  583. jqObj.removeClass("edit_mode");
  584. } else {
  585. $(".sent_tran").removeClass("edit_mode");
  586. jqObj.addClass("edit_mode");
  587. }
  588. }
  589. function sent_pr_merge(id) {
  590. $.post(
  591. "../usent/sent_pr_merge.php",
  592. {
  593. id: id,
  594. },
  595. function (data) {
  596. let result = JSON.parse(data);
  597. if (result.status > 0) {
  598. alert("error" + result.message);
  599. } else {
  600. ntf_show("成功采纳");
  601. }
  602. }
  603. );
  604. }
  605. function sent_commit(src, id) {
  606. commit_init({
  607. src: src,
  608. sent: [id],
  609. express: true,
  610. });
  611. }
  612. function render_one_sent_tran_a(iterator) {
  613. let mChannel = get_channel_by_id(iterator.channal);
  614. let tranText;
  615. let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
  616. if (iterator.text == "") {
  617. tranText =
  618. "<span style='color:var(--border-line-color);'>" +
  619. iterator.channalinfo.name +
  620. "-" +
  621. iterator.channalinfo.lang +
  622. "</span>";
  623. } else {
  624. //note_init处理句子链接
  625. tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  626. }
  627. let html = "";
  628. html += "<div class='sent_tran ";
  629. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  630. html += " pr ";
  631. }
  632. html += "' dbid='" + iterator.id + "' channel='" + iterator.channal + "' sid='" + sid + "'>";
  633. html += "<div class='sent_tran_inner'>";
  634. html += '<div class="tool_bar">';
  635. html += ' <div class="right">';
  636. //句子菜单
  637. html += '<div class="pop_menu">';
  638. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  639. //在pr 列表中的译文
  640. if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
  641. //提交人
  642. //修改按钮
  643. html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
  644. html += '<svg class="icon" >';
  645. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
  646. html += "</svg>";
  647. html += "<span class='tooltiptext tooltip-top'>";
  648. html += gLocal.gui.modify;
  649. html += "</span>";
  650. html += "</button>";
  651. //删除按钮
  652. html += "<button class='icon_btn tooltip' onclick='sent_pr_del(this)'>";
  653. html += '<svg class="icon" >';
  654. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_delete"></use>';
  655. html += "</svg>";
  656. html += "<span class='tooltiptext tooltip-top'>";
  657. html += gLocal.gui.delete;
  658. html += "</span>";
  659. html += "</button>";
  660. } else {
  661. //非提交人
  662. if (parseInt(iterator.mypower) >= 20) {
  663. //有权限 采纳按钮
  664. html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
  665. html += '<svg class="icon" >';
  666. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#accept_copy"></use>';
  667. html += "</svg>";
  668. html += "<span class='tooltiptext tooltip-top'>";
  669. html += gLocal.gui.accept_copy;
  670. html += "</span>";
  671. html += "</button>";
  672. }
  673. //点赞按钮
  674. html += "<button class='icon_btn tooltip' onclick='sent_pr_like(this)'>";
  675. html += '<svg class="icon" >';
  676. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
  677. html += "</svg>";
  678. html += "<span class='tooltiptext tooltip-top'>";
  679. html += gLocal.gui.like;
  680. html += "</span>";
  681. html += "</button>";
  682. }
  683. } else {
  684. //非pr列表里的句子
  685. //编辑按钮
  686. html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
  687. html += '<svg class="icon" >';
  688. if (parseInt(iterator.mypower) < 20) {
  689. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#my_idea"></use>';
  690. } else {
  691. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
  692. }
  693. html += "</svg>";
  694. html += "<span class='tooltiptext tooltip-top'>";
  695. if (parseInt(iterator.mypower) < 20) {
  696. html += "建议";
  697. } else {
  698. html += gLocal.gui.edit;
  699. }
  700. html += "</span>";
  701. html += "</button>";
  702. //推送按钮
  703. let commitIcon = "";
  704. let commitTipText = "";
  705. if (parseInt(iterator.mypower) >= 30 && parseInt(iterator.status) < 30) {
  706. //我的私有资源 公开发布
  707. commitIcon = "publish";
  708. commitTipText = gLocal.gui.publish;
  709. } else {
  710. if (parseInt(iterator.mypower) < 20) {
  711. //只读资源 采纳
  712. commitIcon = "accept_copy";
  713. commitTipText = gLocal.gui.accept_copy;
  714. } else {
  715. //其他资源 复制到
  716. commitIcon = "copy";
  717. commitTipText = gLocal.gui.copy_to;
  718. }
  719. }
  720. html += "<button class='icon_btn tooltip' ";
  721. html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
  722. html += '<svg class="icon" >';
  723. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + commitIcon + '"></use>';
  724. html += "</svg>";
  725. html += "<span class='tooltiptext tooltip-top'>";
  726. html += commitTipText;
  727. html += "</span>";
  728. html += "</button>";
  729. //推送按钮结束
  730. //更多按钮
  731. html += '<div class="case_dropdown">';
  732. html += "<button class='icon_btn'>";
  733. html += '<svg class="icon" >';
  734. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_more"></use>';
  735. html += "</svg>";
  736. html += "</button>";
  737. html += '<div class="case_dropdown-content menu_space_between" style="right:0;">';
  738. //时间线
  739. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  740. html += "<span>" + gLocal.gui.timeline + "</span>";
  741. html += '<svg class="icon" >';
  742. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use>';
  743. html += "</svg>";
  744. html += "</a>";
  745. //复制
  746. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  747. html += "<span>" + gLocal.gui.copy + "</span>";
  748. html += '<svg class="icon" >';
  749. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use>';
  750. html += "</svg>";
  751. html += "</a>";
  752. //点赞
  753. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  754. html += "<span>" + gLocal.gui.like + "</span>";
  755. html += '<svg class="icon" >';
  756. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
  757. html += "</svg>";
  758. html += "</a>";
  759. //分享
  760. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  761. html += "<span>" + gLocal.gui.share_to + "</span>";
  762. html += '<svg class="icon" >';
  763. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use>';
  764. html += "</svg>";
  765. html += "</a>";
  766. html += "</div>";
  767. html += "</div>";
  768. //更多按钮结束
  769. }
  770. html += "</div>";
  771. //句子菜单结束
  772. html += "</div>";
  773. html += "</div>";
  774. //tool_bar 结束
  775. html += '<div class="left_bar" >';
  776. html += ' <div class="face">';
  777. if (iterator.id != "") {
  778. html += '<span class="head_img">' + iterator.editor_name.nickname.slice(0, 1) + "</span>";
  779. }
  780. html += "</div>";
  781. html += '<div class="date">' + getPassDataTime(iterator.update_time) + "</div>";
  782. html += "</div>";
  783. html += '<div class="body">';
  784. html += '<div class="head_bar">';
  785. html += '<div class="info">';
  786. html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
  787. html += '<span class="date">' + getPassDataTime(iterator.update_time) + "</span>";
  788. html += "</div>";
  789. html += "<div class='preview'>" + tranText + "</div>";
  790. html += "</div>";
  791. html += '<div class="edit">';
  792. html += '<div class="input">';
  793. html += "<textarea dbid='" + iterator.id + "' ";
  794. html += "sid='" + sid + "' ";
  795. html += "channel='" + iterator.channal + "' ";
  796. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  797. html += 'onchange="note_pr_save(this)"';
  798. } else {
  799. html += 'onchange="note_sent_save_a(this)"';
  800. }
  801. html += ">" + iterator.text + "</textarea>";
  802. html += "</div>";
  803. html += '<div class="edit_tool">';
  804. if (parseInt(iterator.mypower) < 20) {
  805. html += "<b>提交修改建议</b> ";
  806. }
  807. html += "点击输入框外面自动<a onclick='sent_tran_edit(this)'>" + gLocal.gui.save + "</a> 支持markdown语法";
  808. html += "</div>";
  809. html += "</div>";
  810. html += '<div class="foot_bar">';
  811. html += '<div class="info">';
  812. if (iterator.id != "") {
  813. html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
  814. }
  815. if (iterator.id != "") {
  816. html += '<span class="date"> ' + getPassDataTime(iterator.update_time) + "</span>";
  817. }
  818. if (iterator.id != "") {
  819. html += '<span class="channel">' + gLocal.gui.updated + " @" + iterator.channalinfo.name + "</span>";
  820. } else {
  821. html += '<span class="channel">' + gLocal.gui.no_updated + " @" + iterator.channalinfo.name + "</span>";
  822. }
  823. html += '<ul class="tag_list">';
  824. if (iterator.pr_all && parseInt(iterator.pr_all) > 0) {
  825. html +=
  826. " <li onclick=\"note_pr_show('" +
  827. iterator.channal +
  828. "','" +
  829. sid +
  830. "')\"><span class='icon'>✋</span><span class='num'>" +
  831. iterator.pr_new +
  832. "/" +
  833. iterator.pr_all +
  834. "</span></li>";
  835. }
  836. html += "</ul>";
  837. html += "</div>"; //end of info
  838. html += "</div>"; //end of foot bar
  839. html += "</div>";
  840. html += "</div>";
  841. //sent_tran_inner结束
  842. html += '<div class="pr_content"></div>';
  843. html += "</div>";
  844. return html;
  845. }
  846. function render_one_sent_tran(book, para, begin, end, iterator) {
  847. let output = "";
  848. output += "<div class='tran' lang='" + iterator.lang + "' style='display:flex;'>";
  849. //译文工具按钮开始
  850. output += "<div class='tran_text_tool_botton' onclick='tool_bar_show(this)'>";
  851. output +=
  852. "<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>";
  853. //译文工具栏开始
  854. output += "<div class='tran_text_tool_bar'>";
  855. output += "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom' ";
  856. output +=
  857. " onclick=\"note_edit_sentence('" +
  858. book +
  859. "' ,'" +
  860. para +
  861. "' ,'" +
  862. begin +
  863. "' ,'" +
  864. end +
  865. "' ,'" +
  866. iterator.channal +
  867. "')\"";
  868. output +=
  869. ">" +
  870. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use></svg>';
  871. output += gLocal.gui.edit + "</li>";
  872. output += "<li class = 'tip_buttom' ";
  873. output += " onclick=\"history_show('" + iterator.id + "')\" >";
  874. output +=
  875. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use></svg>';
  876. output += gLocal.gui.timeline + "</li>";
  877. output +=
  878. "<li class = 'tip_buttom'>" +
  879. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use></svg>';
  880. output += gLocal.gui.copy + "</li></div>";
  881. output +=
  882. "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  883. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use></svg>';
  884. output += gLocal.gui.like + "</li>";
  885. output +=
  886. "<li class = 'tip_buttom'>" +
  887. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#comment"></use></svg>';
  888. output += gLocal.gui.comment + "</li>";
  889. output +=
  890. "<li class = 'tip_buttom'>" +
  891. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_shopping_cart"></use></svg>';
  892. output += gLocal.gui.digest + "</li></div>";
  893. output +=
  894. "<div style='margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  895. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use></svg>';
  896. output += gLocal.gui.share_to + "</li>";
  897. output += "</div></div>";
  898. //译文工具栏结束
  899. output += "</div>";
  900. //译文工具按钮结束
  901. //译文正文开始
  902. output +=
  903. "<div class='text' id='tran_text_" +
  904. book +
  905. "_" +
  906. para +
  907. "_" +
  908. begin +
  909. "_" +
  910. end +
  911. "_" +
  912. iterator.channal +
  913. "'>";
  914. if (iterator.text == "") {
  915. output +=
  916. "<span style='color:var(--border-line-color);'>" +
  917. iterator.channalinfo.name +
  918. "-" +
  919. iterator.channalinfo.lang +
  920. "</span>";
  921. } else {
  922. //note_init处理句子链接
  923. output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  924. }
  925. output += "</div>";
  926. //译文正文结束
  927. output += "</div>";
  928. //单个channal译文框结束
  929. return output;
  930. }
  931. function add_new_tran_button_click(obj) {
  932. let html = "<ul>";
  933. for (const iterator of _my_channal) {
  934. if (iterator.status > 0) {
  935. if (_channal.indexOf(iterator.id) < 0) {
  936. html += '<li onclick="';
  937. html +=
  938. "new_sentence('" +
  939. $(obj).parent().attr("book") +
  940. "' ,'" +
  941. $(obj).parent().attr("para") +
  942. "' ,'" +
  943. $(obj).parent().attr("begin") +
  944. "' ,'" +
  945. $(obj).parent().attr("end") +
  946. "' ,'" +
  947. iterator.id +
  948. "',this)";
  949. html += '">' + iterator.name;
  950. if (parseInt(iterator.power) < 20) {
  951. html += "(建议)";
  952. }
  953. html += "</li>";
  954. }
  955. }
  956. }
  957. html += "</ul>";
  958. $(obj).parent().children(".tran_text_tool_bar").first().html(html);
  959. if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
  960. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  961. } else {
  962. $(obj).parent().children(".tran_text_tool_bar").first().show();
  963. $(document).one("click", function () {
  964. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  965. });
  966. event.stopPropagation();
  967. $(obj).parent().show();
  968. }
  969. }
  970. function tool_bar_show(element) {
  971. if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
  972. $(element).find(".tran_text_tool_bar").css("display", "flex");
  973. $(element).find(".icon_expand").css("transform", "rotate(-180deg)");
  974. $(element).css("background-color", "var(--btn-bg-color)");
  975. $(element).css("visibility", "visible");
  976. $(document).one("click", function () {
  977. $(element).find(".tran_text_tool_bar").hide();
  978. $(element).css("background-color", "var(--nocolor)");
  979. $(element).find(".icon_expand").css("transform", "unset");
  980. $(element).css("visibility", "");
  981. });
  982. event.stopPropagation();
  983. } else {
  984. $(element).find(".tran_text_tool_bar").hide();
  985. $(element).css("background-color", "var(--nocolor)");
  986. $(element).find(".icon_expand").css("transform", "unset");
  987. $(element).css("visibility", "");
  988. }
  989. }
  990. function new_sentence(book, para, begin, end, channel, obj) {
  991. let newsent = { id: "", text: "", lang: "", channal: channel };
  992. for (let iterator of _arrData) {
  993. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  994. let found = false;
  995. for (const tran of iterator.translation) {
  996. if (tran.channal == channel) {
  997. found = true;
  998. break;
  999. }
  1000. }
  1001. if (!found) {
  1002. iterator.translation.push(newsent);
  1003. }
  1004. }
  1005. }
  1006. if ($(obj).parent().parent().css("display") == "block") {
  1007. $(obj).parent().parent().hide();
  1008. }
  1009. note_edit_sentence(book, para, begin, end, channel);
  1010. }
  1011. //显示更多译文按钮动作
  1012. function set_more_button_display() {
  1013. $(".other_tran_div").each(function () {
  1014. const sentid = $(this).attr("sent").split("-");
  1015. const book = sentid[0];
  1016. const para = sentid[1];
  1017. const begin = sentid[2];
  1018. const end = sentid[3];
  1019. let count = 0;
  1020. for (const iterator of _channalData) {
  1021. if (iterator.final) {
  1022. for (const onesent of iterator.final) {
  1023. let id = onesent.id.split("-");
  1024. if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
  1025. if (_channal.indexOf(iterator.id) == -1) {
  1026. count++;
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. if (count > 0) {
  1033. $(this).find(".other_tran_num").html(count);
  1034. $(this).find(".other_tran_num").attr("style", "display:inline-flex;");
  1035. $(this)
  1036. .find(".other_bar")
  1037. .click(function () {
  1038. const sentid = $(this).parent().parent().attr("sent").split("-");
  1039. const book = sentid[0];
  1040. const para = sentid[1];
  1041. const begin = sentid[2];
  1042. const end = sentid[3];
  1043. let sentId = $(this).parent().parent().attr("sent");
  1044. if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
  1045. $(".other_tran_div[sent='" + sentId + "']")
  1046. .children(".other_tran")
  1047. .slideDown();
  1048. $(this).siblings(".more_tran ").css("transform", "unset");
  1049. $.get(
  1050. "../usent/get.php",
  1051. {
  1052. book: book,
  1053. para: para,
  1054. begin: begin,
  1055. end: end,
  1056. },
  1057. function (data, status) {
  1058. let arrSent = JSON.parse(data);
  1059. let html = "<div class='compact'>";
  1060. for (const iterator of arrSent) {
  1061. if (_channal.indexOf(iterator.channal) == -1) {
  1062. html += render_one_sent_tran_a(iterator);
  1063. //html += "<div>" + marked(iterator.text) + "</div>";
  1064. }
  1065. }
  1066. html += "</div>";
  1067. let sentId =
  1068. arrSent[0].book +
  1069. "-" +
  1070. arrSent[0].paragraph +
  1071. "-" +
  1072. arrSent[0].begin +
  1073. "-" +
  1074. arrSent[0].end;
  1075. $(".other_tran_div[sent='" + sentId + "']")
  1076. .children(".other_tran")
  1077. .html(html);
  1078. }
  1079. );
  1080. } else {
  1081. $(".other_tran_div[sent='" + sentId + "']")
  1082. .children(".other_tran")
  1083. .slideUp();
  1084. $(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
  1085. }
  1086. });
  1087. } else {
  1088. //隐藏自己
  1089. //$(this).hide();
  1090. $(this)
  1091. .find(".other_tran_span")
  1092. .html(gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation);
  1093. //$(this).find(".more_tran").hide();
  1094. }
  1095. });
  1096. }
  1097. function note_edit_sentence(book, para, begin, end, channal) {
  1098. let channalInfo;
  1099. for (const iterator of _channalData) {
  1100. if (iterator.id == channal) {
  1101. channalInfo = iterator;
  1102. break;
  1103. }
  1104. }
  1105. for (const iterator of _arrData) {
  1106. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1107. for (const tran of iterator.translation) {
  1108. if (tran.channal == channal) {
  1109. let html = "";
  1110. html += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
  1111. html +=
  1112. "<textarea id='edit_dialog_text' sent_id='" +
  1113. tran.id +
  1114. "' book='" +
  1115. book +
  1116. "' para='" +
  1117. para +
  1118. "' begin='" +
  1119. begin +
  1120. "' end='" +
  1121. end +
  1122. "' channal='" +
  1123. channal +
  1124. "' style='width:100%;min-height:260px;'>" +
  1125. tran.text +
  1126. "</textarea>";
  1127. $("#edit_dialog_content").html(html);
  1128. $("#note_sent_edit_dlg").dialog("open");
  1129. return;
  1130. }
  1131. }
  1132. }
  1133. }
  1134. alert("未找到句子");
  1135. }
  1136. function update_note_sent_tran(obj) {}
  1137. //保存pr句子 新
  1138. function note_pr_save(obj) {
  1139. let id = $(obj).attr("dbid");
  1140. let sid = $(obj).attr("sid").split("-");
  1141. let book = sid[0];
  1142. let para = sid[1];
  1143. let begin = sid[2];
  1144. let end = sid[3];
  1145. let channel = $(obj).attr("channel");
  1146. let text = $(obj).val();
  1147. let sent_tran_div = find_sent_tran_div(obj);
  1148. $.post(
  1149. "../usent/pr_post.php",
  1150. {
  1151. id: id,
  1152. book: book,
  1153. para: para,
  1154. begin: begin,
  1155. end: end,
  1156. channel: channel,
  1157. text: text,
  1158. },
  1159. sent_save_callback
  1160. );
  1161. if (sent_tran_div) {
  1162. $(sent_tran_div).find(".preview").addClass("loading");
  1163. }
  1164. }
  1165. //保存译文句子 新
  1166. function note_sent_save_a(obj) {
  1167. let id = $(obj).attr("dbid");
  1168. let sid = $(obj).attr("sid").split("-");
  1169. let book = sid[0];
  1170. let para = sid[1];
  1171. let begin = sid[2];
  1172. let end = sid[3];
  1173. let channal = $(obj).attr("channel");
  1174. let text = $(obj).val();
  1175. let sent_tran_div = find_sent_tran_div(obj);
  1176. $.post(
  1177. "../usent/sent_post.php",
  1178. {
  1179. id: id,
  1180. book: book,
  1181. para: para,
  1182. begin: begin,
  1183. end: end,
  1184. channal: channal,
  1185. text: text,
  1186. lang: "zh",
  1187. },
  1188. sent_save_callback
  1189. );
  1190. if (sent_tran_div) {
  1191. $(sent_tran_div).find(".preview").addClass("loading");
  1192. }
  1193. }
  1194. function sent_save_callback(data) {
  1195. let result = JSON.parse(data);
  1196. if (result.status > 0) {
  1197. alert("error" + result.message);
  1198. } else {
  1199. let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
  1200. let sent_tran_div = $(
  1201. ".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
  1202. );
  1203. if (result.commit_type == 1 || result.commit_type == 2) {
  1204. ntf_show("成功修改");
  1205. if (sent_tran_div) {
  1206. let divPreview = sent_tran_div.find(".preview").first();
  1207. if (result.text == "") {
  1208. let channel_info = "Empty";
  1209. let thisChannel = find_channal(result.channal);
  1210. if (thisChannel) {
  1211. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1212. }
  1213. divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1214. } else {
  1215. divPreview.html(
  1216. marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
  1217. );
  1218. term_updata_translation();
  1219. popup_init();
  1220. for (const iterator of _arrData) {
  1221. if (
  1222. iterator.book == result.book &&
  1223. iterator.para == result.para &&
  1224. iterator.begin == result.begin &&
  1225. iterator.end == result.end
  1226. ) {
  1227. for (const tran of iterator.translation) {
  1228. if (tran.channal == result.channal) {
  1229. tran.text = result.text;
  1230. break;
  1231. }
  1232. }
  1233. }
  1234. }
  1235. }
  1236. sent_tran_div.find(".preview").removeClass("loading");
  1237. }
  1238. } else if (result.commit_type == 3) {
  1239. ntf_show("已经提交修改建议");
  1240. } else {
  1241. ntf_show("未提交");
  1242. }
  1243. }
  1244. }
  1245. //保存译文句子
  1246. function note_sent_save() {
  1247. let id = $("#edit_dialog_text").attr("sent_id");
  1248. let book = $("#edit_dialog_text").attr("book");
  1249. let para = $("#edit_dialog_text").attr("para");
  1250. let begin = $("#edit_dialog_text").attr("begin");
  1251. let end = $("#edit_dialog_text").attr("end");
  1252. let channal = $("#edit_dialog_text").attr("channal");
  1253. let text = $("#edit_dialog_text").val();
  1254. $.post(
  1255. "../usent/sent_post.php",
  1256. {
  1257. id: id,
  1258. book: book,
  1259. para: para,
  1260. begin: begin,
  1261. end: end,
  1262. channal: channal,
  1263. text: text,
  1264. lang: "zh",
  1265. },
  1266. function (data) {
  1267. let result = JSON.parse(data);
  1268. if (result.status > 0) {
  1269. alert("error" + result.message);
  1270. } else {
  1271. if (result.commit_type == 1 || result.commit_type == 2) {
  1272. ntf_show("成功修改");
  1273. if (result.text == "") {
  1274. let channel_info = "Empty";
  1275. let thisChannel = find_channal(result.channal);
  1276. if (thisChannel) {
  1277. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1278. }
  1279. $(
  1280. "#tran_text_" +
  1281. result.book +
  1282. "_" +
  1283. result.para +
  1284. "_" +
  1285. result.begin +
  1286. "_" +
  1287. result.end +
  1288. "_" +
  1289. result.channal
  1290. ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1291. } else {
  1292. $(
  1293. "#tran_text_" +
  1294. result.book +
  1295. "_" +
  1296. result.para +
  1297. "_" +
  1298. result.begin +
  1299. "_" +
  1300. result.end +
  1301. "_" +
  1302. result.channal
  1303. ).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
  1304. term_updata_translation();
  1305. for (const iterator of _arrData) {
  1306. if (
  1307. iterator.book == result.book &&
  1308. iterator.para == result.para &&
  1309. iterator.begin == result.begin &&
  1310. iterator.end == result.end
  1311. ) {
  1312. for (const tran of iterator.translation) {
  1313. if (tran.channal == result.channal) {
  1314. tran.text = result.text;
  1315. break;
  1316. }
  1317. }
  1318. }
  1319. }
  1320. }
  1321. } else if (result.commit_type == 3) {
  1322. ntf_show("已经提交修改建议");
  1323. } else {
  1324. ntf_show("未提交");
  1325. }
  1326. }
  1327. }
  1328. );
  1329. }
  1330. function copy_ref(book, para, begin, end) {
  1331. let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
  1332. copy_to_clipboard(strRef);
  1333. }
  1334. function goto_nissaya(book, para, begin = 0, end = 0) {
  1335. window.open("../nissaya/index.php?book=" + book + "&para=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
  1336. }
  1337. function edit_in_studio(book, para, begin, end) {
  1338. wbw_channal_list_open(book, [para]);
  1339. }
  1340. //显示和隐藏某个内容 如 巴利文
  1341. function setVisibility(key, value) {
  1342. switch (key) {
  1343. case "palitext":
  1344. if ($(value).is(":checked")) {
  1345. $(".palitext").show();
  1346. } else {
  1347. $(".palitext").hide();
  1348. }
  1349. break;
  1350. default:
  1351. break;
  1352. }
  1353. }
  1354. function note_show_pali_sim(SentId) {
  1355. pali_sim_dlg_open(SentId, 0, 20);
  1356. }
  1357. function set_pali_script(pos, script) {
  1358. if (script == "none") {
  1359. $(".palitext" + pos).html("");
  1360. } else {
  1361. $(".palitext" + pos).each(function () {
  1362. let html = $(this).siblings(".palitext_roma").first().html();
  1363. $(this).html(html);
  1364. });
  1365. $(".palitext" + pos)
  1366. .find("*")
  1367. .contents()
  1368. .filter(function () {
  1369. return this.nodeType != 1;
  1370. })
  1371. .wrap("<pl" + pos + "></pl" + pos + ">");
  1372. $(".palitext" + pos)
  1373. .contents()
  1374. .filter(function () {
  1375. return this.nodeType != 1;
  1376. })
  1377. .wrap("<pl" + pos + "></pl" + pos + ">");
  1378. $("pl" + pos).html(function (index, oldcontent) {
  1379. return roman_to_my(oldcontent);
  1380. });
  1381. }
  1382. }
  1383. function splite_pali_word() {
  1384. $("pali")
  1385. .contents()
  1386. .filter(function () {
  1387. return this.nodeType != 1;
  1388. })
  1389. .wrap("<pl></pl>");
  1390. $("pl").each(function () {
  1391. let html = $(this).html();
  1392. $(this).html("<w>" + html.replace(/\s/g, "</w> <w>") + "</w>");
  1393. });
  1394. $("w").click(function () {
  1395. let word = com_getPaliReal($(this).text());
  1396. if (gBuildinDictIsOpen) {
  1397. window.open("../dict/index.php?builtin=true&key=" + word, "dict");
  1398. }
  1399. });
  1400. }
  1401. function refresh_pali_script() {
  1402. if (_display && _display == "para") {
  1403. //段落模式
  1404. } else {
  1405. //句子模式
  1406. setting_get("lib.second_script", set_second_scrip);
  1407. }
  1408. }
  1409. function set_second_scrip(value) {
  1410. set_pali_script(2, value);
  1411. }
  1412. function slider_show(obj) {
  1413. $(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
  1414. }
  1415. function find_sent_tran_div(obj) {
  1416. let parent = obj.parentNode;
  1417. while (parent.nodeType == 1) {
  1418. if ($(parent).hasClass("sent_tran")) {
  1419. return parent;
  1420. } else if (parent.nodeName == "BODY") {
  1421. return false;
  1422. }
  1423. parent = parent.parentNode;
  1424. }
  1425. return false;
  1426. }
  1427. //显示或隐藏pr数据
  1428. function note_pr_show(channel, id) {
  1429. let obj = $(".sent_tran[channel='" + channel + "'][sid='" + id + "']").find(".pr_content");
  1430. let prHtml = obj.first().html();
  1431. if (prHtml == "") {
  1432. note_get_pr(channel, id);
  1433. } else {
  1434. obj.slideUp();
  1435. obj.html("");
  1436. }
  1437. }
  1438. //获取pr数据并显示
  1439. function note_get_pr(channel, id) {
  1440. let sid = id.split("-");
  1441. let book = sid[0];
  1442. let para = sid[1];
  1443. let begin = sid[2];
  1444. let end = sid[3];
  1445. $.post(
  1446. "../usent/get_pr.php",
  1447. {
  1448. book: book,
  1449. para: para,
  1450. begin: begin,
  1451. end: end,
  1452. channel: channel,
  1453. },
  1454. function (data) {
  1455. let result = JSON.parse(data);
  1456. if (result.length > 0) {
  1457. let html = "<div class='compact'>";
  1458. for (const iterator of result) {
  1459. html += render_one_sent_tran_a(iterator);
  1460. }
  1461. html += "</div>";
  1462. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1463. .find(".pr_content")
  1464. .html(html);
  1465. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1466. .find(".pr_content")
  1467. .slideDown();
  1468. } else {
  1469. }
  1470. }
  1471. );
  1472. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1473. .find(".pr_content")
  1474. .html("loading");
  1475. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1476. .find(".pr_content")
  1477. .show();
  1478. }
  1479. function get_channel_by_id(id) {
  1480. if (typeof _channalData != "undefined") {
  1481. for (const iterator of _channalData) {
  1482. if (iterator.id == id) {
  1483. return iterator;
  1484. }
  1485. }
  1486. }
  1487. if (typeof _my_channal != "undefined") {
  1488. for (const iterator of _my_channal) {
  1489. if (iterator.id == id) {
  1490. return iterator;
  1491. }
  1492. }
  1493. }
  1494. return false;
  1495. }