note.js 55 KB

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