note.js 59 KB

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