note.js 53 KB

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