note.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  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 add_new_tran_button_click(obj) {
  1117. let html = "<a href='../channal/my_channal_index.php' target='_blank'><button>" + gLocal.gui.new + "&nbsp;" + gLocal.gui.channel + "</button></a>"
  1118. html += "<div style='display:flex; max-width: 70vw; white-space: normal;'>";
  1119. var first_lang = "";
  1120. for (const iterator of _my_channal) {
  1121. if (iterator.lang) {
  1122. first_lang = iterator.lang;
  1123. break;
  1124. }
  1125. }
  1126. //母语channel列表
  1127. html += "<ul class='channel_list lang_0' >";
  1128. html += "<li>";
  1129. html += gLocal.language[first_lang];
  1130. html += "</li>";
  1131. for (const iterator of _my_channal) {
  1132. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) != -1 && iterator.lang != 0) {
  1133. if (_channal.indexOf(iterator.id) < 0) {
  1134. html += '<li class="channel_name" onclick="';
  1135. html +=
  1136. "new_sentence('" +
  1137. $(obj).parent().attr("book") +
  1138. "' ,'" +
  1139. $(obj).parent().attr("para") +
  1140. "' ,'" +
  1141. $(obj).parent().attr("begin") +
  1142. "' ,'" +
  1143. $(obj).parent().attr("end") +
  1144. "' ,'" +
  1145. iterator.id +
  1146. "',this)";
  1147. html += '" title="' + iterator.nickname;
  1148. html += '">' + iterator.name;
  1149. if (parseInt(iterator.power) < 20) {
  1150. html += "(建议)";
  1151. }
  1152. html += "</li>";
  1153. }
  1154. }
  1155. }
  1156. //非母语channel列表
  1157. html += "</ul>";
  1158. html += "<ul class='channel_list lang_1'>";
  1159. html += "<li>";
  1160. html += gLocal.gui.other;
  1161. html += "</li>";
  1162. for (const iterator of _my_channal) {
  1163. if (iterator.status > 0 && first_lang.indexOf(iterator.lang) == -1 && iterator.lang != 0) {
  1164. if (_channal.indexOf(iterator.id) < 0) {
  1165. html += '<li class="channel_name" onclick="';
  1166. html +=
  1167. "new_sentence('" +
  1168. $(obj).parent().attr("book") +
  1169. "' ,'" +
  1170. $(obj).parent().attr("para") +
  1171. "' ,'" +
  1172. $(obj).parent().attr("begin") +
  1173. "' ,'" +
  1174. $(obj).parent().attr("end") +
  1175. "' ,'" +
  1176. iterator.id +
  1177. "',this)";
  1178. html += '" title="' + iterator.nickname;
  1179. html += '">' + iterator.name;
  1180. if (parseInt(iterator.power) < 20) {
  1181. html += "(建议)";
  1182. }
  1183. html += "</li>";
  1184. }
  1185. }
  1186. }
  1187. html += "</ul>";
  1188. //协作channel列表-带中文
  1189. html += "<ul class='channel_list lang_2'>";
  1190. html += "<li>";
  1191. html += "协作";
  1192. html += "</li>";
  1193. for (const iterator of _my_channal) {
  1194. if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == true) {
  1195. if (_channal.indexOf(iterator.id) < 0) {
  1196. html += '<li class="channel_name" onclick="';
  1197. html +=
  1198. "new_sentence('" +
  1199. $(obj).parent().attr("book") +
  1200. "' ,'" +
  1201. $(obj).parent().attr("para") +
  1202. "' ,'" +
  1203. $(obj).parent().attr("begin") +
  1204. "' ,'" +
  1205. $(obj).parent().attr("end") +
  1206. "' ,'" +
  1207. iterator.id +
  1208. "',this)";
  1209. html += '" title="' + iterator.nickname;
  1210. html += '">' + iterator.name;
  1211. if (parseInt(iterator.power) < 20) {
  1212. html += "(建议)";
  1213. }
  1214. html += "</li>";
  1215. }
  1216. }
  1217. }
  1218. html += "</ul>";
  1219. //协作channel列表-不带中文
  1220. html += "<ul class='channel_list lang_3'>";
  1221. html += "<li>";
  1222. html += "collaborate";
  1223. html += "</li>";
  1224. for (const iterator of _my_channal) {
  1225. if (iterator.status > 0 && iterator.lang == 0 && checkStringIsChinese(iterator.name) == false) {
  1226. if (_channal.indexOf(iterator.id) < 0) {
  1227. html += '<li class="channel_name" onclick="';
  1228. html +=
  1229. "new_sentence('" +
  1230. $(obj).parent().attr("book") +
  1231. "' ,'" +
  1232. $(obj).parent().attr("para") +
  1233. "' ,'" +
  1234. $(obj).parent().attr("begin") +
  1235. "' ,'" +
  1236. $(obj).parent().attr("end") +
  1237. "' ,'" +
  1238. iterator.id +
  1239. "',this)";
  1240. html += '" title="' + iterator.nickname;
  1241. html += '">' + iterator.name;
  1242. if (parseInt(iterator.power) < 20) {
  1243. html += "(建议)";
  1244. }
  1245. html += "</li>";
  1246. }
  1247. }
  1248. }
  1249. html += "</ul>";
  1250. html += "</div>";
  1251. $(obj).parent().children(".tran_text_tool_bar").first().html(html);
  1252. if ($(obj).parent().children(".tran_text_tool_bar").css("display") == "block") {
  1253. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1254. } else {
  1255. $(obj).parent().children(".tran_text_tool_bar").first().show();
  1256. $(document).one("click", function () {
  1257. $(obj).parent().children(".tran_text_tool_bar").first().hide();
  1258. });
  1259. event.stopPropagation();
  1260. $(obj).parent().show();
  1261. }
  1262. }
  1263. function checkStringIsChinese(str) {
  1264. var pattern = new RegExp("[\u4E00-\u9FA5]+");
  1265. if (pattern.test(str)) {
  1266. return true;
  1267. }
  1268. return false;
  1269. }
  1270. function tool_bar_show(element) {
  1271. if ($(element).find(".tran_text_tool_bar").css("display") == "none") {
  1272. $(element).find(".tran_text_tool_bar").css("display", "flex");
  1273. $(element).find(".icon_expand").css("transform", "rotate(-180deg)");
  1274. $(element).css("background-color", "var(--btn-bg-color)");
  1275. $(element).css("visibility", "visible");
  1276. $(document).one("click", function () {
  1277. $(element).find(".tran_text_tool_bar").hide();
  1278. $(element).css("background-color", "var(--nocolor)");
  1279. $(element).find(".icon_expand").css("transform", "unset");
  1280. $(element).css("visibility", "");
  1281. });
  1282. event.stopPropagation();
  1283. } else {
  1284. $(element).find(".tran_text_tool_bar").hide();
  1285. $(element).css("background-color", "var(--nocolor)");
  1286. $(element).find(".icon_expand").css("transform", "unset");
  1287. $(element).css("visibility", "");
  1288. }
  1289. }
  1290. function new_sentence(book, para, begin, end, channel, obj) {
  1291. let newsent = { id: "", text: "", lang: "", channal: channel };
  1292. for (let iterator of _arrData) {
  1293. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1294. let found = false;
  1295. for (const tran of iterator.translation) {
  1296. if (tran.channal == channel) {
  1297. found = true;
  1298. break;
  1299. }
  1300. }
  1301. if (!found) {
  1302. iterator.translation.push(newsent);
  1303. }
  1304. }
  1305. }
  1306. if ($(obj).parent().parent().css("display") == "block") {
  1307. $(obj).parent().parent().hide();
  1308. }
  1309. note_edit_sentence(book, para, begin, end, channel);
  1310. }
  1311. //显示更多译文按钮动作
  1312. function set_more_button_display() {
  1313. $(".other_tran_div").each(function () {
  1314. const sentid = $(this).attr("sent").split("-");
  1315. const book = sentid[0];
  1316. const para = sentid[1];
  1317. const begin = sentid[2];
  1318. const end = sentid[3];
  1319. let count = 0;
  1320. for (const iterator of _channalData) {
  1321. if (iterator.final) {
  1322. for (const onesent of iterator.final) {
  1323. let id = onesent.id.split("-");
  1324. if (book == id[0] && para == id[1] && begin == id[2] && end == id[3] && onesent.final) {
  1325. if (_channal.indexOf(iterator.id) == -1) {
  1326. count++;
  1327. }
  1328. }
  1329. }
  1330. }
  1331. }
  1332. if (count > 0) {
  1333. $(this).find(".other_tran_num").html(count);
  1334. $(this).find(".other_tran_num").attr("style", "display:inline-flex;");
  1335. $(this)
  1336. .find(".other_bar")
  1337. .click(function () {
  1338. const sentid = $(this).parent().parent().attr("sent").split("-");
  1339. const book = sentid[0];
  1340. const para = sentid[1];
  1341. const begin = sentid[2];
  1342. const end = sentid[3];
  1343. let sentId = $(this).parent().parent().attr("sent");
  1344. if ($(this).parent().parent().siblings(".other_tran").first().css("display") == "none") {
  1345. $(".other_tran_div[sent='" + sentId + "']")
  1346. .children(".other_tran")
  1347. .slideDown();
  1348. $(this).siblings(".more_tran ").css("transform", "unset");
  1349. $.get(
  1350. "../usent/get.php",
  1351. {
  1352. book: book,
  1353. para: para,
  1354. begin: begin,
  1355. end: end,
  1356. },
  1357. function (data, status) {
  1358. let arrSent = JSON.parse(data);
  1359. let html = "<div class='compact'>";
  1360. for (const iterator of arrSent) {
  1361. if (_channal.indexOf(iterator.channal) == -1) {
  1362. html += render_one_sent_tran_a(iterator);
  1363. }
  1364. }
  1365. html += "</div>";
  1366. let sentId =
  1367. arrSent[0].book +
  1368. "-" +
  1369. arrSent[0].paragraph +
  1370. "-" +
  1371. arrSent[0].begin +
  1372. "-" +
  1373. arrSent[0].end;
  1374. $(".other_tran_div[sent='" + sentId + "']")
  1375. .children(".other_tran")
  1376. .html(html);
  1377. //初始化文本编辑框消息处理
  1378. tran_sent_textarea_event_init();
  1379. }
  1380. );
  1381. } else {
  1382. $(".other_tran_div[sent='" + sentId + "']")
  1383. .children(".other_tran")
  1384. .slideUp();
  1385. $(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
  1386. }
  1387. });
  1388. } else {
  1389. //隐藏自己
  1390. //$(this).hide();
  1391. $(this).find(".other_tran_span").addClass("disable"); //gLocal.gui.no + gLocal.gui.other + gLocal.gui.translation
  1392. //$(this).find(".more_tran").hide();
  1393. }
  1394. });
  1395. }
  1396. function note_edit_sentence(book, para, begin, end, channal) {
  1397. let channalInfo;
  1398. for (const iterator of _channalData) {
  1399. if (iterator.id == channal) {
  1400. channalInfo = iterator;
  1401. break;
  1402. }
  1403. }
  1404. for (const iterator of _arrData) {
  1405. if (iterator.book == book && iterator.para == para && iterator.begin == begin && iterator.end == end) {
  1406. for (const tran of iterator.translation) {
  1407. if (tran.channal == channal) {
  1408. let html = "";
  1409. html += "<div style='color:blue;'>" + channalInfo.name + "@" + channalInfo.nickname + "</div>";
  1410. html +=
  1411. "<textarea id='edit_dialog_text' sent_id='" +
  1412. tran.id +
  1413. "' book='" +
  1414. book +
  1415. "' para='" +
  1416. para +
  1417. "' begin='" +
  1418. begin +
  1419. "' end='" +
  1420. end +
  1421. "' channal='" +
  1422. channal +
  1423. "' style='width:100%;min-height:260px;'>" +
  1424. tran.text +
  1425. "</textarea>";
  1426. $("#edit_dialog_content").html(html);
  1427. $("#note_sent_edit_dlg").dialog("open");
  1428. return;
  1429. }
  1430. }
  1431. }
  1432. }
  1433. alert("未找到句子");
  1434. }
  1435. function tran_sent_edit_cancel(obj) {
  1436. sent_tran_set_edit_mode(obj, false);
  1437. }
  1438. function tran_sent_save(obj) {
  1439. let sentDiv = find_sent_tran_div(obj);
  1440. if (sentDiv) {
  1441. let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
  1442. let isPr = $(textarea).attr("is_pr");
  1443. if (isPr == "true") {
  1444. note_pr_save(textarea);
  1445. } else {
  1446. note_sent_save_a(textarea);
  1447. }
  1448. sent_tran_set_edit_mode(textarea, false);
  1449. } else {
  1450. console.error("sent div not found");
  1451. }
  1452. }
  1453. //保存pr句子 新
  1454. function note_pr_save(obj) {
  1455. let id = $(obj).attr("dbid");
  1456. let sid = $(obj).attr("sid").split("-");
  1457. let book = sid[0];
  1458. let para = sid[1];
  1459. let begin = sid[2];
  1460. let end = sid[3];
  1461. let channel = $(obj).attr("channel");
  1462. let text = $(obj).val();
  1463. let sent_tran_div = find_sent_tran_div(obj);
  1464. $.post(
  1465. "../usent/pr_post.php",
  1466. {
  1467. id: id,
  1468. book: book,
  1469. para: para,
  1470. begin: begin,
  1471. end: end,
  1472. channel: channel,
  1473. text: text,
  1474. },
  1475. sent_save_callback
  1476. );
  1477. if (sent_tran_div) {
  1478. $(sent_tran_div).addClass("loading");
  1479. }
  1480. }
  1481. //保存译文句子 新
  1482. function note_sent_save_a(obj) {
  1483. let id = $(obj).attr("dbid");
  1484. let sid = $(obj).attr("sid").split("-");
  1485. let book = sid[0];
  1486. let para = sid[1];
  1487. let begin = sid[2];
  1488. let end = sid[3];
  1489. let channal = $(obj).attr("channel");
  1490. let text = $(obj).val();
  1491. let sent_tran_div = find_sent_tran_div(obj);
  1492. /*
  1493. var jqxhr = $.post("example.php", function() {
  1494. alert("success");
  1495. })
  1496. .success(function() { alert("second success"); })
  1497. .error(function() { alert("error"); })
  1498. .complete(function() { alert("complete"); });*/
  1499. /*
  1500. function (data, status) {
  1501. alert("异常!" + data.responseText);
  1502. switch (status) {
  1503. case "timeout":
  1504. break;
  1505. case "error":
  1506. break;
  1507. case "notmodified":
  1508. break;
  1509. case "parsererror":
  1510. break;
  1511. default:
  1512. break;
  1513. }
  1514. */
  1515. var jqxhr = $.post(
  1516. "../usent/sent_post.php",
  1517. {
  1518. id: id,
  1519. book: book,
  1520. para: para,
  1521. begin: begin,
  1522. end: end,
  1523. channal: channal,
  1524. text: text,
  1525. lang: "zh",
  1526. },
  1527. sent_save_callback
  1528. )
  1529. .success(function () {
  1530. //alert("second success");
  1531. })
  1532. .error(function (xhr, error, data) {
  1533. let sid = book + "-" + para + "-" + begin + "-" + end;
  1534. let sent_tran_div = $(".sent_tran[channel='" + channal + "'][sid='" + sid + "']");
  1535. if (sent_tran_div) {
  1536. sent_tran_div.removeClass("loading");
  1537. sent_tran_div.addClass("error");
  1538. }
  1539. switch (error) {
  1540. case "timeout":
  1541. alert("服务器长时间没有回应。请稍后重试。");
  1542. break;
  1543. case "error":
  1544. alert("与服务器通讯失败,您可能没有连接到网络。请稍后重试。");
  1545. break;
  1546. case "notmodified":
  1547. break;
  1548. default:
  1549. break;
  1550. }
  1551. })
  1552. .complete(function (xhr, data) {
  1553. //请求完成后回调函数 (请求成功或失败之后均调用)。
  1554. switch (data) {
  1555. case "error":
  1556. break;
  1557. case "success":
  1558. break;
  1559. default:
  1560. break;
  1561. }
  1562. });
  1563. if (sent_tran_div) {
  1564. $(sent_tran_div).addClass("loading");
  1565. }
  1566. }
  1567. function update_sent_tran(sentData) { }
  1568. function sent_save_callback(data) {
  1569. let result = JSON.parse(data);
  1570. if (result.status > 0) {
  1571. alert("error" + result.message);
  1572. } else {
  1573. let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
  1574. let sent_tran_div = $(
  1575. ".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
  1576. );
  1577. if (result.commit_type == 1 || result.commit_type == 2) {
  1578. ntf_show("成功修改");
  1579. if (sent_tran_div) {
  1580. let divPreview = sent_tran_div.find(".preview").first();
  1581. if (result.text == "") {
  1582. let channel_info = "Empty";
  1583. let thisChannel = find_channal(result.channal);
  1584. if (thisChannel) {
  1585. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1586. }
  1587. divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1588. } else {
  1589. divPreview.html(
  1590. marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
  1591. );
  1592. term_updata_translation();
  1593. popup_init();
  1594. for (const iterator of _arrData) {
  1595. if (
  1596. iterator.book == result.book &&
  1597. iterator.para == result.para &&
  1598. iterator.begin == result.begin &&
  1599. iterator.end == result.end
  1600. ) {
  1601. for (const tran of iterator.translation) {
  1602. if (tran.channal == result.channal) {
  1603. tran.text = result.text;
  1604. break;
  1605. }
  1606. }
  1607. }
  1608. }
  1609. }
  1610. sent_tran_div.removeClass("loading");
  1611. }
  1612. } else if (result.commit_type == 3) {
  1613. ntf_show("已经提交修改建议");
  1614. } else {
  1615. ntf_show("未提交");
  1616. }
  1617. }
  1618. }
  1619. //保存译文句子
  1620. function note_sent_save() {
  1621. let id = $("#edit_dialog_text").attr("sent_id");
  1622. let book = $("#edit_dialog_text").attr("book");
  1623. let para = $("#edit_dialog_text").attr("para");
  1624. let begin = $("#edit_dialog_text").attr("begin");
  1625. let end = $("#edit_dialog_text").attr("end");
  1626. let channal = $("#edit_dialog_text").attr("channal");
  1627. let text = $("#edit_dialog_text").val();
  1628. $.post(
  1629. "../usent/sent_post.php",
  1630. {
  1631. id: id,
  1632. book: book,
  1633. para: para,
  1634. begin: begin,
  1635. end: end,
  1636. channal: channal,
  1637. text: text,
  1638. lang: "zh",
  1639. },
  1640. function (data) {
  1641. let result = JSON.parse(data);
  1642. if (result.status > 0) {
  1643. alert("error" + result.message);
  1644. } else {
  1645. if (result.commit_type == 1 || result.commit_type == 2) {
  1646. ntf_show("成功修改");
  1647. if (result.text == "") {
  1648. let channel_info = "Empty";
  1649. let thisChannel = find_channal(result.channal);
  1650. if (thisChannel) {
  1651. channel_info = thisChannel.name + "-" + thisChannel.nickname;
  1652. }
  1653. $(
  1654. "#tran_text_" +
  1655. result.book +
  1656. "_" +
  1657. result.para +
  1658. "_" +
  1659. result.begin +
  1660. "_" +
  1661. result.end +
  1662. "_" +
  1663. result.channal
  1664. ).html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
  1665. } else {
  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(marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang)));
  1678. term_updata_translation();
  1679. for (const iterator of _arrData) {
  1680. if (
  1681. iterator.book == result.book &&
  1682. iterator.para == result.para &&
  1683. iterator.begin == result.begin &&
  1684. iterator.end == result.end
  1685. ) {
  1686. for (const tran of iterator.translation) {
  1687. if (tran.channal == result.channal) {
  1688. tran.text = result.text;
  1689. break;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. }
  1695. } else if (result.commit_type == 3) {
  1696. ntf_show("已经提交修改建议");
  1697. } else {
  1698. ntf_show("未提交");
  1699. }
  1700. }
  1701. }
  1702. );
  1703. }
  1704. function copy_ref(book, para, begin, end) {
  1705. let strRef = "{{" + book + "-" + para + "-" + begin + "-" + end + "}}";
  1706. copy_to_clipboard(strRef);
  1707. }
  1708. function goto_nissaya(book, para, begin = 0, end = 0) {
  1709. window.open("../nissaya/index.php?book=" + book + "&para=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
  1710. }
  1711. function edit_in_studio(book, para, begin, end) {
  1712. wbw_channal_list_open(book, [para]);
  1713. }
  1714. //显示和隐藏某个内容 如 巴利文
  1715. function setVisibility(key, value) {
  1716. switch (key) {
  1717. case "palitext":
  1718. if ($(value).is(":checked")) {
  1719. $(".palitext").show();
  1720. } else {
  1721. $(".palitext").hide();
  1722. }
  1723. break;
  1724. default:
  1725. break;
  1726. }
  1727. }
  1728. function note_show_pali_sim(SentId) {
  1729. pali_sim_dlg_open(SentId, 0, 20);
  1730. }
  1731. function set_pali_script(pos, script) {
  1732. if (script == "none") {
  1733. $(".palitext" + pos).html("");
  1734. } else {
  1735. $(".palitext" + pos).each(function () {
  1736. let html = $(this).siblings(".palitext_roma").first().html();
  1737. $(this).html(html);
  1738. });
  1739. $(".palitext" + pos)
  1740. .find("*")
  1741. .contents()
  1742. .filter(function () {
  1743. return this.nodeType != 1;
  1744. })
  1745. .wrap("<pl" + pos + "></pl" + pos + ">");
  1746. $(".palitext" + pos)
  1747. .contents()
  1748. .filter(function () {
  1749. return this.nodeType != 1;
  1750. })
  1751. .wrap("<pl" + pos + "></pl" + pos + ">");
  1752. $("pl" + pos).html(function (index, oldcontent) {
  1753. return roman_to_my(oldcontent);
  1754. });
  1755. }
  1756. }
  1757. function splite_pali_word() {
  1758. $("pali")
  1759. .contents()
  1760. .filter(function () {
  1761. return this.nodeType != 1;
  1762. })
  1763. .wrap("<pl></pl>");
  1764. $("pl").each(function () {
  1765. let html = $(this).html();
  1766. $(this).html("<w>" + html.replace(/\s/g, "</w> <w>") + "</w>");
  1767. });
  1768. $("w").click(function () {
  1769. let word = com_getPaliReal($(this).text());
  1770. if (gBuildinDictIsOpen) {
  1771. window.open("../dict/index.php?builtin=true&key=" + word, "dict");
  1772. }
  1773. });
  1774. }
  1775. function refresh_pali_script() {
  1776. if (_display && _display == "para") {
  1777. //段落模式
  1778. } else {
  1779. //句子模式
  1780. setting_get("lib.second_script", set_second_scrip);
  1781. }
  1782. }
  1783. function set_second_scrip(value) {
  1784. set_pali_script(2, value);
  1785. }
  1786. function slider_show(obj) {
  1787. $(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
  1788. }
  1789. function find_sent_tran_div(obj) {
  1790. let jqObj = $(obj);
  1791. while (!jqObj.hasClass("sent_tran")) {
  1792. jqObj = jqObj.parent();
  1793. if (!jqObj) {
  1794. return false;
  1795. }
  1796. }
  1797. return jqObj;
  1798. /*
  1799. let parent = obj.parentNode;
  1800. while (parent.nodeType == 1) {
  1801. if ($(parent).hasClass("sent_tran")) {
  1802. return parent;
  1803. } else if (parent.nodeName == "BODY") {
  1804. return false;
  1805. }
  1806. parent = parent.parentNode;
  1807. }
  1808. return false;
  1809. */
  1810. }
  1811. //显示或隐藏pr数据
  1812. function note_pr_show(channel, id) {
  1813. let obj = $(".sent_tran[channel='" + channel + "'][sid='" + id + "']").find(".pr_content");
  1814. let prHtml = obj.first().html();
  1815. if (prHtml == "") {
  1816. note_get_pr(channel, id);
  1817. } else {
  1818. obj.slideUp();
  1819. obj.html("");
  1820. }
  1821. }
  1822. //获取pr数据并显示
  1823. function note_get_pr(channel, id) {
  1824. let sid = id.split("-");
  1825. let book = sid[0];
  1826. let para = sid[1];
  1827. let begin = sid[2];
  1828. let end = sid[3];
  1829. $.post(
  1830. "../usent/get_pr.php",
  1831. {
  1832. book: book,
  1833. para: para,
  1834. begin: begin,
  1835. end: end,
  1836. channel: channel,
  1837. },
  1838. function (data) {
  1839. let result = JSON.parse(data);
  1840. if (result.length > 0) {
  1841. let html = "<div class='compact'>";
  1842. for (const iterator of result) {
  1843. html += render_one_sent_tran_a(iterator);
  1844. }
  1845. html += "</div>";
  1846. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1847. .find(".pr_content")
  1848. .html(html);
  1849. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1850. .find(".pr_content")
  1851. .slideDown();
  1852. } else {
  1853. }
  1854. }
  1855. );
  1856. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1857. .find(".pr_content")
  1858. .html("loading");
  1859. $(".sent_tran[channel='" + channel + "'][sid='" + id + "']")
  1860. .find(".pr_content")
  1861. .show();
  1862. }
  1863. function get_channel_by_id(id) {
  1864. if (typeof _channalData != "undefined") {
  1865. for (const iterator of _channalData) {
  1866. if (iterator.id == id) {
  1867. return iterator;
  1868. }
  1869. }
  1870. }
  1871. if (typeof _my_channal != "undefined") {
  1872. for (const iterator of _my_channal) {
  1873. if (iterator.id == id) {
  1874. return iterator;
  1875. }
  1876. }
  1877. }
  1878. return false;
  1879. }
  1880. //设置显示方向
  1881. function setDirection(obj) {
  1882. if (obj.value == "row") {
  1883. $("#contents").removeClass("vertical");
  1884. $("#contents").addClass("horizontal");
  1885. _direction = "row";
  1886. } else {
  1887. $("#contents").removeClass("horizontal");
  1888. $("#contents").addClass("vertical");
  1889. _direction = "col";
  1890. }
  1891. }
  1892. //设置逐段或逐句模式
  1893. function setDisplay(obj) {
  1894. if (obj.value == "para") {
  1895. $("#contents").removeClass("sent_mode");
  1896. $("#contents").addClass("para_mode");
  1897. _display = "para";
  1898. } else {
  1899. $("#contents").removeClass("para_mode");
  1900. $("#contents").addClass("sent_mode");
  1901. _display = "sent";
  1902. }
  1903. }