note.js 53 KB

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