note.js 54 KB

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