note.js 54 KB

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