note.js 55 KB

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