note.js 59 KB

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