note.js 53 KB

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