note.js 56 KB

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