note.js 54 KB

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