note.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039
  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. //采纳 pr
  690. function sent_pr_merge(id) {
  691. $.post(
  692. "../usent/sent_pr_merge.php",
  693. {
  694. id: id,
  695. },
  696. function (data) {
  697. let result = JSON.parse(data);
  698. if (result.status > 0) {
  699. alert("error" + result.message);
  700. } else {
  701. ntf_show("成功采纳");
  702. }
  703. }
  704. );
  705. }
  706. function sent_commit(src, id) {
  707. commit_init({
  708. src: src,
  709. sent: [id],
  710. express: false,
  711. });
  712. }
  713. function render_icon_button(icon_id, event, tiptitle) {
  714. let html = "";
  715. html += "<button class='icon_btn tooltip' onclick=\"" + event + '">';
  716. html += '<svg class="icon" >';
  717. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + icon_id + '"></use>';
  718. html += "</svg>";
  719. html += "<span class='tooltiptext tooltip-top'>";
  720. html += tiptitle;
  721. html += "</span>";
  722. html += "</button>";
  723. return html;
  724. }
  725. function render_one_sent_tran_a(iterator, diff = false) {
  726. let mChannel = get_channel_by_id(iterator.channal);
  727. let tranText;
  728. let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
  729. if (iterator.text == "") {
  730. if (typeof iterator.channalinfo == "undefined") {
  731. tranText =
  732. "<span style='color:var(--border-line-color);'>" +
  733. "空" +
  734. "@" +
  735. iterator.editor_name.nickname +
  736. "</span>";
  737. } else {
  738. tranText =
  739. "<span style='color:var(--border-line-color);'>" +
  740. iterator.channalinfo.name +
  741. "-" +
  742. iterator.channalinfo.lang +
  743. "</span>";
  744. }
  745. } else {
  746. if (diff) {
  747. let orgText = "";
  748. for (const oneSent of _arrData) {
  749. if (
  750. oneSent.book == iterator.book &&
  751. oneSent.para == iterator.para &&
  752. oneSent.begin == iterator.begin &&
  753. oneSent.end == iterator.end
  754. ) {
  755. for (const tran of oneSent.translation) {
  756. if (tran.channal == iterator.channal) {
  757. orgText = tran.text;
  758. break;
  759. }
  760. }
  761. break;
  762. }
  763. }
  764. tranText = str_diff(orgText, iterator.text);
  765. } else {
  766. //note_init处理句子链接
  767. tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  768. }
  769. }
  770. let html = "";
  771. html += "<div class='sent_tran ";
  772. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  773. html += " pr ";
  774. }
  775. html += "' dbid='" + iterator.id + "' channel='" + iterator.channal + "' sid='" + sid + "'>";
  776. html += "<div class='sent_tran_inner'>";
  777. html += '<div class="tool_bar">';
  778. html += ' <div class="right">';
  779. //句子菜单
  780. html += '<div class="pop_menu">';
  781. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  782. //在pr 列表中的译文
  783. if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
  784. //提交人
  785. //修改按钮
  786. html += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.modify);
  787. //删除按钮
  788. html += render_icon_button("ic_delete", "sent_pr_del(this)", gLocal.gui.delete);
  789. } else {
  790. //非提交人
  791. if (parseInt(iterator.mypower) >= 20) {
  792. //有权限 采纳按钮
  793. html += render_icon_button(
  794. "accept_copy",
  795. "sent_pr_merge('" + iterator.id + "')",
  796. gLocal.gui.accept_copy
  797. );
  798. }
  799. //点赞按钮
  800. html += render_icon_button("like", "sent_pr_like(this)", gLocal.gui.like);
  801. }
  802. } else {
  803. //非pr列表里的句子
  804. //编辑按钮
  805. if (parseInt(iterator.mypower) < 20) {
  806. html += render_icon_button("my_idea", "sent_tran_edit(this)", gLocal.gui.suggest);
  807. } else {
  808. html += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.edit);
  809. }
  810. //推送按钮
  811. let commitIcon = "";
  812. let commitTipText = "";
  813. if (parseInt(iterator.mypower) >= 30 && parseInt(iterator.status) < 30) {
  814. //我的私有资源 公开发布
  815. commitIcon = "publish";
  816. commitTipText = gLocal.gui.publish;
  817. } else {
  818. if (parseInt(iterator.mypower) < 20) {
  819. //只读资源 采纳
  820. commitIcon = "accept_copy";
  821. commitTipText = gLocal.gui.accept_copy;
  822. } else {
  823. //其他资源 复制到
  824. commitIcon = "copy";
  825. commitTipText = gLocal.gui.copy_to;
  826. }
  827. }
  828. html += render_icon_button(commitIcon, "sent_commit('" + iterator.channal + "','" + sid + "')", commitTipText);
  829. //推送按钮结束
  830. //更多按钮
  831. html += '<div class="case_dropdown">';
  832. html += "<button class='icon_btn'>";
  833. html += '<svg class="icon" >';
  834. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_more"></use>';
  835. html += "</svg>";
  836. html += "</button>";
  837. html += '<div class="case_dropdown-content menu_space_between" style="right:0;">';
  838. //时间线
  839. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  840. html += "<span>" + gLocal.gui.timeline + "</span>";
  841. html += '<svg class="icon" >';
  842. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use>';
  843. html += "</svg>";
  844. html += "</a>";
  845. //复制
  846. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  847. html += "<span>" + gLocal.gui.copy + "</span>";
  848. html += '<svg class="icon" >';
  849. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use>';
  850. html += "</svg>";
  851. html += "</a>";
  852. //点赞
  853. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  854. html += "<span>" + gLocal.gui.like + "</span>";
  855. html += '<svg class="icon" >';
  856. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
  857. html += "</svg>";
  858. html += "</a>";
  859. //分享
  860. html += "<a onclick=\"history_show('" + iterator.id + "')\">";
  861. html += "<span>" + gLocal.gui.share_to + "</span>";
  862. html += '<svg class="icon" >';
  863. html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use>';
  864. html += "</svg>";
  865. html += "</a>";
  866. html += "</div>";
  867. html += "</div>";
  868. //更多按钮结束
  869. }
  870. html += "</div>";
  871. //句子菜单结束
  872. html += "</div>";
  873. html += "</div>";
  874. //tool_bar 结束
  875. html += '<div class="left_bar" >';
  876. html += "<span class='icon_sent_status icon_sent_loading'>";
  877. html +=
  878. "<svg class='icon icon_spin' style='fill: var(--detail-color); '>" +
  879. "<use xlink='http://www.w3.org/1999/xlink' href='../studio/svg/icon.svg#loading'></use>" +
  880. "</svg>";
  881. html += "</span>";
  882. html += "<span class='icon_sent_status icon_sent_error' title='再次发送' onclick='tran_sent_save(this)'>";
  883. html +=
  884. "<svg class='icon' style='fill: red; '>" +
  885. "<use xlink='http://www.w3.org/1999/xlink' href='../term/error.svg'></use>" +
  886. "</svg>";
  887. html += "</span>";
  888. html += ' <div class="face">';
  889. if (iterator.id != "") {
  890. html += '<span class="head_img">' + iterator.editor_name.nickname.slice(0, 1) + "</span>";
  891. }
  892. html += "</div>";
  893. html +=
  894. '<div class="date" title="' +
  895. getFullDataTime(iterator.update_time) +
  896. '">' +
  897. getDataTime(iterator.update_time) +
  898. "</div>";
  899. html += "</div>";
  900. html += '<div class="body">';
  901. html += '<div class="head_bar">';
  902. html += '<div class="info">';
  903. html += '<span class="name channel_name" title="' + iterator.editor_name.nickname + gLocal.gui.recent_update + '">';
  904. if (typeof iterator.channalinfo == "undefined") {
  905. html += "unkown";
  906. } else {
  907. html += iterator.channalinfo.name;
  908. }
  909. html += "</span>";
  910. html += '<span class="name editor_name" '
  911. if (typeof iterator.channalinfo == "undefined") {
  912. html += '>';
  913. html += "unkown";
  914. } else {
  915. html += 'title="' + iterator.channalinfo.name + gLocal.gui.recent_update + '">';
  916. html += iterator.editor_name.nickname;
  917. }
  918. html += "</span>";
  919. html += '<span class="date">' + getPassDataTime(iterator.update_time) + "</span>";
  920. html += "</div>";
  921. html += "<div class='preview'>" + tranText + "</div>";
  922. html += "</div>";
  923. html += '<div class="edit">';
  924. html += '<div class="input">';
  925. html += "<textarea class='tran_sent_textarea' dbid='" + iterator.id + "' ";
  926. html += "sid='" + sid + "' ";
  927. html += "channel='" + iterator.channal + "' ";
  928. if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
  929. html += ' is_pr="true" onchange1="note_pr_save(this)"';
  930. } else {
  931. html += 'is_pr="false" onchange1="note_sent_save_a(this)"';
  932. }
  933. html += ">" + iterator.text + "</textarea>";
  934. html += "</div>";
  935. html += '<div class="edit_tool">';
  936. //html += ""
  937. html += '<span style="display: inline-flex;">';
  938. html += '<span class="keybutton" >ESC</span> = ';
  939. html += "<a onclick='tran_sent_edit_cancel(this)'>" + gLocal.gui.cancel + "</a>";
  940. html += "</span>";
  941. html += "<span style='display: inline-flex;'>";
  942. html += '<span class="keybutton" >Ctrl/⌘</span>';
  943. html += "➕";
  944. html += '<span class="keybutton" >Enter</span> = ';
  945. if (parseInt(iterator.mypower) < 20) {
  946. html += "<a onclick='tran_sent_save(this)'>";
  947. html += gLocal.gui.submit + "<b>" + gLocal.gui.suggest + gLocal.gui.translation + "</b>";
  948. html += "</a></span><span style='display: inline-flex;'>";
  949. } else {
  950. html += "<a onclick='tran_sent_save(this)'>";
  951. html += gLocal.gui.save;
  952. html += "</a></span><span style='display: inline-flex;'>";
  953. }
  954. html += '<span class="keybutton" >Enter</span> = ';
  955. html += gLocal.gui.next_line;
  956. html += "</span><span style='display: inline-flex;'>MarkDown✅</span>";
  957. html += "</div>";
  958. html += "</div>";
  959. html += '<div class="foot_bar">';
  960. html += '<div class="info">';
  961. if (iterator.id != "") {
  962. html += '<span class="date"> ' + getPassDataTime(iterator.update_time) + "</span>";
  963. }
  964. if (iterator.id != "") {
  965. html += '<span class="name">' + iterator.editor_name.nickname + "</span>";
  966. }
  967. if (iterator.id != "") {
  968. html += '<span class="channel">' + gLocal.gui.updated + " ";
  969. if (typeof iterator.channalinfo == "undefined") {
  970. html += "unkown";
  971. } else {
  972. html += "<a title='" + iterator.channalinfo.summary + "'>" + iterator.channalinfo.name + "@</a>";
  973. }
  974. html += "</span>";
  975. } else {
  976. html += '<span class="channel">' + gLocal.gui.no_updated + " @";
  977. if (typeof iterator.channalinfo == "undefined") {
  978. html += "unkown";
  979. } else {
  980. html += "<a title='" + iterator.channalinfo.owner + "'>" + iterator.channalinfo.name + "@</a>";
  981. }
  982. html += "</span>";
  983. }
  984. html += '<ul class="tag_list">';
  985. if (iterator.pr_all && parseInt(iterator.pr_all) > 0) {
  986. html +=
  987. "<li onclick=\"note_pr_show('" +
  988. iterator.channal +
  989. "','" +
  990. sid +
  991. "')\"><span class='icon'>✋</span><span class='num'>" +
  992. iterator.pr_new +
  993. "/" +
  994. iterator.pr_all +
  995. "</span></li>";
  996. }
  997. html += "</ul>";
  998. html += "</div>"; //end of info
  999. html += "</div>"; //end of foot bar
  1000. html += "</div>";
  1001. html += "</div>";
  1002. //sent_tran_inner结束
  1003. html += '<div class="pr_content"></div>';
  1004. html += "</div>";
  1005. return html;
  1006. }
  1007. function tran_sent_textarea_event_init() {
  1008. let textarea = document.querySelectorAll(".tran_sent_textarea");
  1009. for (let iterator of textarea) {
  1010. iterator.onkeydown = function (e) {
  1011. let menu = document.querySelector("#menu");
  1012. switch (e.key) {
  1013. case "Enter":
  1014. if (menu && menu.style.display == "block") {
  1015. let value = textarea.value;
  1016. let selectionStart = textarea.selectionStart;
  1017. let str1 = value.slice(0, selectionStart);
  1018. let str2 = value.slice(selectionStart);
  1019. textarea.value = str1 + data[menuFocusIndex] + "]]" + str2;
  1020. menu.style.display = "none";
  1021. return false;
  1022. } else {
  1023. if (e.ctrlKey) {
  1024. //回车存盘
  1025. tran_sent_save(e.currentTarget);
  1026. return false;
  1027. }
  1028. }
  1029. break;
  1030. case "Escape":
  1031. tran_sent_edit_cancel(e.currentTarget);
  1032. break;
  1033. default:
  1034. break;
  1035. }
  1036. };
  1037. }
  1038. }
  1039. function render_one_sent_tran(book, para, begin, end, iterator) {
  1040. let output = "";
  1041. output += "<div class='tran' lang='" + iterator.lang + "' style='display:flex;'>";
  1042. //译文工具按钮开始
  1043. output += "<div class='tran_text_tool_botton' onclick='tool_bar_show(this)'>";
  1044. output +=
  1045. "<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>";
  1046. //译文工具栏开始
  1047. output += "<div class='tran_text_tool_bar'>";
  1048. output += "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom' ";
  1049. output +=
  1050. " onclick=\"note_edit_sentence('" +
  1051. book +
  1052. "' ,'" +
  1053. para +
  1054. "' ,'" +
  1055. begin +
  1056. "' ,'" +
  1057. end +
  1058. "' ,'" +
  1059. iterator.channal +
  1060. "')\"";
  1061. output +=
  1062. ">" +
  1063. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use></svg>';
  1064. output += gLocal.gui.edit + "</li>";
  1065. output += "<li class = 'tip_buttom' ";
  1066. output += " onclick=\"history_show('" + iterator.id + "')\" >";
  1067. output +=
  1068. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#recent_scan"></use></svg>';
  1069. output += gLocal.gui.timeline + "</li>";
  1070. output +=
  1071. "<li class = 'tip_buttom'>" +
  1072. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#copy"></use></svg>';
  1073. output += gLocal.gui.copy + "</li></div>";
  1074. output +=
  1075. "<div style='border-right: solid 1px;margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  1076. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use></svg>';
  1077. output += gLocal.gui.like + "</li>";
  1078. output +=
  1079. "<li class = 'tip_buttom'>" +
  1080. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#comment"></use></svg>';
  1081. output += gLocal.gui.comment + "</li>";
  1082. output +=
  1083. "<li class = 'tip_buttom'>" +
  1084. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_shopping_cart"></use></svg>';
  1085. output += gLocal.gui.digest + "</li></div>";
  1086. output +=
  1087. "<div style='margin: 0.3em 0;'><li class = 'tip_buttom'>" +
  1088. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#share_to"></use></svg>';
  1089. output += gLocal.gui.share_to + "</li>";
  1090. output += "</div></div>";
  1091. //译文工具栏结束
  1092. output += "</div>";
  1093. //译文工具按钮结束
  1094. //译文正文开始
  1095. output +=
  1096. "<div class='text' id='tran_text_" +
  1097. book +
  1098. "_" +
  1099. para +
  1100. "_" +
  1101. begin +
  1102. "_" +
  1103. end +
  1104. "_" +
  1105. iterator.channal +
  1106. "'>";
  1107. if (iterator.text == "") {
  1108. output +=
  1109. "<span style='color:var(--border-line-color);'>" +
  1110. iterator.channalinfo.name +
  1111. "-" +
  1112. iterator.channalinfo.lang +
  1113. "</span>";
  1114. } else {
  1115. //note_init处理句子链接
  1116. output += note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
  1117. }
  1118. output += "</div>";
  1119. //译文正文结束
  1120. output += "</div>";
  1121. //单个channal译文框结束
  1122. return output;
  1123. }
  1124. function hidden_control(obj) {
  1125. if ($(".lang_2")[0].style.display == "none" && $(".lang_3")[0].style.display == "none") {
  1126. $(".lang_2").show();
  1127. $(".lang_3").show();
  1128. obj.innerHTML = "⬅"
  1129. }
  1130. else {
  1131. $(".lang_2").hide();
  1132. $(".lang_3").hide();
  1133. obj.innerHTML = "➡"
  1134. }
  1135. }
  1136. function add_new_tran_button_click(obj) {
  1137. let html = "<div style='display:flex; max-width: 70vw; white-space: normal;'>";
  1138. var first_lang = "";
  1139. for (const iterator of _my_channal) {
  1140. if (iterator.lang) {
  1141. first_lang = iterator.lang;
  1142. break;
  1143. }
  1144. }
  1145. //母语channel列表
  1146. html += "<ul class='channel_list lang_0' >";
  1147. html += "<li>";
  1148. html += gLocal.language[first_lang];
  1149. html += "</li>";
  1150. for (const iterator of _my_channal) {
  1151. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) != -1 && iterator.lang != 0) {
  1152. if (_channal.indexOf(iterator.id) < 0) {
  1153. html += '<li class="channel_name" onclick="';
  1154. html +=
  1155. "new_sentence('" +
  1156. $(obj).parent().attr("book") +
  1157. "' ,'" +
  1158. $(obj).parent().attr("para") +
  1159. "' ,'" +
  1160. $(obj).parent().attr("begin") +
  1161. "' ,'" +
  1162. $(obj).parent().attr("end") +
  1163. "' ,'" +
  1164. iterator.id +
  1165. "',this)";
  1166. html += '" title="' + iterator.nickname;
  1167. html += '">' + iterator.name;
  1168. if (parseInt(iterator.power) < 20) {
  1169. html += "(建议)";
  1170. }
  1171. html += "</li>";
  1172. }
  1173. }
  1174. }
  1175. html += "<li><a href='../channal/my_channal_index.php' target='_blank'><button>" + gLocal.gui.new + "&nbsp;" + gLocal.gui.channel + "</button></a></li>"
  1176. html += "</ul>";
  1177. //非母语channel列表
  1178. html += "<ul class='channel_list lang_1'>";
  1179. html += "<li>";
  1180. html += gLocal.gui.other;
  1181. html += "&nbsp;<button style='height: 1.8em;' onmouseover='hidden_control(this)'>➡</button>"
  1182. html += "</li>";
  1183. for (const iterator of _my_channal) {
  1184. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) == -1 && iterator.lang != 0) {
  1185. if (_channal.indexOf(iterator.id) < 0) {
  1186. html += '<li class="channel_name" onclick="';
  1187. html +=
  1188. "new_sentence('" +
  1189. $(obj).parent().attr("book") +
  1190. "' ,'" +
  1191. $(obj).parent().attr("para") +
  1192. "' ,'" +
  1193. $(obj).parent().attr("begin") +
  1194. "' ,'" +
  1195. $(obj).parent().attr("end") +
  1196. "' ,'" +
  1197. iterator.id +
  1198. "',this)";
  1199. html += '" title="' + iterator.nickname;
  1200. html += '">' + iterator.name;
  1201. if (parseInt(iterator.power) < 20) {
  1202. html += "(建议)";
  1203. }
  1204. html += "</li>";
  1205. }
  1206. }
  1207. }
  1208. html += "</ul>";
  1209. //协作channel列表-带中文
  1210. html += "<ul class='channel_list lang_2' style='display:none;'>";
  1211. html += "<li>";
  1212. html += "协作";
  1213. html += "</li>";
  1214. for (const iterator of _my_channal) {
  1215. if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == true) {
  1216. if (_channal.indexOf(iterator.id) < 0) {
  1217. html += '<li class="channel_name" onclick="';
  1218. html +=
  1219. "new_sentence('" +
  1220. $(obj).parent().attr("book") +
  1221. "' ,'" +
  1222. $(obj).parent().attr("para") +
  1223. "' ,'" +
  1224. $(obj).parent().attr("begin") +
  1225. "' ,'" +
  1226. $(obj).parent().attr("end") +
  1227. "' ,'" +
  1228. iterator.id +
  1229. "',this)";
  1230. html += '" title="' + iterator.nickname;
  1231. html += '">' + iterator.name;
  1232. if (parseInt(iterator.power) < 20) {
  1233. html += "(建议)";
  1234. }
  1235. html += "</li>";
  1236. }
  1237. }
  1238. }
  1239. html += "</ul>";
  1240. //协作channel列表-不带中文
  1241. html += "<ul class='channel_list lang_3' style='display:none;'>";
  1242. html += "<li>";
  1243. html += "collaborate";
  1244. html += "</li>";
  1245. for (const iterator of _my_channal) {
  1246. if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == false) {
  1247. if (_channal.indexOf(iterator.id) < 0) {
  1248. html += '<li class="channel_name" onclick="';
  1249. html +=
  1250. "new_sentence('" +
  1251. $(obj).parent().attr("book") +
  1252. "' ,'" +
  1253. $(obj).parent().attr("para") +
  1254. "' ,'" +
  1255. $(obj).parent().attr("begin") +
  1256. "' ,'" +
  1257. $(obj).parent().attr("end") +
  1258. "' ,'" +
  1259. iterator.id +
  1260. "',this)";
  1261. html += '" title="' + iterator.nickname;
  1262. html += '">' + iterator.name;
  1263. if (parseInt(iterator.power) < 20) {
  1264. html += "(建议)";
  1265. }
  1266. html += "</li>";
  1267. }
  1268. }
  1269. }
  1270. html += "</ul>";
  1271. html += "</div>";
  1272. $(obj).parent().children(".tran_text_tool_bar").first().html(html);
  1273. if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
  1274. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1275. } else {
  1276. $(obj).parent().children(".tran_text_tool_bar").first().show();
  1277. $(document).one("click", function () {
  1278. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1279. });
  1280. event.stopPropagation();
  1281. $(obj).parent().show();
  1282. }
  1283. }
  1284. function checkStringIsChinese(str) {
  1285. var pattern = new RegExp("[\u4E00-\u9FA5]+");
  1286. if (pattern.test(str)) {
  1287. return true;
  1288. }
  1289. return false;
  1290. }
  1291. function tool_bar_show(element) {
  1292. if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
  1293. $(element).find(".tran_text_tool_bar").css("display", "flex");
  1294. $(element).find(".icon_expand").css("transform", "rotate(-180deg)");
  1295. $(element).css("background-color", "var(--btn-bg-color)");
  1296. $(element).css("visibility", "visible");
  1297. $(document).one("click", function () {
  1298. $(element).find(".tran_text_tool_bar").hide();
  1299. $(element).css("background-color", "var(--nocolor)");
  1300. $(element).find(".icon_expand").css("transform", "unset");
  1301. $(element).css("visibility", "");
  1302. });
  1303. event.stopPropagation();
  1304. } else {
  1305. $(element).find(".tran_text_tool_bar").hide();
  1306. $(element).css("background-color", "var(--nocolor)");
  1307. $(element).find(".icon_expand").css("transform", "unset");
  1308. $(element).css("visibility", "");
  1309. }
  1310. }
  1311. function new_sentence(book, para, begin, end, channel, obj) {
  1312. let newsent = { id: "", text: "", lang: "", channal: channel };
  1313. for (let iterator of _arrData) {
  1314. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1315. let found = false;
  1316. for (const tran of iterator.translation) {
  1317. if (tran.channal == channel) {
  1318. found = true;
  1319. break;
  1320. }
  1321. }
  1322. if (!found) {
  1323. iterator.translation.push(newsent);
  1324. }
  1325. }
  1326. }
  1327. if ($(obj).parent().parent().css("display") == "block") {
  1328. $(obj).parent().parent().hide();
  1329. }
  1330. note_edit_sentence(book, para, begin, end, channel);
  1331. }
  1332. //显示更多译文按钮动作
  1333. function set_more_button_display() {
  1334. $(".other_tran_div").each(function () {
  1335. const sentid = $(this).attr("sent").split("-");
  1336. const book = sentid[0];
  1337. const para = sentid[1];
  1338. const begin = sentid[2];
  1339. const end = sentid[3];
  1340. let count = 0;
  1341. for (const iterator of _channalData) {
  1342. if (iterator.final) {
  1343. for (const onesent of iterator.final) {
  1344. let id = onesent.id.split("-");
  1345. if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
  1346. if (_channal.indexOf(iterator.id) == -1) {
  1347. count++;
  1348. }
  1349. }
  1350. }
  1351. }
  1352. }
  1353. if (count > 0) {
  1354. $(this).find(".other_tran_num").html(count);
  1355. $(this).find(".other_tran_num").attr("style", "display:inline-flex;");
  1356. $(this)
  1357. .find(".other_bar")
  1358. .click(function () {
  1359. const sentid = $(this).parent().parent().attr("sent").split("-");
  1360. const book = sentid[0];
  1361. const para = sentid[1];
  1362. const begin = sentid[2];
  1363. const end = sentid[3];
  1364. let sentId = $(this).parent().parent().attr("sent");
  1365. if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
  1366. $(".other_tran_div[sent='" + sentId + "']")
  1367. .children(".other_tran")
  1368. .slideDown();
  1369. $(this).siblings(".more_tran ").css("transform", "unset");
  1370. $.get(
  1371. "../usent/get.php",
  1372. {
  1373. book: book,
  1374. para: para,
  1375. begin: begin,
  1376. end: end,
  1377. },
  1378. function (data, status) {
  1379. let arrSent = JSON.parse(data);
  1380. let html = "<div class='compact'>";
  1381. for (const iterator of arrSent) {
  1382. if (_channal.indexOf(iterator.channal) == -1) {
  1383. html += render_one_sent_tran_a(iterator);
  1384. }
  1385. }
  1386. html += "</div>";
  1387. let sentId =
  1388. arrSent[0].book +
  1389. "-" +
  1390. arrSent[0].paragraph +
  1391. "-" +
  1392. arrSent[0].begin +
  1393. "-" +
  1394. arrSent[0].end;
  1395. $(".other_tran_div[sent='" + sentId + "']")
  1396. .children(".other_tran")
  1397. .html(html);
  1398. //初始化文本编辑框消息处理
  1399. tran_sent_textarea_event_init();
  1400. }
  1401. );
  1402. } else {
  1403. $(".other_tran_div[sent='" + sentId + "']")
  1404. .children(".other_tran")
  1405. .slideUp();
  1406. $(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
  1407. }
  1408. });
  1409. } else {
  1410. //隐藏自己
  1411. //$(this).hide();
  1412. $(this).find(".other_tran_span").addClass("disable"); //gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation
  1413. //$(this).find(".more_tran").hide();
  1414. }
  1415. });
  1416. }
  1417. function note_edit_sentence(book, para, begin, end, channal) {
  1418. let channalInfo;
  1419. for (const iterator of _channalData) {
  1420. if (iterator.id == channal) {
  1421. channalInfo = iterator;
  1422. break;
  1423. }
  1424. }
  1425. for (const iterator of _arrData) {
  1426. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1427. for (const tran of iterator.translation) {
  1428. if (tran.channal == channal) {
  1429. let html = "";
  1430. html += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
  1431. html +=
  1432. "<textarea id='edit_dialog_text' sent_id='" +
  1433. tran.id +
  1434. "' book='" +
  1435. book +
  1436. "' para='" +
  1437. para +
  1438. "' begin='" +
  1439. begin +
  1440. "' end='" +
  1441. end +
  1442. "' channal='" +
  1443. channal +
  1444. "' style='width:100%;min-height:260px;'>" +
  1445. tran.text +
  1446. "</textarea>";
  1447. $("#edit_dialog_content").html(html);
  1448. $("#note_sent_edit_dlg").dialog("open");
  1449. return;
  1450. }
  1451. }
  1452. }
  1453. }
  1454. alert("未找到句子");
  1455. }
  1456. function tran_sent_edit_cancel(obj) {
  1457. sent_tran_set_edit_mode(obj, false);
  1458. }
  1459. function tran_sent_save(obj) {
  1460. let sentDiv = find_sent_tran_div(obj);
  1461. if (sentDiv) {
  1462. let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
  1463. let isPr = $(textarea).attr("is_pr");
  1464. if (isPr == "true") {
  1465. note_pr_save(textarea);
  1466. } else {
  1467. note_sent_save_a(textarea);
  1468. }
  1469. sent_tran_set_edit_mode(textarea, false);
  1470. } else {
  1471. console.error("sent div not found");
  1472. }
  1473. }
  1474. //保存pr句子 新
  1475. function note_pr_save(obj) {
  1476. let id = $(obj).attr("dbid");
  1477. let sid = $(obj).attr("sid").split("-");
  1478. let book = sid[0];
  1479. let para = sid[1];
  1480. let begin = sid[2];
  1481. let end = sid[3];
  1482. let channel = $(obj).attr("channel");
  1483. let text = $(obj).val();
  1484. let sent_tran_div = find_sent_tran_div(obj);
  1485. $.post(
  1486. "../usent/pr_post.php",
  1487. {
  1488. id: id,
  1489. book: book,
  1490. para: para,
  1491. begin: begin,
  1492. end: end,
  1493. channel: channel,
  1494. text: text,
  1495. },
  1496. sent_save_callback
  1497. );
  1498. if (sent_tran_div) {
  1499. $(sent_tran_div).addClass("loading");
  1500. }
  1501. }
  1502. //保存译文句子 新
  1503. function note_sent_save_a(obj) {
  1504. let id = $(obj).attr("dbid");
  1505. let sid = $(obj).attr("sid").split("-");
  1506. let book = sid[0];
  1507. let para = sid[1];
  1508. let begin = sid[2];
  1509. let end = sid[3];
  1510. let channal = $(obj).attr("channel");
  1511. let text = $(obj).val();
  1512. let sent_tran_div = find_sent_tran_div(obj);
  1513. /*
  1514. var jqxhr = $.post("example.php", function() {
  1515. alert("success");
  1516. })
  1517. .success(function() { alert("second success"); })
  1518. .error(function() { alert("error"); })
  1519. .complete(function() { alert("complete"); });*/
  1520. /*
  1521. function (data, status) {
  1522. alert("异常!" + data.responseText);
  1523. switch (status) {
  1524. case "timeout":
  1525. break;
  1526. case "error":
  1527. break;
  1528. case "notmodified":
  1529. break;
  1530. case "parsererror":
  1531. break;
  1532. default:
  1533. break;
  1534. }
  1535. */
  1536. var jqxhr = $.post(
  1537. "../usent/sent_post.php",
  1538. {
  1539. id: id,
  1540. book: book,
  1541. para: para,
  1542. begin: begin,
  1543. end: end,
  1544. channal: channal,
  1545. text: text,
  1546. lang: "zh",
  1547. },
  1548. sent_save_callback
  1549. )
  1550. .success(function () {
  1551. //alert("second success");
  1552. })
  1553. .error(function (xhr, error, data) {
  1554. let sid = book + "-" + para + "-" + begin + "-" + end;
  1555. let sent_tran_div = $(".sent_tran[channel='" + channal + "'][sid='" + sid + "']");
  1556. if (sent_tran_div) {
  1557. sent_tran_div.removeClass("loading");
  1558. sent_tran_div.addClass("error");
  1559. }
  1560. switch (error) {
  1561. case "timeout":
  1562. alert("服务器长时间没有回应。请稍后重试。");
  1563. break;
  1564. case "error":
  1565. alert("与服务器通讯失败,您可能没有连接到网络。请稍后重试。");
  1566. break;
  1567. case "notmodified":
  1568. break;
  1569. default:
  1570. break;
  1571. }
  1572. })
  1573. .complete(function (xhr, data) {
  1574. //请求完成后回调函数 (请求成功或失败之后均调用)。
  1575. switch (data) {
  1576. case "error":
  1577. break;
  1578. case "success":
  1579. break;
  1580. default:
  1581. break;
  1582. }
  1583. });
  1584. if (sent_tran_div) {
  1585. $(sent_tran_div).addClass("loading");
  1586. }
  1587. }
  1588. function update_sent_tran(sentData) {}
  1589. function sent_save_callback(data) {
  1590. let result = JSON.parse(data);
  1591. if (result.status > 0) {
  1592. alert("error" + result.message);
  1593. } else {
  1594. let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
  1595. let sent_tran_div = $(
  1596. ".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
  1597. );
  1598. if (sent_tran_div) {
  1599. sent_tran_div.removeClass("loading");
  1600. }
  1601. if (result.commit_type == 1 || result.commit_type == 2) {
  1602. ntf_show("成功修改");
  1603. if (sent_tran_div) {
  1604. let divPreview = sent_tran_div.find(".preview").first();
  1605. if (result.text == "") {
  1606. let channel_info = "Empty";
  1607. let thisChannel = find_channal(result.channal);
  1608. if (thisChannel) {
  1609. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1610. }
  1611. divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1612. } else {
  1613. divPreview.html(
  1614. marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
  1615. );
  1616. term_updata_translation();
  1617. popup_init();
  1618. for (const iterator of _arrData) {
  1619. if (
  1620. iterator.book == result.book &&
  1621. iterator.para == result.para &&
  1622. iterator.begin == result.begin &&
  1623. iterator.end == result.end
  1624. ) {
  1625. for (const tran of iterator.translation) {
  1626. if (tran.channal == result.channal) {
  1627. tran.text = result.text;
  1628. break;
  1629. }
  1630. }
  1631. }
  1632. }
  1633. }
  1634. }
  1635. } else if (result.commit_type == 3) {
  1636. ntf_show("已经提交修改建议");
  1637. } else {
  1638. ntf_show("未提交");
  1639. }
  1640. }
  1641. }
  1642. //保存译文句子
  1643. function note_sent_save() {
  1644. let id = $("#edit_dialog_text").attr("sent_id");
  1645. let book = $("#edit_dialog_text").attr("book");
  1646. let para = $("#edit_dialog_text").attr("para");
  1647. let begin = $("#edit_dialog_text").attr("begin");
  1648. let end = $("#edit_dialog_text").attr("end");
  1649. let channal = $("#edit_dialog_text").attr("channal");
  1650. let text = $("#edit_dialog_text").val();
  1651. $.post(
  1652. "../usent/sent_post.php",
  1653. {
  1654. id: id,
  1655. book: book,
  1656. para: para,
  1657. begin: begin,
  1658. end: end,
  1659. channal: channal,
  1660. text: text,
  1661. lang: "zh",
  1662. },
  1663. function (data) {
  1664. let result = JSON.parse(data);
  1665. if (result.status > 0) {
  1666. alert("error" + result.message);
  1667. } else {
  1668. if (result.commit_type == 1 || result.commit_type == 2) {
  1669. ntf_show("成功修改");
  1670. if (result.text == "") {
  1671. let channel_info = "Empty";
  1672. let thisChannel = find_channal(result.channal);
  1673. if (thisChannel) {
  1674. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1675. }
  1676. $(
  1677. "#tran_text_" +
  1678. result.book +
  1679. "_" +
  1680. result.para +
  1681. "_" +
  1682. result.begin +
  1683. "_" +
  1684. result.end +
  1685. "_" +
  1686. result.channal
  1687. ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1688. } else {
  1689. $(
  1690. "#tran_text_" +
  1691. result.book +
  1692. "_" +
  1693. result.para +
  1694. "_" +
  1695. result.begin +
  1696. "_" +
  1697. result.end +
  1698. "_" +
  1699. result.channal
  1700. ).html(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
  1701. term_updata_translation();
  1702. for (const iterator of _arrData) {
  1703. if (
  1704. iterator.book == result.book &&
  1705. iterator.para == result.para &&
  1706. iterator.begin == result.begin &&
  1707. iterator.end == result.end
  1708. ) {
  1709. for (const tran of iterator.translation) {
  1710. if (tran.channal == result.channal) {
  1711. tran.text = result.text;
  1712. break;
  1713. }
  1714. }
  1715. }
  1716. }
  1717. }
  1718. } else if (result.commit_type == 3) {
  1719. ntf_show("已经提交修改建议");
  1720. } else {
  1721. ntf_show("未提交");
  1722. }
  1723. }
  1724. }
  1725. );
  1726. }
  1727. function copy_ref(book, para, begin, end) {
  1728. let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
  1729. copy_to_clipboard(strRef);
  1730. }
  1731. function goto_nissaya(book, para, begin = 0, end = 0) {
  1732. window.open("../nissaya/index.php?book=" + book + "&para=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
  1733. }
  1734. function edit_in_studio(book, para, begin, end) {
  1735. wbw_channal_list_open(book, [para]);
  1736. }
  1737. //显示和隐藏某个内容 如 巴利文
  1738. function setVisibility(key, value) {
  1739. switch (key) {
  1740. case "palitext":
  1741. if ($(value).is(":checked")) {
  1742. $(".palitext").show();
  1743. } else {
  1744. $(".palitext").hide();
  1745. }
  1746. break;
  1747. default:
  1748. break;
  1749. }
  1750. }
  1751. function note_show_pali_sim(SentId) {
  1752. pali_sim_dlg_open(SentId, 0, 20);
  1753. }
  1754. function set_pali_script(pos, script) {
  1755. if (script == "none") {
  1756. $(".palitext" + pos).html("");
  1757. } else {
  1758. $(".palitext" + pos).each(function () {
  1759. let html = $(this).siblings(".palitext_roma").first().html();
  1760. $(this).html(html);
  1761. });
  1762. $(".palitext" + pos)
  1763. .find("*")
  1764. .contents()
  1765. .filter(function () {
  1766. return this.nodeType != 1;
  1767. })
  1768. .wrap("<pl" + pos + "></pl" + pos + ">");
  1769. $(".palitext" + pos)
  1770. .contents()
  1771. .filter(function () {
  1772. return this.nodeType != 1;
  1773. })
  1774. .wrap("<pl" + pos + "></pl" + pos + ">");
  1775. $("pl" + pos).html(function (index, oldcontent) {
  1776. return roman_to_my(oldcontent);
  1777. });
  1778. }
  1779. }
  1780. function splite_pali_word() {
  1781. $("pali")
  1782. .contents()
  1783. .filter(function () {
  1784. return this.nodeType != 1;
  1785. })
  1786. .wrap("<pl></pl>");
  1787. $("pl").each(function () {
  1788. let html = $(this).html();
  1789. $(this).html("<w>" + html.replace(/\s/g, "</w> <w>") + "</w>");
  1790. });
  1791. $("w").click(function () {
  1792. let word = com_getPaliReal($(this).text());
  1793. if (gBuildinDictIsOpen) {
  1794. window.open("../dict/index.php?builtin=true&key=" + word, "dict");
  1795. }
  1796. });
  1797. }
  1798. function refresh_pali_script() {
  1799. if (_display && _display == "para") {
  1800. //段落模式
  1801. } else {
  1802. //句子模式
  1803. setting_get("lib.second_script", set_second_scrip);
  1804. }
  1805. }
  1806. function set_second_scrip(value) {
  1807. set_pali_script(2, value);
  1808. }
  1809. function slider_show(obj) {
  1810. $(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
  1811. }
  1812. function find_sent_tran_div(obj) {
  1813. let jqObj = $(obj);
  1814. while (!jqObj.hasClass("sent_tran")) {
  1815. jqObj = jqObj.parent();
  1816. if (!jqObj) {
  1817. return false;
  1818. }
  1819. }
  1820. return jqObj;
  1821. /*
  1822. let parent = obj.parentNode;
  1823. while (parent.nodeType == 1) {
  1824. if ($(parent).hasClass("sent_tran")) {
  1825. return parent;
  1826. } else if (parent.nodeName == "BODY") {
  1827. return false;
  1828. }
  1829. parent = parent.parentNode;
  1830. }
  1831. return false;
  1832. */
  1833. }
  1834. //显示或隐藏pr数据
  1835. function note_pr_show(channel, id) {
  1836. let obj = $(".sent_tran[channel='" + channel + "'][sid='" + id + "']").find(".pr_content");
  1837. let prHtml = obj.first().html();
  1838. if (prHtml == "") {
  1839. note_get_pr(channel, id);
  1840. } else {
  1841. obj.slideUp();
  1842. obj.html("");
  1843. }
  1844. }
  1845. //获取pr数据并显示
  1846. function note_get_pr(channel, id) {
  1847. let sid = id.split("-");
  1848. let book = sid[0];
  1849. let para = sid[1];
  1850. let begin = sid[2];
  1851. let end = sid[3];
  1852. $.post(
  1853. "../usent/get_pr.php",
  1854. {
  1855. book: book,
  1856. para: para,
  1857. begin: begin,
  1858. end: end,
  1859. channel: channel,
  1860. },
  1861. function (data) {
  1862. let result = JSON.parse(data);
  1863. if (result.length > 0) {
  1864. let html = "<div class='compact pr'>";
  1865. for (const iterator of result) {
  1866. html += render_one_sent_tran_a(iterator, true);
  1867. }
  1868. html += "</div>";
  1869. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1870. .find(".pr_content")
  1871. .html(html);
  1872. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1873. .find(".pr_content")
  1874. .slideDown();
  1875. } else {
  1876. }
  1877. }
  1878. );
  1879. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1880. .find(".pr_content")
  1881. .html("loading");
  1882. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1883. .find(".pr_content")
  1884. .show();
  1885. }
  1886. function get_channel_by_id(id) {
  1887. if (typeof _channalData != "undefined") {
  1888. for (const iterator of _channalData) {
  1889. if (iterator.id == id) {
  1890. return iterator;
  1891. }
  1892. }
  1893. }
  1894. if (typeof _my_channal != "undefined") {
  1895. for (const iterator of _my_channal) {
  1896. if (iterator.id == id) {
  1897. return iterator;
  1898. }
  1899. }
  1900. }
  1901. return false;
  1902. }
  1903. //设置显示方向
  1904. function setDirection(obj) {
  1905. if (obj.value == "row") {
  1906. $("#contents").removeClass("vertical");
  1907. $("#contents").addClass("horizontal");
  1908. _direction = "row";
  1909. } else {
  1910. $("#contents").removeClass("horizontal");
  1911. $("#contents").addClass("vertical");
  1912. _direction = "col";
  1913. }
  1914. }
  1915. //设置逐段或逐句模式
  1916. function setDisplay(obj) {
  1917. if (obj.value == "para") {
  1918. $("#contents").removeClass("sent_mode");
  1919. $("#contents").addClass("para_mode");
  1920. _display = "para";
  1921. } else {
  1922. $("#contents").removeClass("para_mode");
  1923. $("#contents").addClass("sent_mode");
  1924. _display = "sent";
  1925. }
  1926. }