note.js 55 KB

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