note.js 53 KB

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