note.js 53 KB

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