render.js 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721
  1. var gDisplayCapacity = 20000;
  2. var gCurrTopParagraph = 0;
  3. var gVisibleParBegin = 0;
  4. var gVisibleParEnd = 10000;
  5. //显示模式
  6. var _display_para_arrange = 0; //0:横向 排列 1:纵向排列
  7. var _display_sbs = 0; //0:逐段 1:逐句
  8. //翻译块显示模式
  9. //在编辑状态下显示预览
  10. var _tran_show_preview_on_edit = true;
  11. //在非编辑状态下显示编辑框
  12. var _tran_show_textarea_esc_edit = true;
  13. var gVisibleParBeginOld = 0;
  14. var gVisibleParEndOld = gDisplayCapacity;
  15. //var gPalitext_length=0
  16. var gtext_max_length = 0;
  17. var g_allparlen_array = new Array();
  18. function palitext_calculator() {
  19. var allText = "";
  20. var allTextLen_array = new Array();
  21. var text_max2_length = 0;
  22. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  23. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  24. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  25. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  26. //bookId=getNodeText(xmlParInfo,"book")
  27. //paragraph=getNodeText(xmlParInfo,"paragraph")
  28. type = getNodeText(xmlParInfo, "type");
  29. if (type == "wbw") {
  30. var wbwTextNode = xmlParData.getElementsByTagName("word");
  31. var para_text_cal = "";
  32. for (var iText = 0; iText < wbwTextNode.length; iText++) {
  33. if (getNodeText(wbwTextNode[iText], "type") != ".ctl.") {
  34. para_text_cal += getNodeText(wbwTextNode[iText], "pali") + " ";
  35. }
  36. }
  37. allText += para_text_cal;
  38. allTextLen_array.push(allText.length);
  39. //gPalitext_length+=para_text_cal.length
  40. if (para_text_cal.length > text_max2_length) {
  41. text_max2_length = para_text_cal.length;
  42. if (text_max2_length > gtext_max_length) {
  43. var num_max_tem = gtext_max_length;
  44. gtext_max_length = text_max2_length;
  45. text_max2_length = num_max_tem;
  46. }
  47. }
  48. }
  49. }
  50. for (i_cal in allTextLen_array) {
  51. g_allparlen_array.push(allTextLen_array[i_cal] / gtext_max_length);
  52. }
  53. gDisplayCapacity = 190000000 + text_max2_length / gtext_max_length;
  54. if (gDisplayCapacity * gtext_max_length < 500000000) {
  55. gDisplayCapacity = 500000000 / gtext_max_length;
  56. }
  57. }
  58. //添加新的段落块
  59. function addNewBlockToHTML(bookId, parId, begin = -1, end = -1) {
  60. parHeadingLevel = 0;
  61. parTitle = "";
  62. var divBlock = document.createElement("div");
  63. var typId = document.createAttribute("id");
  64. if (begin == -1 && end == -1) {
  65. //基于段落的块
  66. typId.nodeValue = "par_" + bookId + "_" + (parId - 1);
  67. } else {
  68. //基于句子的块
  69. typId.nodeValue = "par_" + bookId + "_" + (parId - 1) + "_" + begin + "_" + end;
  70. }
  71. divBlock.attributes.setNamedItem(typId);
  72. var typClass = document.createAttribute("class");
  73. typClass.nodeValue = "pardiv";
  74. divBlock.attributes.setNamedItem(typClass);
  75. var output = '<a name="par_begin_' + bookId + "_" + (parId - 1) + '"></a>';
  76. output += ' <div id="head_tool_' + bookId + "_" + (parId - 1) + '" class="head_tool edit_tool">';
  77. output +=
  78. ' <button id="id_heading_add_new" onclick="editor_heading_add_new(\'' +
  79. bookId +
  80. "','" +
  81. parId +
  82. "')\" >" +
  83. gui_string_editor[0] +
  84. "</button>";
  85. output +=
  86. "<input id='page_break_'" +
  87. bookId +
  88. "_" +
  89. (parId - 1) +
  90. ' type="checkbox" onclick="editor_page_break(this,\'' +
  91. bookId +
  92. "','" +
  93. (parId - 1) +
  94. "')\" />" +
  95. gui_string_editor[1];
  96. output += "</div>";
  97. //heading
  98. output += ' <div id="heading_' + bookId + "_" + (parId - 1) + '" class="par_heading"></div>';
  99. //word by word translate block
  100. //内部可以包含多个wbw块
  101. output += ' <div id="wblock_' + bookId + "_" + (parId - 1) + '" class="wbwdiv"></div>';
  102. //translate div
  103. output += ' <div id="tran_' + bookId + "_" + (parId - 1) + '" class="trandiv"></div>';
  104. //word note div
  105. output += ' <div id="wnote_' + bookId + "_" + (parId - 1) + '" class="wnotediv"></div>';
  106. //note div
  107. output += ' <div id="note_' + bookId + "_" + (parId - 1) + '" class="pnotediv"></div>';
  108. //vedio div
  109. output += ' <div id="vedioblock_' + bookId + "_" + (parId - 1) + '" class="vediodiv"></div>';
  110. divBlock.innerHTML = output;
  111. document.getElementById("sutta_text").appendChild(divBlock);
  112. }
  113. function renderToc(bookId, parBegin, parEnd) {
  114. var firstHeadingLevel = getNodeText(gXmlParIndex[parBegin - 1], "level");
  115. var output = "<ul>";
  116. for (var iPar = parBegin; iPar < parEnd; iPar++) {
  117. parTitle = getNodeText(gXmlParIndex[iPar - 1], "title");
  118. parHeadingLevel = getNodeText(gXmlParIndex[iPar - 1], "level");
  119. if (parHeadingLevel > 0) {
  120. output += '<li class="toc_h_' + (parHeadingLevel - firstHeadingLevel + 1) + '">';
  121. output += '<a href="#par-' + bookId + "-" + iPar + '">' + parTitle + "</a>";
  122. output += "</li>";
  123. }
  124. }
  125. output += "</ul>";
  126. return output;
  127. }
  128. function updataWordParContainer(bookId, parId) {
  129. document.getElementById("wblock-" + bookId + "-" + parId + '"').innerHTML = renderWordParContainerInner(
  130. bookId,
  131. parId
  132. );
  133. }
  134. function renderWordParContainerInner(bookId, parId) {
  135. var strHtml = "";
  136. strHtml += '<div class="wbwparblock">';
  137. strHtml += renderWordParBlockInner(packageIndex);
  138. strHtml += "</div>";
  139. }
  140. //根据block数据更新 目录 列表
  141. function updataToc() {
  142. document.getElementById("content").innerHTML = "";
  143. //创建目录空壳
  144. for (let iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  145. if (gArrayDocParagraph[iPar].level > 0) {
  146. let bookId = gArrayDocParagraph[iPar].book;
  147. let parIndex = gArrayDocParagraph[iPar].paragraph;
  148. let tocId = "toc_" + bookId + "_" + (parIndex - 1);
  149. let str = '<div class="toc_heading">';
  150. str += "<table><tr><td>";
  151. str +=
  152. "<input type='checkbox' checked onclick=\"editor_par_show(this,'" +
  153. bookId +
  154. "','" +
  155. parIndex +
  156. "')\" />";
  157. str += "</td><td>";
  158. str += '<div class="toc_heading_inner" id="' + tocId + '">';
  159. str += "<a onclick=\"editor_goto_link('" + bookId + "'," + parIndex + ')" >[' + parIndex + "]</a>";
  160. str += "</div>";
  161. str += "</td></tr></table>";
  162. str += "</div>";
  163. document.getElementById("content").innerHTML += str;
  164. }
  165. }
  166. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  167. for (let iBlock = 0; iBlock < allBlock.length; iBlock++) {
  168. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  169. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  170. bookId = getNodeText(xmlParInfo, "book");
  171. paragraph = getNodeText(xmlParInfo, "paragraph");
  172. type = getNodeText(xmlParInfo, "type");
  173. if (type == "heading") {
  174. level = getNodeText(xmlParInfo, "level");
  175. //if(level>0)
  176. {
  177. language = getNodeText(xmlParInfo, "language");
  178. bId = getNodeText(xmlParInfo, "id");
  179. strHeadingText = getNodeText(xmlParData, "text");
  180. tocId = "toc_" + bookId + "_" + (paragraph - 1);
  181. /*
  182. var htmlBlock=document.getElementById(tocId)
  183. if(htmlBlock==null){
  184. var str="<div class=\"toc_heading\">";
  185. str += "<table><tr><td>";
  186. str += "<input type='checkbox' checked onclick=\"editor_par_show(this,'"+bookId+"','"+(paragraph-1)+"')\" />";
  187. str += "</td><td>";
  188. str += "<div class=\"toc_heading_inner\" id=\""+tocId+"\"></div>";
  189. str += "</td></tr></table>";
  190. str += "</div>";
  191. document.getElementById("content").innerHTML+=str
  192. }
  193. */
  194. let tocText = '<p class="toc_item_' + level + " " + language + '_text">';
  195. tocText +=
  196. "<a onclick=\"editor_goto_link('" +
  197. bookId +
  198. "'," +
  199. paragraph +
  200. ')" >[' +
  201. paragraph +
  202. "]-" +
  203. strHeadingText +
  204. "</a>";
  205. tocText += "</p>";
  206. $("#toc_" + bookId + "_" + (paragraph - 1)).html(tocText);
  207. }
  208. }
  209. }
  210. palitext_calculator();
  211. }
  212. //向html中插入数据块
  213. function insertBlockToHtml(element) {
  214. xmlParInfo = element.getElementsByTagName("info")[0];
  215. xmlParData = element.getElementsByTagName("data")[0];
  216. let bookId = getNodeText(xmlParInfo, "book");
  217. let paragraph = getNodeText(xmlParInfo, "paragraph");
  218. let base_on = getNodeText(xmlParInfo, "base");
  219. let begin = getNodeText(xmlParInfo, "begin");
  220. let end = getNodeText(xmlParInfo, "end");
  221. type = getNodeText(xmlParInfo, "type");
  222. language = getNodeText(xmlParInfo, "language");
  223. bId = getNodeText(xmlParInfo, "id");
  224. let htmlBlock;
  225. if (base_on == "sentence") {
  226. blockId = "par_" + bookId + "_" + (paragraph - 1) + "_" + begin + "_" + end;
  227. htmlBlock = document.getElementById(blockId);
  228. if (htmlBlock == null) {
  229. addNewBlockToHTML(bookId, paragraph, begin, end);
  230. }
  231. } else {
  232. blockId = "par_" + bookId + "_" + (paragraph - 1);
  233. htmlBlock = document.getElementById(blockId);
  234. if (htmlBlock == null) {
  235. addNewBlockToHTML(bookId, paragraph);
  236. }
  237. }
  238. if (!isParInView(getParIndex(bookId, paragraph))) {
  239. document.getElementById(blockId).style.display = "none";
  240. return;
  241. } else {
  242. document.getElementById(blockId).style.display = "inline-flex";
  243. }
  244. switch (type) {
  245. case "wbw":
  246. var strHtml = renderWordParBlockInner(element);
  247. $("#wnote_" + bookId + "_" + (paragraph - 1)).html(renderNoteShell(element));
  248. var paraDiv = document.createElement("div");
  249. var node = document.createTextNode("");
  250. paraDiv.appendChild(node);
  251. paraDiv.innerHTML = strHtml;
  252. note_refresh_new();
  253. var typ = document.createAttribute("class");
  254. typ.nodeValue = "wbwparblock";
  255. paraDiv.attributes.setNamedItem(typ);
  256. var id = document.createAttribute("id");
  257. id.nodeValue = "id_wbw_" + bId;
  258. paraDiv.attributes.setNamedItem(id);
  259. blockId = "wblock_" + bookId + "_" + (paragraph - 1);
  260. document.getElementById(blockId).appendChild(paraDiv);
  261. refreshWordNoteDiv(element);
  262. refreshNoteNumber();
  263. break;
  264. case "translate":
  265. var strHtml = "";
  266. strHtml = renderTranslateParBlockInner(element);
  267. var paraDiv = document.createElement("div");
  268. var node = document.createTextNode("");
  269. paraDiv.appendChild(node);
  270. paraDiv.innerHTML = strHtml;
  271. var typ = document.createAttribute("class");
  272. typ.nodeValue = "tran_parblock " + language + "_text";
  273. paraDiv.attributes.setNamedItem(typ);
  274. var id = document.createAttribute("id");
  275. id.nodeValue = "id_tran_" + bId;
  276. paraDiv.attributes.setNamedItem(id);
  277. blockId = "tran_" + bookId + "_" + (paragraph - 1);
  278. document.getElementById(blockId).appendChild(paraDiv);
  279. //逐句
  280. if (_display_sbs == 1) {
  281. let eAllSent = document.getElementById(blockId).getElementsByClassName("tran_sent");
  282. for (let iSen = 0; iSen < eAllSent.length; iSen++) {
  283. let senA = eAllSent[iSen].getAttributeNode("sn").value;
  284. let blockId = eAllSent[iSen].getAttributeNode("block").value;
  285. let eSBSDiv = document.getElementById("sent_" + senA);
  286. if (eSBSDiv) {
  287. let eBlockSenDiv = document.getElementById("sent_" + senA + "_" + blockId);
  288. if (!eBlockSenDiv) {
  289. //没有 添加
  290. let divSen = document.createElement("div");
  291. let typ = document.createAttribute("class");
  292. typ.nodeValue = "sbs_sent_block";
  293. divSen.attributes.setNamedItem(typ);
  294. let typId = document.createAttribute("id");
  295. typId.nodeValue = "sent_" + senA + "_" + blockId;
  296. divSen.attributes.setNamedItem(typId);
  297. let sn = document.createAttribute("sn");
  298. sn.nodeValue = senA;
  299. divSen.attributes.setNamedItem(sn);
  300. let block = document.createAttribute("block");
  301. block.nodeValue = blockId;
  302. divSen.attributes.setNamedItem(block);
  303. divSen.innerHTML = eAllSent[iSen].innerHTML;
  304. eSBSDiv.appendChild(divSen);
  305. } else {
  306. eBlockSenDiv.innerHTML = eAllSent[iSen].innerHTML;
  307. }
  308. eAllSent[iSen].innerHTML = "";
  309. }
  310. }
  311. }
  312. break;
  313. case "note":
  314. var strHtml = "";
  315. strHtml = renderNoteParBlockInner(element);
  316. var paraDiv = document.createElement("div");
  317. var node = document.createTextNode("");
  318. paraDiv.appendChild(node);
  319. paraDiv.innerHTML = strHtml;
  320. var typ = document.createAttribute("class");
  321. typ.nodeValue = "note_parblock " + language + "_text";
  322. paraDiv.attributes.setNamedItem(typ);
  323. var id = document.createAttribute("id");
  324. id.nodeValue = "id_note_" + bId;
  325. paraDiv.attributes.setNamedItem(id);
  326. blockId = "note_" + bookId + "_" + (paragraph - 1);
  327. document.getElementById(blockId).appendChild(paraDiv);
  328. document.getElementById(blockId).style.display = "block";
  329. break;
  330. case "heading":
  331. headingLevel = getNodeText(xmlParInfo, "level");
  332. var strHtml = "";
  333. strHtml = renderHeadingBlockInner(element);
  334. var paraDiv = document.createElement("div");
  335. var node = document.createTextNode("");
  336. paraDiv.appendChild(node);
  337. paraDiv.innerHTML = strHtml;
  338. var typ = document.createAttribute("class");
  339. typ.nodeValue = "heading_parblock_" + headingLevel + "_" + language + " " + language + "_text";
  340. paraDiv.attributes.setNamedItem(typ);
  341. var id = document.createAttribute("id");
  342. id.nodeValue = "id_heading_" + bId;
  343. paraDiv.attributes.setNamedItem(id);
  344. blockId = "heading_" + bookId + "_" + (paragraph - 1);
  345. document.getElementById(blockId).appendChild(paraDiv);
  346. document.getElementById(blockId).style.display = "block";
  347. //document.getElementById("id_heading_level_"+bookId+"_"+(paragraph-1)).value=headingLevel;
  348. break;
  349. }
  350. guide_init();
  351. }
  352. function updataHeadingBlockInHtml(book, par) {
  353. document.getElementById("heading_" + book + "_" + (par - 1)).innerHTML = "";
  354. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  355. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  356. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  357. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  358. bookId = getNodeText(xmlParInfo, "book");
  359. paragraph = getNodeText(xmlParInfo, "paragraph");
  360. type = getNodeText(xmlParInfo, "type");
  361. if (type == "heading" && bookId == book && paragraph == par) {
  362. insertBlockToHtml(allBlock[iBlock]);
  363. }
  364. }
  365. }
  366. function renderBlock() {}
  367. /*
  368. 重绘翻译数据块
  369. */
  370. function update_tran_sent(blockId, begin, end) {
  371. let eBlock = document.getElementById("id_tran_" + blockId);
  372. if (eBlock) {
  373. eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
  374. term_updata_translation();
  375. }
  376. /*
  377. $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
  378. term_updata_translation();
  379. */
  380. }
  381. /*
  382. 更新翻译数据块数据
  383. */
  384. function update_tran_block_text(blockId) {
  385. let block = doc_tran("#" + blockId);
  386. if (block != null) {
  387. let book = block.info("book");
  388. let para = block.info("paragraph");
  389. let sent = block.list();
  390. if (sent != null) {
  391. for (const element of sent) {
  392. let eText = document.getElementById("ta_" + blockId + "_" + element.begin + "_" + element.end);
  393. if (eText) {
  394. eText.innerHTML = element.text;
  395. }
  396. let eLable = document.getElementById(
  397. "tran_pre_" + blockId + "_p" + book + "-" + para + "-" + element.end
  398. );
  399. if (eLable) {
  400. eLable.innerHTML = element.text;
  401. }
  402. }
  403. term_updata_translation();
  404. }
  405. }
  406. }
  407. /*
  408. 重绘翻译数据块
  409. */
  410. function update_tran_block(blockId) {
  411. let eBlock = document.getElementById("id_tran_" + blockId);
  412. if (eBlock) {
  413. eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
  414. term_updata_translation();
  415. }
  416. /*
  417. $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
  418. term_updata_translation();
  419. */
  420. }
  421. //譯文段落渲染
  422. function renderTranslateParBlockInnerById(blockId) {
  423. var xBlock = gXmlBookDataBody.getElementsByTagName("block");
  424. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  425. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  426. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  427. bId = getNodeText(xmlParInfo, "id");
  428. if (bId == blockId) {
  429. return renderTranslateParBlockInner(xBlock[iBlock]);
  430. }
  431. }
  432. }
  433. //譯文段落渲染
  434. function renderTranslateParBlockInner(elementBlock) {
  435. var output = "";
  436. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  437. var book = getNodeText(xmlParInfo, "book");
  438. var paragraph = getNodeText(xmlParInfo, "paragraph");
  439. var bId = getNodeText(xmlParInfo, "id");
  440. var power = getNodeText(xmlParInfo, "power");
  441. var readonly = getNodeText(xmlParInfo, "readonly");
  442. par_num = paragraph - 1;
  443. type = getNodeText(xmlParInfo, "type");
  444. language = getNodeText(xmlParInfo, "language");
  445. var allSen = elementBlock.getElementsByTagName("sen");
  446. output += "<div>";
  447. for (iSen = 0; iSen < allSen.length; iSen++) {
  448. var senText = getNodeText(allSen[iSen], "text");
  449. var senBegin = getNodeText(allSen[iSen], "begin");
  450. var senEnd = getNodeText(allSen[iSen], "end");
  451. var senA = "p" + book + "-" + paragraph + "-" + senEnd;
  452. output +=
  453. "<div id='tran_sent_" + bId + "_" + senA + "' block='" + bId + "' sn='" + senA + "' class='tran_sent' >";
  454. if (power != "read") {
  455. //可写入模式
  456. if (readonly != 1) {
  457. output +=
  458. "<div class='tran_sent_inner' onmouseenter=\"tran_sent_div_mouseenter('" +
  459. bId +
  460. "','" +
  461. senA +
  462. "')\" >";
  463. }
  464. } else {
  465. output += "<div class='tran_sent_inner' >";
  466. }
  467. output += "<div id='tran_pre_" + bId + "_" + senA + "' class='tran_sent_pre'>";
  468. if (senText == "") {
  469. output += "<span style='color:gray;'>" + gLocal.gui.translation + "</span>";
  470. } else {
  471. output += term_std_str_to_tran(senText);
  472. }
  473. output += "</div>";
  474. output += "<div id='tran_sent_text_div_" + bId + "_" + senA + "' class='tran_sen_textarea'";
  475. //在非编辑状态下 不显示 编辑框
  476. if (_tran_show_textarea_esc_edit == false) {
  477. output += " style='display:none'";
  478. }
  479. output += ">";
  480. //只读权限不显示修改框
  481. if (power != "read") {
  482. //可写入模式
  483. if (readonly != 1) {
  484. //只读模式不显示修改框 只有power=write才考虑只读模式
  485. output += "<textarea id='ta_" + bId + "_" + senBegin + "_" + senEnd + "' ";
  486. output += " onkeyup=\"updateTranslationPreview('" + bId + "_" + senA + "',this)\" ";
  487. output += " onchange=\"tran_text_onchange('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
  488. //output += " onchange=\"sen_save('"+bId+"','"+senBegin+"','"+senEnd+"',this.value)\" ";
  489. output += " onblur=\"tran_sent_div_blur('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
  490. output +=
  491. " onfocus=\"tran_sent_div_onfocus('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" >";
  492. senText = senText.replace(/\<br \/\>/g, "\n\n");
  493. output += term_std_str_to_edit(senText);
  494. output += "</textarea>";
  495. }
  496. }
  497. output += "</div>";
  498. output += '<div class="tran_sent_text_tool_bar">';
  499. //output += "<button onclick=\"tran_sen_save_click('"+bId+"','"+senBegin+"','"+senEnd+"',this)\">Save</button>";
  500. output += "<span></span>";
  501. output +=
  502. "<span onclick=\"show_tran_msg('" +
  503. bId +
  504. "','" +
  505. senBegin +
  506. "','" +
  507. senEnd +
  508. "')\"><span id='' class=\"word_msg\"></span></span>";
  509. output += "</div>";
  510. output += "</div>";
  511. output += "</div>";
  512. output += "</div>";
  513. }
  514. output += "</div>";
  515. return output;
  516. }
  517. function renderTranslateParBlockInnerPreview(strText) {}
  518. function updateTranslationPreview_a(blockId, text) {
  519. let out = "";
  520. let newText = text;
  521. newText = marked(newText);
  522. //newText = term_tran_edit_replace(newText);
  523. //newText = term_edit_to_std_str(newText);
  524. newText = term_std_str_to_tran(newText);
  525. out += newText;
  526. if (out == "") {
  527. out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
  528. }
  529. $("#tran_pre_" + blockId).html(out);
  530. term_updata_translation();
  531. }
  532. function updateTranslationPreview(blockId, obj) {
  533. let out = "";
  534. let newText = obj.value;
  535. newText = marked(newText);
  536. //newText = term_tran_edit_replace(newText);
  537. //newText = term_edit_to_std_str(newText);
  538. let channal = $(obj).attr("channal");
  539. let lang = $(obj).attr("lang");
  540. newText = term_std_str_to_tran(newText, channal, getCookie("userid"), lang);
  541. out += newText;
  542. if (out == "") {
  543. out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
  544. }
  545. $("#tran_pre_" + blockId).html(out);
  546. term_updata_translation();
  547. }
  548. function getSuperTranslateModifyString(inString, par_num, par_guid, language) {
  549. var curr_super_info = getPrevNextTrans_Guid("curr", par_guid);
  550. var arrString = translate_split(curr_super_info.senText, language).string;
  551. var output = "";
  552. var arrString_last = "";
  553. var sent_ID = "";
  554. var arr_sentA_ID = g_arr_Para_ID[par_num];
  555. var y = 0;
  556. for (y in arr_par_sent_num) {
  557. //得到本段句子外殻數0~par_num_last
  558. var arr_sentID = arr_par_sent_num[y].split("_");
  559. if (arr_sentID[1] == par_num) {
  560. var par_num_last = arr_sentID[2];
  561. }
  562. }
  563. if (par_num_last >= arrString.length - 1) {
  564. //外殻數大於等於切分結果,執行充填
  565. for (var x = 0; x < arrString.length; x++) {
  566. //整段渲染
  567. sent_ID = "sent_" + arr_sentA_ID[x];
  568. var superStringPosition_Start = 0;
  569. var superStringPosition_End = 0;
  570. var superString = translate_super_split(arrString[x], language).string;
  571. var language_type = translate_super_split(arrString[x], language).language_type;
  572. var output_super = "";
  573. for (var super_x = 0; super_x < superString.length; super_x++) {
  574. superStringPosition_End = superStringPosition_Start;
  575. superStringPosition_Start += superString[super_x].length;
  576. output_super +=
  577. "<span id='SBS_senA_" +
  578. par_guid +
  579. "_" +
  580. superStringPosition_End +
  581. "' class=\"tran_sen\" style='display:none'>";
  582. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  583. output_super += "</span>";
  584. output_super +=
  585. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  586. output_super += superString[super_x];
  587. output_super += '<span class="tooltiptext tooltip-bottom">';
  588. output_super +=
  589. "<button onclick='super_trans_modify(up_sen," +
  590. superStringPosition_Start +
  591. "," +
  592. par_guid +
  593. "," +
  594. language +
  595. ")'>▲</button>";
  596. output_super +=
  597. "<button onclick='super_trans_modify(down_sen," +
  598. superStringPosition_End +
  599. "," +
  600. par_guid +
  601. "," +
  602. language +
  603. ")'>▼</button>";
  604. output_super += "</span></span>";
  605. }
  606. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  607. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  608. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  609. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  610. } else {
  611. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  612. }
  613. }
  614. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  615. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  616. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  617. }
  618. } else if (par_num_last < arrString.length - 1) {
  619. //外殻數小於切分結果
  620. for (var x = 0; x < par_num_last; x++) {
  621. //除最後一句,其他充填
  622. //整段渲染
  623. sent_ID = "sent_" + arr_sentA_ID[x];
  624. var superStringPosition_Start = 0;
  625. var superStringPosition_End = 0;
  626. var superString = translate_super_split(arrString[x], language).string;
  627. var language_type = translate_super_split(arrString[x], language).language_type;
  628. var output_super = "";
  629. for (var super_x = 0; super_x < superString.length; super_x++) {
  630. superStringPosition_End = superStringPosition_Start;
  631. superStringPosition_Start += superString[super_x].length;
  632. output_super +=
  633. "<span id='SBS_senA_" +
  634. par_guid +
  635. "_" +
  636. superStringPosition_End +
  637. "' class=\"tran_sen\" style='display:none'>";
  638. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  639. output_super += "</span>";
  640. output_super +=
  641. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  642. output_super += superString[super_x];
  643. output_super += '<span class="tooltiptext tooltip-bottom">';
  644. output_super +=
  645. "<button onclick='super_trans_modify(up_sen," +
  646. superStringPosition_Start +
  647. "," +
  648. par_guid +
  649. "," +
  650. language +
  651. ")'>▲</button>";
  652. output_super +=
  653. "<button onclick='super_trans_modify(down_sen," +
  654. superStringPosition_End +
  655. "," +
  656. par_guid +
  657. "," +
  658. language +
  659. ")'>▼</button>";
  660. output_super += "</span></span>";
  661. }
  662. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  663. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  664. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  665. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  666. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  667. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  668. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  669. } else {
  670. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  671. }
  672. }
  673. }
  674. var output_super = "";
  675. for (var x = par_num_last; x < arrString.length - 1; x++) {
  676. //最後一句,合併所有譯文
  677. var superString = translate_super_split(arrString[x], language).string;
  678. var language_type = translate_super_split(arrString[x], language).language_type;
  679. for (var super_x = 0; super_x < superString.length; super_x++) {
  680. superStringPosition_End = superStringPosition_Start;
  681. superStringPosition_Start += superString[super_x].length;
  682. output_super +=
  683. "<span id='SBS_senA_" +
  684. par_guid +
  685. "_" +
  686. superStringPosition_End +
  687. "' class=\"tran_sen\" style='display:none'>";
  688. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  689. output_super += "</span>";
  690. output_super +=
  691. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  692. output_super += superString[super_x];
  693. output_super += '<span class="tooltiptext tooltip-bottom">';
  694. output_super +=
  695. "<button onclick='super_trans_modify(up_sen," +
  696. superStringPosition_Start +
  697. "," +
  698. par_guid +
  699. "," +
  700. language +
  701. ")'>▲</button>";
  702. output_super +=
  703. "<button onclick='super_trans_modify(down_sen," +
  704. superStringPosition_End +
  705. "," +
  706. par_guid +
  707. "," +
  708. language +
  709. ")'>▼</button>";
  710. output_super += "</span></span>";
  711. }
  712. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  713. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  714. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  715. }
  716. sent_ID = "sent_" + arr_sentA_ID[par_num_last];
  717. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  718. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  719. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  720. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  721. } else {
  722. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  723. }
  724. }
  725. }
  726. return output;
  727. }
  728. function super_trans_modify(updown, superStringPosition, par_guid, language) {
  729. //未完成
  730. var prev_super_info = getPrevNextTrans_Guid(prev, par_guid);
  731. var next_super_info = getPrevNextTrans_Guid(next, par_guid);
  732. var curr_super_info = getPrevNextTrans_Guid(curr, par_guid);
  733. var new_prev_super_info = new Object();
  734. var new_next_super_info = new Object();
  735. var new_curr_super_info = new Object();
  736. switch (updown) {
  737. case "up_par":
  738. new_prev_super_info.GUID = prev_super_info.GUID;
  739. new_prev_super_info.senText =
  740. prev_super_info.senText + curr_super_info.senText.replace(/#/g, "").slice(0, superStringPosition);
  741. var new_senText_array = translate_super_split(new_prev_super_info.senText, language);
  742. new_prev_super_info.senA = "0_";
  743. for (new_senText_array_i in new_senText_array) {
  744. new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
  745. new_prev_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
  746. if (new_senText_array_i == new_senText_array.length - 1) {
  747. new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
  748. break;
  749. }
  750. }
  751. new_prev_super_info.senA = (new_prev_super_info.senA + "#").replace(/##/g, "");
  752. new_curr_super_info.GUID = curr_super_info.GUID;
  753. new_curr_super_info.senText = curr_super_info.senText.replace(/#/g, "").slice(superStringPosition);
  754. var new_senText_array = translate_super_split(new_curr_super_info.senText, language);
  755. new_curr_super_info.senA = "";
  756. for (new_senText_array_i in new_senText_array) {
  757. new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
  758. new_curr_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
  759. if (new_senText_array_i == new_senText_array.length - 1) {
  760. new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
  761. break;
  762. }
  763. }
  764. new_curr_super_info.senA = (new_curr_super_info.senA + "#").replace(/##/g, "");
  765. break;
  766. case "down_par":
  767. if (par_num > max_par_num) {
  768. //无效通知
  769. }
  770. break;
  771. }
  772. }
  773. function getPrevNextTrans_Guid(direction, par_guid) {
  774. var allBlock = gXmlBookDataBody.getElementsByTagName("block"); //得到全局block
  775. var prev_super_info = new Object();
  776. var next_super_info = new Object();
  777. var curr_super_info = new Object();
  778. var super_arr_xmlParInfo = new Array();
  779. var super_arr_xmlParData = new Array();
  780. var super_arr_xmlParAllsen = new Array();
  781. var super_arr_xmlParAllloc = new Array();
  782. curr_super_info.GUID = par_guid;
  783. for (var super_iBlock = 0; super_iBlock < allBlock.length; super_iBlock++) {
  784. if (super_iBlock == "length") {
  785. break;
  786. }
  787. var elementBlock = allBlock[super_iBlock]; //得到其中一段的數據
  788. if (elementBlock.getElementsByTagName("sen").length != 0) {
  789. super_arr_xmlParInfo.push(elementBlock.getElementsByTagName("info")[0]);
  790. super_arr_xmlParData.push(elementBlock.getElementsByTagName("data")[0]);
  791. }
  792. }
  793. if (elementBlock.getElementsByTagName("sen").length != 0) {
  794. for (var super_iData in super_arr_xmlParData) {
  795. var super_xmlParAll_Sen = "";
  796. var super_xmlParAll_Loc = "";
  797. for (var super_iSen = 0; super_iSen < super_arr_xmlParData[super_iData].childNodes.length; super_iSen++) {
  798. var super_xmlParData_Detail = super_arr_xmlParData[super_iData].childNodes[super_iSen];
  799. super_xmlParAll_Sen += super_xmlParData_Detail.getElementsByTagName("text")[0].innerHTML + "#";
  800. super_xmlParAll_Loc += super_xmlParData_Detail.getElementsByTagName("a")[0].innerHTML + "#";
  801. }
  802. super_xmlParAll_Sen = (super_xmlParAll_Sen + "#").replace(/##/g, "");
  803. super_xmlParAll_Loc = (super_xmlParAll_Loc + "#").replace(/##/g, "");
  804. super_arr_xmlParAllsen.push(super_xmlParAll_Sen);
  805. super_arr_xmlParAllloc.push(super_xmlParAll_Loc);
  806. }
  807. for (var super_iBlock = 0; super_iBlock < super_arr_xmlParInfo.length; super_iBlock++) {
  808. if (super_iBlock == "length") {
  809. break;
  810. }
  811. var super_GUID = getNodeText(super_arr_xmlParInfo[super_iBlock], "id"); //得到guid
  812. prev_super_info.senText = "";
  813. prev_super_info.senA = "";
  814. curr_super_info.senText = super_arr_xmlParAllsen[super_iBlock];
  815. curr_super_info.senA = super_arr_xmlParAllloc[super_iBlock];
  816. next_super_info.senText = "";
  817. next_super_info.senA = "";
  818. if (super_GUID == par_guid && super_iBlock == 0) {
  819. prev_super_info.GUID = ""; //前一個為空
  820. next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
  821. next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
  822. next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
  823. break;
  824. } else if (super_GUID == par_guid && super_iBlock > 0 && super_iBlock < super_arr_xmlParAllsen.length - 1) {
  825. prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
  826. next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
  827. prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
  828. prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
  829. next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
  830. next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
  831. break;
  832. } else if (super_GUID == par_guid && super_iBlock == super_arr_xmlParAllsen.length - 1) {
  833. prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
  834. next_super_info.GUID = "";
  835. prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
  836. prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
  837. break;
  838. }
  839. }
  840. } else {
  841. prev_super_info.GUID = "";
  842. prev_super_info.senText = "";
  843. prev_super_info.senA = "";
  844. curr_super_info.GUID = "";
  845. curr_super_info.senText = "";
  846. curr_super_info.senA = "";
  847. next_super_info.GUID = "";
  848. next_super_info.senText = "";
  849. next_super_info.senA = "";
  850. }
  851. switch (direction) {
  852. case "next":
  853. return next_super_info;
  854. break;
  855. case "curr":
  856. return curr_super_info;
  857. break;
  858. case "prev":
  859. return prev_super_info;
  860. break;
  861. }
  862. }
  863. function translate_split(inString, language) {
  864. var newString = "";
  865. var arrString = new Object();
  866. var language_type = "";
  867. if (
  868. language.toLowerCase() == "tw" ||
  869. language.toLowerCase() == "zh" ||
  870. language.toLowerCase() == "sc" ||
  871. language.toLowerCase() == "tc"
  872. ) {
  873. language_type = "ZH";
  874. } else {
  875. language_type = "EN";
  876. }
  877. arrString.language_type = language_type.toLowerCase();
  878. switch (language_type) {
  879. case "ZH":
  880. for (var i_cntransplit in cn_transplit) {
  881. newString = inString;
  882. eval("newString = newString.replace(" + cn_transplit[i_cntransplit] + ")");
  883. }
  884. /*newString = inString.replace(/。/g,"。#");
  885. newString = newString.replace(/;/g,";");
  886. newString = newString.replace(/ /g,"");
  887. newString = newString.replace(/;/g,";#");
  888. newString = newString.replace(/?/g,"?#");
  889. newString = newString.replace(/”“/g,"”#“");
  890. newString = newString.replace(/’‘/g,"’#‘");
  891. newString = newString.replace(/。#”/g,"。”#");
  892. newString = newString.replace(/?#”/g,"?”#");
  893. newString = newString.replace(/?“/g,"?#“");
  894. newString = newString.replace(/:“/g,":#“");
  895. newString = newString.replace(/:「/g,":#「");
  896. newString = newString.replace(/!#’/g,"!’#");
  897. newString = newString.replace(/。#’/g,"。’#");
  898. newString = newString.replace(/?#’/g,"?’#");
  899. newString = newString.replace(/?‘/g,"?#‘");
  900. newString = newString.replace(/:‘/g,":#‘");
  901. newString = newString.replace(/##/g,"#");
  902. */
  903. arrString.string = newString.split("#");
  904. break;
  905. case "EN":
  906. newString = inString;
  907. for (var i_entransplit in en_transplit) {
  908. newString = inString;
  909. eval("newString = newString.replace(" + en_transplit[i_entransplit] + ")");
  910. }
  911. /*newString = inString.replace(/\./g,"\.#");
  912. newString = newString.replace(/;/g,";");
  913. newString = newString.replace(/;/g,";#");
  914. newString = newString.replace(/\?/g,"?#");
  915. newString = newString.replace(/\"\"/g,"”#“");
  916. newString = newString.replace(/.\'\'/g,".”");
  917. newString = newString.replace(/.#\"/g,".”#");
  918. newString = newString.replace(/\?#\"/g,"?”#");
  919. newString = newString.replace(/\?“/g,"?#“");
  920. newString = newString.replace(/,\"/g,",#“");
  921. newString = newString.replace(/!#\'/g,"!’#");
  922. newString = newString.replace(/.#\'/g,".’#");
  923. newString = newString.replace(/?#’/g,"?’#");
  924. newString = newString.replace(/?‘/g,"?#‘");
  925. newString = newString.replace(/##/g,"#");
  926. */
  927. arrString.string = newString.split("#");
  928. break;
  929. }
  930. return arrString;
  931. // body...
  932. }
  933. function translate_super_split(inString) {
  934. var newString = inString;
  935. var arrString = new Object();
  936. var language_type = "";
  937. if (
  938. language.toLowerCase() == "tw" ||
  939. language.toLowerCase() == "zh" ||
  940. language.toLowerCase() == "sc" ||
  941. language.toLowerCase() == "tc"
  942. ) {
  943. language_type = "ZH";
  944. } else {
  945. language_type = "EN";
  946. }
  947. arrString.language_type = language_type.toLowerCase();
  948. switch (language_type) {
  949. case "ZH":
  950. newString = newString.replace(/,/g, ",#");
  951. newString = newString.replace(/!/g, "!#");
  952. newString = newString.replace(/!#”/g, "!”#");
  953. newString = newString.replace(/!#’/g, "!’#");
  954. arrString.string = newString.split("#");
  955. break;
  956. case "EN":
  957. newString = newString.replace(/,/g, ",#");
  958. newString = newString.replace(/!/g, "!#");
  959. arrString.string = newString.split("#");
  960. break;
  961. }
  962. return arrString;
  963. // body...
  964. }
  965. function renderNoteParBlockInner(elementBlock) {
  966. var output = "";
  967. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  968. book = getNodeText(xmlParInfo, "book");
  969. paragraph = getNodeText(xmlParInfo, "paragraph");
  970. bId = getNodeText(xmlParInfo, "id");
  971. type = getNodeText(xmlParInfo, "type");
  972. var allSen = elementBlock.getElementsByTagName("sen");
  973. output +=
  974. '<button type="button" class="edit_note_button imgbutton" onclick="editor_note_edit(\'' +
  975. bId +
  976. "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
  977. for (iSen = 0; iSen < allSen.length; iSen++) {
  978. senText = getNodeText(allSen[iSen], "text");
  979. senA = getNodeText(allSen[iSen], "a");
  980. output += '<span id="note_sen_' + bId + "_" + iSen + '" class="note_sen">';
  981. output += senText;
  982. output += "</span>";
  983. }
  984. return output;
  985. }
  986. function renderHeadingBlockInner(elementBlock) {
  987. var output = "";
  988. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  989. book = getNodeText(xmlParInfo, "book");
  990. paragraph = getNodeText(xmlParInfo, "paragraph");
  991. bId = getNodeText(xmlParInfo, "id");
  992. type = getNodeText(xmlParInfo, "type");
  993. var headingData = elementBlock.getElementsByTagName("data")[0];
  994. headingText = getNodeText(headingData, "text");
  995. output += '<span id="id_heading_text_' + bId + '">' + headingText + "</span>";
  996. output +=
  997. '<button type="button" class="edit_tool imgbutton" onclick="editor_heading_edit(\'' +
  998. bId +
  999. "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
  1000. return output;
  1001. }
  1002. function updateWordParBlockInnerAll() {
  1003. var xBlock = gXmlBookDataBody.getElementsByTagName("block");
  1004. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  1005. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  1006. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  1007. mId = getNodeText(xmlParInfo, "id");
  1008. type = getNodeText(xmlParInfo, "type");
  1009. if ((type = "wbw")) {
  1010. updateWordParBlockInner(xBlock[iBlock]);
  1011. }
  1012. }
  1013. }
  1014. function updateWordParBlockInner(elementBlock) {
  1015. var xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1016. var blockId = getNodeText(xmlParInfo, "id");
  1017. var wbwblock = document.getElementById("id_wbw_" + blockId);
  1018. if (wbwblock) {
  1019. wbwblock.innerHTML = renderWordParBlockInner(elementBlock);
  1020. word_mouse_event();
  1021. note_refresh_new();
  1022. }
  1023. }
  1024. function renderNoteShell(elementBlock) {
  1025. let output = "";
  1026. let allWord = elementBlock.getElementsByTagName("word");
  1027. for (iWord = 0; iWord < allWord.length; iWord++) {
  1028. let wID = getNodeText(allWord[iWord], "id");
  1029. output += '<div id="wn_' + wID + '">';
  1030. output += '<div id="wnn_' + wID + '"></div>';
  1031. output += '<div id="wnr_' + wID + '"></div>';
  1032. output += '<div id="wnc_' + wID + '"></div>';
  1033. output += "</div>";
  1034. }
  1035. return output;
  1036. }
  1037. //句子上面的工具条
  1038. function render_sent_tool_bar(elementBlock, begin) {
  1039. let output = "";
  1040. let axmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1041. let abook = getNodeText(axmlParInfo, "book");
  1042. let aparagraph = getNodeText(axmlParInfo, "paragraph");
  1043. let xallWord = elementBlock.getElementsByTagName("word");
  1044. let iBegin = -1;
  1045. let iEnd = -1;
  1046. let iWordId = 0;
  1047. for (let i = 0; i < xallWord.length; i++) {
  1048. let aID = getNodeText(xallWord[i], "id");
  1049. let aEnter = getNodeText(xallWord[i], "enter");
  1050. let arrId = aID.split("-");
  1051. iWordId = parseInt(arrId[2]);
  1052. if (iWordId > begin && iBegin < 0) {
  1053. iBegin = iWordId;
  1054. }
  1055. if (iWordId > begin && aEnter == "1") {
  1056. //句子末尾
  1057. iEnd = iWordId;
  1058. break;
  1059. }
  1060. }
  1061. if (iEnd == -1) {
  1062. iEnd = iWordId;
  1063. }
  1064. output += "<div class='sent_wbw_trans_bar'>";
  1065. let sentIdString = abook + "-" + aparagraph + "-" + iBegin + "-" + iEnd;
  1066. let sentIdStringLink = "{{" + sentIdString + "}}";
  1067. let sentReaderLink = "";
  1068. if (_display_sbs == 0) {
  1069. //逐段模式
  1070. sentReaderLink = "https://www.wikipali.org/app/reader/?view=para&book=" + abook + "&para=" + aparagraph;
  1071. } else {
  1072. //逐句模式
  1073. sentReaderLink =
  1074. "https://www.wikipali.org/app/reader/?view=sent&book=" +
  1075. abook +
  1076. "&para=" +
  1077. aparagraph +
  1078. "&begin=" +
  1079. iBegin +
  1080. "&end=" +
  1081. iEnd;
  1082. }
  1083. output +=
  1084. "<span style='flex: 7;display: flex;'><div style='background-color: silver;'><span style='font-size: large; font-weight: bolder;' title=" +
  1085. gLocal.gui.text_num +
  1086. ">" +
  1087. sentIdString +
  1088. "</span><button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1089. sentIdStringLink +
  1090. "')\" title=" +
  1091. gLocal.gui.copy_to_clipboard +
  1092. ">";
  1093. output +=
  1094. '<svg style="fill: var(--link-color);" t="1601480724259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4644"><path d="M791.272727 93.090909H139.636364v837.818182a93.090909 93.090909 0 0 1-93.090909-93.090909V93.090909a93.090909 93.090909 0 0 1 93.090909-93.090909h558.545454a93.090909 93.090909 0 0 1 93.090909 93.090909zM232.727273 186.181818h744.727272v837.818182H232.727273V186.181818z" p-id="4645"></path></svg>';
  1095. output += "</button>";
  1096. // output += "<span>"+abook+"-"+aparagraph+"-"+iBegin+"-"+iEnd+"</span>";
  1097. if (_display_sbs == 0) {
  1098. //逐段模式
  1099. output +=
  1100. "<button class='icon_btn' onclick=\"window.open('../reader/?view=para&book=" +
  1101. abook +
  1102. "&para=" +
  1103. aparagraph +
  1104. "')\" target='_blank' title='" +
  1105. gLocal.gui.scan_in_reader +
  1106. "'>";
  1107. } else {
  1108. //逐句模式
  1109. output +=
  1110. "<button class='icon_btn' onclick=\"window.open('../reader/?view=sent&book=" +
  1111. abook +
  1112. "&para=" +
  1113. aparagraph +
  1114. "&begin=" +
  1115. iBegin +
  1116. "&end=" +
  1117. iEnd +
  1118. "')\" target='_blank' title='" +
  1119. gLocal.gui.scan_in_reader +
  1120. "'>";
  1121. }
  1122. output +=
  1123. '<svg style="fill: var(--link-color);" t="1601482753387" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22291"><path d="M703.730499 544.578527a191.730499 191.730499 0 0 1 156.260356 302.806368l122.004508 122.004507a31.955083 31.955083 0 0 1-45.248398 45.184488l-121.940597-121.940598A191.730499 191.730499 0 1 1 703.730499 544.642437z m-6.391017-511.28133c38.857381 0 70.301183 30.67688 70.301183 68.511698v386.912146a255.640665 255.640665 0 1 0-69.022979 503.16474l-563.687667 0.06391c-38.857381 0-70.301183-30.67688-70.301183-68.447788V101.808895C64.628836 63.910166 96.072638 33.233286 134.930019 33.233286h562.409463z m6.391017 575.191496a127.820333 127.820333 0 1 0 0 255.640665 127.820333 127.820333 0 0 0 0-255.640665z m-351.505915 0h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511281h127.820332a31.955083 31.955083 0 0 0 0-63.910166z m0-191.730499h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h127.820332a31.955083 31.955083 0 0 0 0-63.910167z m191.730499-191.730499h-319.550831a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h319.550831a31.955083 31.955083 0 0 0 0-63.910167z" p-id="22292"></path></svg>';
  1124. output += "</button>";
  1125. output +=
  1126. "<button class='icon_btn' title='" +
  1127. gLocal.gui.relational_map +
  1128. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1129. abook +
  1130. "','" +
  1131. aparagraph +
  1132. "','" +
  1133. iBegin +
  1134. "','" +
  1135. iEnd +
  1136. "')\">" +
  1137. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1138. "</button>";
  1139. output += "</div>";
  1140. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1141. output += "</span>";
  1142. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1143. output += "</div>";
  1144. return output;
  1145. }
  1146. var arr_par_sent_num = new Array();
  1147. var g_arr_Para_ID = new Array();
  1148. function renderWordParBlockInner(elementBlock) {
  1149. var output = "<div style='display:block;width:100%'>";
  1150. var Note_Mark = 0;
  1151. var sent_gramma_i = 0;
  1152. var word_length_count = 0;
  1153. var sent_num = 0;
  1154. var arr_Para_ID = new Array();
  1155. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1156. let book = getNodeText(xmlParInfo, "book");
  1157. let paragraph = getNodeText(xmlParInfo, "paragraph");
  1158. let par_num = paragraph - 1;
  1159. let type = getNodeText(xmlParInfo, "type");
  1160. let allWord = elementBlock.getElementsByTagName("word");
  1161. output += "<div class='sent_wbw_trans'>";
  1162. output += render_sent_tool_bar(elementBlock, 0);
  1163. output += "<div class='sent_wbw'>";
  1164. let sent_begin = 0;
  1165. let wID;
  1166. let word_id;
  1167. for (let iWord = 0; iWord < allWord.length; iWord++) {
  1168. wID = getNodeText(allWord[iWord], "id");
  1169. let wPali = getNodeText(allWord[iWord], "pali");
  1170. let wReal = getNodeText(allWord[iWord], "real");
  1171. let wType = getNodeText(allWord[iWord], "type");
  1172. let wGramma = getNodeText(allWord[iWord], "gramma");
  1173. let wCase = getNodeText(allWord[iWord], "case");
  1174. let wMean = getNodeText(allWord[iWord], "mean");
  1175. let wParent = getNodeText(allWord[iWord], "parent");
  1176. let wUn = getNodeText(allWord[iWord], "un");
  1177. let wStyle = getNodeText(allWord[iWord], "style");
  1178. let wEnter = getNodeText(allWord[iWord], "enter");
  1179. if ((wType == "" || wType == "?") && wCase != "") {
  1180. wType = wCase.split("#")[0];
  1181. }
  1182. word_id = parseInt(wID.split("-")[2]);
  1183. if (sent_begin == 0) {
  1184. sent_begin = word_id;
  1185. }
  1186. //渲染单词块
  1187. //word div class
  1188. let strMouseEvent = ' onmouseover="on_word_mouse_enter()" onmouseout="on_word_mouse_leave()"';
  1189. if (wType == ".ctl." && wGramma == ".a.") {
  1190. //output += "<div><a name='"+wPali+"'></a></div>";
  1191. output +=
  1192. '<div id="wb' +
  1193. wID +
  1194. "\" class='ctrl sent_gramma_" +
  1195. (sent_gramma_i % 3) +
  1196. "'> <a name='" +
  1197. wPali +
  1198. "'></a>";
  1199. } else if (Note_Mark == 1) {
  1200. output +=
  1201. '<div id="wb' +
  1202. wID +
  1203. "\" class='word org_note sent_gramma_" +
  1204. (sent_gramma_i % 3) +
  1205. "'> <a name='" +
  1206. wPali +
  1207. "'></a>";
  1208. } else {
  1209. if (wReal == "") {
  1210. output +=
  1211. '<div id="wb' + wID + '" class="word_punc un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //符號
  1212. } else {
  1213. if (wType == ".un.") {
  1214. output +=
  1215. '<div id="wb' + wID + '" class="word un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //粘音詞
  1216. } else if (wType == ".comp.") {
  1217. output +=
  1218. '<div id="wb' + wID + '" class="word comp_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //複合詞
  1219. } else {
  1220. output += '<div id="wb' + wID + '" class="word sent_gramma_' + (sent_gramma_i % 3) + '" >'; //普通
  1221. }
  1222. }
  1223. }
  1224. //head div class
  1225. output += " <div id='ws_" + wID + "' class='word_head_shell' >";
  1226. if (wUn.length > 0) {
  1227. output += " <div class='word_head un_pali' id=\"whead_" + wID + '">';
  1228. } else {
  1229. output += " <div class='word_head' id=\"whead_" + wID + '">';
  1230. }
  1231. output += renderWordHeadInner(allWord[iWord]);
  1232. output += " </div>";
  1233. output += " </div>";
  1234. output += ' <div id="detail' + wID + '" class="wbody">';
  1235. output += renderWordBodyInner(allWord[iWord]);
  1236. output += " </div>";
  1237. output += "</div>";
  1238. //渲染单词块结束
  1239. word_length_count += wPali.length;
  1240. if (iWord >= 1) {
  1241. var pre_pali_spell = getNodeText(allWord[iWord - 1], "pali");
  1242. var pre_pali_type = getNodeText(allWord[iWord - 1], "type");
  1243. var pre_pali_Gramma = getNodeText(allWord[iWord - 1], "gramma");
  1244. var pre_pali_Case = getNodeText(allWord[iWord - 1], "case");
  1245. if (pre_pali_type == "" && pre_pali_Case != "") {
  1246. pre_pali_type = pre_pali_Case.split("#")[0];
  1247. }
  1248. if (pre_pali_Case != "" && pre_pali_Case.lastIndexOf("$") != -1) {
  1249. var pre_case_array = pre_pali_Case.split("$");
  1250. pre_pali_Case = pre_case_array[pre_case_array.length - 1];
  1251. }
  1252. }
  1253. if (iWord + 2 <= allWord.length) {
  1254. var next_pali_spell = getNodeText(allWord[iWord + 1], "pali");
  1255. var next_pali_type = getNodeText(allWord[iWord + 1], "type");
  1256. var next_pali_Gramma = getNodeText(allWord[iWord + 1], "gramma");
  1257. var next_pali_Case = getNodeText(allWord[iWord + 1], "case");
  1258. if (next_pali_type == "" && next_pali_Case != "") {
  1259. next_pali_type = next_pali_Case.split("#")[0];
  1260. }
  1261. if (next_pali_Case != "" && next_pali_Case.lastIndexOf("$") != -1) {
  1262. var next_case_array = next_pali_Case.split("$");
  1263. next_pali_Case = next_case_array[next_case_array.length - 1];
  1264. }
  1265. }
  1266. if (next_pali_spell == "(") {
  1267. Note_Mark = 1;
  1268. } else if (pre_pali_spell == ")" && Note_Mark == 1) {
  1269. Note_Mark = 0;
  1270. } else {
  1271. }
  1272. if (wEnter == 1) {
  1273. //句子末尾
  1274. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1275. if (_display_sbs == 1) {
  1276. //逐句显示模式
  1277. output += "</div>"; //逐句逐词译块结束
  1278. //逐句翻译块开始
  1279. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1280. output += "<div class='translate_sent_head'>";
  1281. output += "<div class='translate_sent_head_toolbar' style='display:none;'>";
  1282. output += "<span></span>";
  1283. output +=
  1284. "<span onclick=\"show_tran_net('" +
  1285. book +
  1286. "','" +
  1287. paragraph +
  1288. "','" +
  1289. sent_begin +
  1290. "','" +
  1291. word_id +
  1292. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1293. //
  1294. output += "</div>";
  1295. output += "<div class='translate_sent_head_content'>";
  1296. //句子预览
  1297. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1298. if (_my_channal != null) {
  1299. for (const iterator of _my_channal) {
  1300. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1301. }
  1302. }
  1303. //句子预览结束
  1304. output += "</div>";
  1305. output +=
  1306. "<div class='trans_text_content' pcds='sent-net' book='" +
  1307. book +
  1308. "' para='" +
  1309. paragraph +
  1310. "' begin='" +
  1311. sent_begin +
  1312. "' end=''></div>";
  1313. output += "</div>";
  1314. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1315. output += "</div>";
  1316. output += "</div>";
  1317. //逐句翻译块内容结束
  1318. output += "<div class='translate_sent_foot'>";
  1319. output += "</div>";
  1320. output += "</div>";
  1321. //逐句翻译块结束
  1322. output += "</div>"; //逐句块结束
  1323. sent_begin = word_id + 1;
  1324. //下一个逐句块开始
  1325. output += "<div class='sent_wbw_trans'>";
  1326. //output += output += render_sent_tool_bar(elementBlock,word_id);
  1327. let nextBegin = word_id + 1;
  1328. let nextEnd = 0;
  1329. for (let j = iWord + 1; j < allWord.length; j++) {
  1330. let aID = getNodeText(allWord[j], "id");
  1331. let aEnter = getNodeText(allWord[j], "enter");
  1332. let arrId = aID.split("-");
  1333. iWordId = parseInt(arrId[2]);
  1334. if (aEnter == 1) {
  1335. nextEnd = iWordId;
  1336. break;
  1337. }
  1338. }
  1339. if (nextEnd == 0) {
  1340. nextEnd = iWordId;
  1341. }
  1342. output += "<div class='sent_wbw_trans_bar'>";
  1343. let sentIdString = book + "-" + paragraph + "-" + nextBegin + "-" + nextEnd;
  1344. let sentIdStringLink = "{{" + sentIdString + "}}";
  1345. output +=
  1346. "<span style='flex: 7;display: flex;'><div style='background-color: silver;'><span style='font-size: large; font-weight: bolder;' title=" +
  1347. gLocal.gui.text_num +
  1348. ">" +
  1349. sentIdString +
  1350. "</span><button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1351. sentIdStringLink +
  1352. "')\" title=" +
  1353. gLocal.gui.copy_to_clipboard +
  1354. ">";
  1355. output +=
  1356. '<svg style="fill: var(--link-color);" t="1601480724259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4644"><path d="M791.272727 93.090909H139.636364v837.818182a93.090909 93.090909 0 0 1-93.090909-93.090909V93.090909a93.090909 93.090909 0 0 1 93.090909-93.090909h558.545454a93.090909 93.090909 0 0 1 93.090909 93.090909zM232.727273 186.181818h744.727272v837.818182H232.727273V186.181818z" p-id="4645"></path></svg>';
  1357. output += "</button>";
  1358. output +=
  1359. "<button class='icon_btn' onclick=\"window.open('../reader/?view=sent&book=" +
  1360. book +
  1361. "&para=" +
  1362. paragraph +
  1363. "&begin=" +
  1364. nextBegin +
  1365. "&end=" +
  1366. nextEnd +
  1367. "')\" target='_blank' title='" +
  1368. gLocal.gui.scan_in_reader +
  1369. "'>";
  1370. output +=
  1371. '<svg style="fill: var(--link-color);" t="1601482753387" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22291"><path d="M703.730499 544.578527a191.730499 191.730499 0 0 1 156.260356 302.806368l122.004508 122.004507a31.955083 31.955083 0 0 1-45.248398 45.184488l-121.940597-121.940598A191.730499 191.730499 0 1 1 703.730499 544.642437z m-6.391017-511.28133c38.857381 0 70.301183 30.67688 70.301183 68.511698v386.912146a255.640665 255.640665 0 1 0-69.022979 503.16474l-563.687667 0.06391c-38.857381 0-70.301183-30.67688-70.301183-68.447788V101.808895C64.628836 63.910166 96.072638 33.233286 134.930019 33.233286h562.409463z m6.391017 575.191496a127.820333 127.820333 0 1 0 0 255.640665 127.820333 127.820333 0 0 0 0-255.640665z m-351.505915 0h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511281h127.820332a31.955083 31.955083 0 0 0 0-63.910166z m0-191.730499h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h127.820332a31.955083 31.955083 0 0 0 0-63.910167z m191.730499-191.730499h-319.550831a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h319.550831a31.955083 31.955083 0 0 0 0-63.910167z" p-id="22292"></path></svg>';
  1372. output += "</button>";
  1373. output +=
  1374. "<button class='icon_btn' title='" +
  1375. gLocal.gui.relational_map +
  1376. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1377. book +
  1378. "','" +
  1379. paragraph +
  1380. "','" +
  1381. nextBegin +
  1382. "','" +
  1383. nextEnd +
  1384. "')\">" +
  1385. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1386. "</button>";
  1387. output += "</div>";
  1388. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1389. output += "</span>";
  1390. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1391. output += "</div>";
  1392. output += "<div class='sent_wbw'>";
  1393. }
  1394. sent_num += 1;
  1395. word_length_count = 0;
  1396. sent_gramma_i = 0;
  1397. arr_Para_ID.push(wID);
  1398. }
  1399. } //循環結束
  1400. output += "</div>";
  1401. //逐句翻译块开始
  1402. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1403. output += "<div class='translate_sent_head'>";
  1404. output += "<div class='translate_sent_head_toolbar'>";
  1405. output += "<span></span>";
  1406. output +=
  1407. "<span onclick=\"show_tran_net('" +
  1408. book +
  1409. "','" +
  1410. paragraph +
  1411. "','" +
  1412. sent_begin +
  1413. "','" +
  1414. word_id +
  1415. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1416. output += "</div>";
  1417. output += "<div class='translate_sent_head_content'>";
  1418. //逐句译文开始
  1419. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1420. if (_my_channal != null) {
  1421. for (const iterator of _my_channal) {
  1422. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1423. }
  1424. }
  1425. output += "</div>";
  1426. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1427. output += "</div>";
  1428. //逐句翻译块内容结束
  1429. output += "<div class='translate_sent_foot'>";
  1430. output += "</div>";
  1431. output += "</div>";
  1432. //逐句翻译块结束
  1433. output += "</div>";
  1434. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1435. arr_Para_ID.push(wID);
  1436. arr_par_sent_num.push(sent_ID);
  1437. g_arr_Para_ID[par_num] = arr_Para_ID;
  1438. return output;
  1439. }
  1440. function sent_show_rel_map(book, para, begin, end) {
  1441. let wordId;
  1442. let memind = "graph LR\n";
  1443. let pali_text = "";
  1444. for (wordId = begin; wordId <= end; wordId++) {
  1445. let rel = doc_word("#p" + book + "-" + para + "-" + wordId).val("rela");
  1446. let pali = doc_word("#p" + book + "-" + para + "-" + wordId).val("real");
  1447. let type = doc_word("#p" + book + "-" + para + "-" + wordId).val("type");
  1448. if (type != ".ctl.") {
  1449. pali_text += pali + " ";
  1450. }
  1451. let wid = "p" + book + "-" + para + "-" + wordId;
  1452. if (rel != "") {
  1453. let relaData = JSON.parse(rel);
  1454. for (const iterator of relaData) {
  1455. let strRel = iterator.relation;
  1456. let dest = iterator.dest_spell;
  1457. let type = doc_word("#" + iterator.dest_id).val("case");
  1458. if (type.indexOf(".v.") >= 0) {
  1459. dest = iterator.dest_id + "[/" + dest + "/]";
  1460. } else {
  1461. dest = iterator.dest_id + "[" + dest + "]";
  1462. }
  1463. if (strRel.indexOf("SV") >= 0 || strRel.indexOf("-P") >= 0) {
  1464. memind += wid + "(" + pali + ")" + " ==> |" + strRel + "|" + dest + "\n";
  1465. } else if (strRel.indexOf("OV") >= 0 || strRel.indexOf("-S") >= 0) {
  1466. memind += dest + " ==> |" + strRel + "|" + wid + "(" + pali + ")" + "\n";
  1467. } else {
  1468. memind += wid + "(" + pali + ")" + " -- " + strRel + " --> " + dest + "\n";
  1469. }
  1470. }
  1471. }
  1472. }
  1473. let graph = mermaid.render("graphDiv", memind);
  1474. document.querySelector("#term_body").innerHTML = "<h3>" + pali_text + "</h3>" + graph;
  1475. document.querySelector("#term_win").style.display = "flex";
  1476. }
  1477. //句子编辑块
  1478. function render_tran_sent_block(book, para, begin, end, channal = 0, readonly = true) {
  1479. let usent_count = _user_sent_buffer.getSentNum(book, para, begin, end);
  1480. let netSent = doc_msg_get_trans(book, para, begin, end);
  1481. let sender = "";
  1482. let sChannalName = "";
  1483. let sent_text = "";
  1484. let sent_lang = "en";
  1485. let objSent;
  1486. if (channal == 0) {
  1487. //百家言
  1488. if (netSent.length > 0) {
  1489. sender = netSent[netSent.length - 1].sender;
  1490. sent_text += netSent[netSent.length - 1].data.text;
  1491. } else if (usent_count > 0) {
  1492. sender = _user_sent_buffer.getSentText(book, para, begin, end)[0].nickname;
  1493. sChannalName = "channal name";
  1494. sent_text += _user_sent_buffer.getSentText(book, para, begin, end)[0].text;
  1495. }
  1496. } else {
  1497. sender = "通道的名字";
  1498. objSent = _user_sent_buffer.getSentText(book, para, begin, end, channal);
  1499. if (objSent == false) {
  1500. objSent = new Object();
  1501. objSent.text = "";
  1502. if (doc_head("lang") == "") {
  1503. objSent.language = "en";
  1504. } else {
  1505. objSent.language = doc_head("lang");
  1506. }
  1507. objSent.id = "";
  1508. objSent.tag = "[]";
  1509. objSent.author = "{}";
  1510. sent_text = "";
  1511. } else {
  1512. sent_text = objSent.text;
  1513. }
  1514. sent_lang = objSent.language;
  1515. }
  1516. let output = "";
  1517. output += "<div class='trans_text_block' style='padding-top:0;";
  1518. if (readonly == false) {
  1519. output += "border-color: #ccd1ff;background-color:unset;";
  1520. }
  1521. output += "'>";
  1522. output += "<div class='trans_text_info' style='border:none;'>";
  1523. if (channal == 0) {
  1524. output += "<span class='author'>" + sender + "</span><span>[滤]</span>";
  1525. } else {
  1526. output += "<span style='width: 100%;display: contents;'>";
  1527. output += "<span>";
  1528. let thischannal = channal_getById(channal);
  1529. if (thischannal) {
  1530. output += thischannal.name;
  1531. } else {
  1532. output += "未知的频道名";
  1533. }
  1534. output += "</span>";
  1535. output +=
  1536. "<span style='margin-left: auto;' class='send_status' id='send_" +
  1537. book +
  1538. "_" +
  1539. para +
  1540. "_" +
  1541. begin +
  1542. "_" +
  1543. end +
  1544. "_" +
  1545. channal +
  1546. "'></span>";
  1547. }
  1548. output += "</span><span></span>";
  1549. output += "</div>";
  1550. let id = "tran_pre_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1551. output += "<div class='trans_text_content' tid = '" + id;
  1552. if (channal == 0) {
  1553. output += "' pcds='sent-net-all' ";
  1554. } else {
  1555. output += "' pcds='sent-net' ";
  1556. }
  1557. output +=
  1558. " book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' channal='" + channal + "'>";
  1559. if (readonly) {
  1560. output += note_init(term_std_str_to_tran(sent_text, channal, "", sent_lang));
  1561. } else {
  1562. output += "<span id='" + id + "' ";
  1563. output += "onclick=\"sent_edit_click('";
  1564. output += book + "','" + para + "','" + begin + "','" + end + "','" + channal + "',)\">";
  1565. if (objSent.text == null || objSent.text == "") {
  1566. output += "<span style='color:gray;'>";
  1567. output += "<svg class='icon' style='fill: var(--detail-color);'>";
  1568. output += "<use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
  1569. output += "</span>";
  1570. } else {
  1571. output += note_init(objSent.text);
  1572. }
  1573. output += "</span>";
  1574. }
  1575. output += "</div>";
  1576. //句子预览结束
  1577. //编辑框开始
  1578. if (readonly == false) {
  1579. output += "<div style='display:none;'>";
  1580. let id = book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1581. output += "<textarea id='trans_sent_edit_" + id + "' ";
  1582. output += " onkeyup = \"updateTranslationPreview('" + id + "',this)\" ";
  1583. output +=
  1584. " onchange=\"trans_text_save('" +
  1585. book +
  1586. "','" +
  1587. para +
  1588. "','" +
  1589. begin +
  1590. "','" +
  1591. end +
  1592. "','" +
  1593. channal +
  1594. "')\"";
  1595. output += "class='trans_sent_edit' style='background-color: #f8f8fa;color: black;border-color: silver;' ";
  1596. output += "sent_id='" + objSent.id + "' ";
  1597. output += "book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' ";
  1598. output +=
  1599. " channal='" +
  1600. channal +
  1601. "' author='" +
  1602. objSent.author +
  1603. "' lang='" +
  1604. objSent.language +
  1605. "' tag='" +
  1606. objSent.tag +
  1607. "' >";
  1608. output += objSent.text;
  1609. output += "</textarea>";
  1610. output += "<div class='trans_text_info' style='justify-content: flex-end;'>";
  1611. output += "<span></span>";
  1612. output += "<button class='icon_btn' ";
  1613. output +=
  1614. "onclick=\"trans_text_save('" +
  1615. book +
  1616. "','" +
  1617. para +
  1618. "','" +
  1619. begin +
  1620. "','" +
  1621. end +
  1622. "','" +
  1623. channal +
  1624. "')\" ";
  1625. output +=
  1626. "title=" +
  1627. gLocal.gui.draft +
  1628. ">" +
  1629. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#ic_save"></use></svg>';
  1630. output += "</button>";
  1631. output += "<button class='icon_btn' ";
  1632. output +=
  1633. "onclick=\"trans_text_send('" +
  1634. book +
  1635. "','" +
  1636. para +
  1637. "','" +
  1638. begin +
  1639. "','" +
  1640. end +
  1641. "','" +
  1642. channal +
  1643. "')\"";
  1644. output +=
  1645. " title=" +
  1646. gLocal.gui.send +
  1647. " disabled>" +
  1648. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#send_by_paper_plane"></use></svg>';
  1649. output += "</button>";
  1650. output += "</div>";
  1651. output += "</div>";
  1652. }
  1653. if (readonly) {
  1654. output += "<div class='trans_text_info'>" + "<span></span>" + "<span><span class='tools'>";
  1655. output +=
  1656. "<button class='icon_btn' title=" +
  1657. gLocal.gui.accept_copy +
  1658. ">" +
  1659. "<svg class='icon' style='fill: var(--link-color); height: 2em; width: 2em; '><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_move_to_inbox'></use></svg>" +
  1660. "</button>";
  1661. if (channal == 0) {
  1662. //百家言 显示更多按钮
  1663. output +=
  1664. "<button class='icon_btn' onclick=\"show_tran_net('" +
  1665. book +
  1666. "','" +
  1667. para +
  1668. "','" +
  1669. begin +
  1670. "','" +
  1671. end +
  1672. "')\" title=" +
  1673. gLocal.gui.message +
  1674. ">" +
  1675. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="plugin/system_message/icon.svg#icon_message"></use></svg>' +
  1676. "</button>";
  1677. }
  1678. output += "</span><span>" + usent_count + "</span></span>";
  1679. output += "</div>";
  1680. }
  1681. output += "</div>";
  1682. return output;
  1683. }
  1684. function trans_text_save(book, para, begin, end, channal) {
  1685. let textarea = $("#trans_sent_edit_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal);
  1686. if (textarea) {
  1687. let objsent = new Object();
  1688. objsent.id = textarea.attr("sent_id");
  1689. objsent.book = book;
  1690. objsent.paragraph = para;
  1691. objsent.begin = begin;
  1692. objsent.end = end;
  1693. objsent.channal = channal;
  1694. objsent.author = textarea.attr("author");
  1695. objsent.lang = textarea.attr("lang");
  1696. objsent.text = textarea.val();
  1697. _user_sent_buffer.setSent(objsent);
  1698. }
  1699. }
  1700. function sent_edit_click(book, para, begin, end, channal) {
  1701. $(".trans_sent_edit").parent().hide(200);
  1702. $(
  1703. ".trans_sent_edit[book='" +
  1704. book +
  1705. "'][para='" +
  1706. para +
  1707. "'][begin='" +
  1708. begin +
  1709. "'][end='" +
  1710. end +
  1711. "'][channal='" +
  1712. channal +
  1713. "']"
  1714. )
  1715. .parent()
  1716. .show();
  1717. }
  1718. function magic_sentence_cut() {
  1719. var all_sent_array = document.getElementsByClassName("sent_wbw");
  1720. for (i_magic = 0; i_magic < all_sent_array.length; i_magic++) {
  1721. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1").length != 0) {
  1722. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1")[0].className += " sent_cut";
  1723. }
  1724. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2").length != 0) {
  1725. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2")[0].className += " sent_cut";
  1726. }
  1727. }
  1728. }
  1729. function updataWordHeadById(wordId) {
  1730. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1731. var iIndex = getWordIndex(wordId);
  1732. if (iIndex >= 0) {
  1733. $("#whead_" + wordId).html(renderWordHeadInner(xAllWord[iIndex]));
  1734. }
  1735. }
  1736. function updataWordHeadByIndex(wordIndex) {
  1737. if (wordIndex > 0) {
  1738. let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1739. let wordId = getNodeText(xAllWord[wordIndex], "id");
  1740. let obj = document.getElementById("whead_" + wordId);
  1741. if (obj) {
  1742. obj.innerHTML = renderWordHeadInner(xAllWord[wordIndex]);
  1743. }
  1744. }
  1745. }
  1746. function updateWordBodyById(wordId) {
  1747. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1748. var wordIndex = getWordIndex(wordId);
  1749. var obj = document.getElementById("detail" + wordId);
  1750. if (obj) {
  1751. obj.innerHTML = renderWordBodyInner(xAllWord[wordIndex]);
  1752. }
  1753. }
  1754. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  1755. //返回 无
  1756. function modifyWordDetailByWordIndex(wordIndex) {
  1757. xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1758. wordId = getNodeText(xAllWord[wordIndex], "id");
  1759. try {
  1760. var sDetail = "detail" + wordId;
  1761. var cDetail = document.getElementById(sDetail);
  1762. if (cDetail != null) {
  1763. cDetail.innerHTML = renderWordDetailByElement(xAllWord[wordIndex]);
  1764. }
  1765. } catch (error) {
  1766. debugOutput(error);
  1767. }
  1768. }
  1769. function renderWordHeadInner(element) {
  1770. var output = "";
  1771. var wid = getNodeText(element, "id");
  1772. var wpali = getNodeText(element, "pali");
  1773. var sParent = getNodeText(element, "parent");
  1774. var wId = getNodeText(element, "id");
  1775. var wNote = getNodeText(element, "note");
  1776. wStyle = "v_" + getNodeText(element, "style");
  1777. if (wStyle == "v_bld") {
  1778. if (wpali.indexOf("{") >= 0) {
  1779. wpali = wpali.replace("{", "<span class='v_bld'>");
  1780. wpali = wpali.replace("}", "</span>");
  1781. wStyle = "";
  1782. }
  1783. }
  1784. if (wNote.indexOf("{{") >= 0 && wNote.indexOf("}}") >= 0) {
  1785. wStyle += " note_ref";
  1786. }
  1787. if (wNote.substring(0, 6) == "=term(") {
  1788. wStyle += " term_word_head";
  1789. } else {
  1790. if (sParent.length > 0) {
  1791. if (term_lookup_my(sParent) != false) {
  1792. wStyle += " term_my";
  1793. } else {
  1794. if (term_lookup_all(sParent) != null) {
  1795. wStyle += " term_other";
  1796. }
  1797. }
  1798. }
  1799. }
  1800. var sign_count = 0;
  1801. var letter_count = 0;
  1802. for (i_sign in local_sign_str) {
  1803. if (wpali.lastIndexOf(local_sign_str[i_sign].id) != -1) {
  1804. sign_count += 1;
  1805. } //如果是标点或数字
  1806. else if (wpali.lastIndexOf(local_letter_str[i_sign].id) != -1) {
  1807. letter_count += 1;
  1808. } //如果有字母
  1809. }
  1810. if (sign_count != 0 && letter_count == 0) {
  1811. output += "<a name='w" + wId + "'>";
  1812. } else {
  1813. output += "<a name='w" + wId + "' onclick='on_word_click(\"" + wId + "\")'>";
  1814. }
  1815. if (wpali) output += '<span id="whead1_' + wid + '" class="whead paliword1 ' + wStyle + '">';
  1816. output += wpali;
  1817. output += "</span>";
  1818. output += "</a>";
  1819. if (wNote.length > 0) {
  1820. output += '<span id="wnote_root_' + wid + '"><wnh wid="' + wid + '">[1]</wnh></span>';
  1821. } else {
  1822. output += '<span id="wnote_root_' + wid + '"></span>';
  1823. }
  1824. var newMsg = msg_word_msg_num(wid);
  1825. if (newMsg > 0) {
  1826. output += "<span class='word_msg' onclick=\"word_msg_counter_click('" + wid + "')\">" + newMsg + "</span>";
  1827. }
  1828. output += '<span id="whead2_' + wid + '" class="whead paliword2 ' + wStyle + '">';
  1829. output += "</span>";
  1830. return output;
  1831. }
  1832. function renderWordBodyInner(element) {
  1833. return renderWordDetailByElement(element);
  1834. }
  1835. //新的渲染单词块函数
  1836. function renderWordDetailByElement_edit_a(xmlElement) {
  1837. if (xmlElement == null) {
  1838. return "";
  1839. }
  1840. var wordNode = xmlElement;
  1841. var sPali = getNodeText(wordNode, "pali");
  1842. var sId = getNodeText(wordNode, "id");
  1843. var sReal = getNodeText(wordNode, "real");
  1844. var sMean = getNodeText(wordNode, "mean");
  1845. var sOrg = getNodeText(wordNode, "org");
  1846. var sOm = getNodeText(wordNode, "om");
  1847. var sCase = getNodeText(wordNode, "case");
  1848. var sType = getNodeText(wordNode, "type");
  1849. var sGramma = getNodeText(wordNode, "gramma");
  1850. var sParent = getNodeText(wordNode, "parent");
  1851. var sParentGrammar = getNodeText(wordNode, "pg");
  1852. var sParent2 = getNodeText(wordNode, "parent2");
  1853. var sNote = getNodeText(wordNode, "note");
  1854. var sStatus = getNodeText(wordNode, "status");
  1855. if (sStatus == "") {
  1856. sStatus = 0;
  1857. }
  1858. var wordID = sId;
  1859. if (sCase == "") {
  1860. sCase = sType + "#" + sGramma;
  1861. }
  1862. var _txtOutDetail = "";
  1863. var _bgColor = "";
  1864. var status_bg_color = "status_bg_color_" + sStatus;
  1865. var _caseColor = "";
  1866. //标点符号
  1867. if (sReal.length <= 1) {
  1868. _txtOutDetail += "<div>";
  1869. /*id begin*/
  1870. _txtOutDetail += "<div class='ID'> </div>";
  1871. /*mean begin*/
  1872. _txtOutDetail += "<div class='mean'> </div>";
  1873. /*org begin*/
  1874. _txtOutDetail += "<div class='org'> </div>";
  1875. /*org mean begin*/
  1876. _txtOutDetail += "<div class='om'> </div>";
  1877. /*case begin*/
  1878. _txtOutDetail += "<div class='case'> </div>";
  1879. _txtOutDetail += "</div>";
  1880. return _txtOutDetail;
  1881. }
  1882. var strBookMarkColor = getNodeText(wordNode, "bmc");
  1883. if (strBookMarkColor.length > 2) {
  1884. var icolor = strBookMarkColor.substr(-1);
  1885. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  1886. }
  1887. // Auto Match Begin
  1888. if (sCase == "?" && _bgColor == "") {
  1889. _caseColor = " class='bookmarkcolorx' ";
  1890. }
  1891. if (g_useMode == "read" || g_useMode == "translate") {
  1892. _bgColor = "";
  1893. _caseColor = "";
  1894. if (sOrg == "?") {
  1895. sOrg = " ";
  1896. }
  1897. if (sMean == "?") {
  1898. sMean = " ";
  1899. }
  1900. if (sCase == "?" || sCase == "?#?") {
  1901. sCase = " ";
  1902. }
  1903. }
  1904. //编辑模式开始
  1905. {
  1906. /*gramma*/
  1907. /*find in dict*/
  1908. var arrGramma = new Array();
  1909. var thisWord = sReal;
  1910. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  1911. if (thisWord == g_DictWordList[iDict].Pali) {
  1912. if (
  1913. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  1914. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  1915. ) {
  1916. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  1917. pushNewToList(arrGramma, arrCase);
  1918. }
  1919. }
  1920. }
  1921. if (sCase == "?" || sCase == "?#?") {
  1922. if (arrGramma.length > 0) {
  1923. setNodeText(xmlElement, "case", arrGramma[0]);
  1924. sCase = arrGramma[0];
  1925. } else {
  1926. setNodeText(xmlElement, "case", "?#?");
  1927. sCase = "?#?";
  1928. }
  1929. } else {
  1930. if (sCase.indexOf("#") == -1) {
  1931. sCase = "?#" + sCase;
  1932. setNodeText(xmlElement, "case", "?#" + sCase);
  1933. }
  1934. }
  1935. var currType = sCase.split("#")[0];
  1936. var currGramma = sCase.split("#")[1];
  1937. //end gramma
  1938. if (getNodeText(wordNode, "lock") == "true") {
  1939. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  1940. } else {
  1941. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  1942. }
  1943. //状态颜色
  1944. _txtOutDetail += "<div class='" + status_bg_color + "'>";
  1945. //书签颜色
  1946. _txtOutDetail += "<div " + _bgColor + ">";
  1947. /*id begin*/
  1948. /*
  1949. _txtOutDetail += "<p class='ID'>";
  1950. _txtOutDetail += sId + "&nbsp;";
  1951. _txtOutDetail += "</p>";
  1952. */
  1953. /*id end*/
  1954. /*meaning*/
  1955. //格位公式开始
  1956. //去除格位公式
  1957. var currMeaning = removeFormula(sMean);
  1958. //currMeaning = getLocalFormulaStr(currGramma,currMeaning);
  1959. var orgMeaning = sMean;
  1960. //切割过长意思
  1961. if (sReal.length < 4) {
  1962. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, 24));
  1963. } else {
  1964. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, sReal.length * 6));
  1965. }
  1966. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  1967. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  1968. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  1969. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  1970. //格位公式结束
  1971. if (sMean.length == 0) {
  1972. renderMeaning = "<span class='word_space_holder'>meaning</span>";
  1973. }
  1974. //渲染下拉菜单
  1975. _txtOutDetail += "<div class='mean'>";
  1976. _txtOutDetail += '<div class="case_dropdown">';
  1977. _txtOutDetail += "<p class='case_dropbtn' >";
  1978. _txtOutDetail += renderMeaning;
  1979. _txtOutDetail += "</p>";
  1980. _txtOutDetail += "<div id='mean_" + wordID + '\' class="case_dropdown-content">';
  1981. _txtOutDetail += "</div>";
  1982. _txtOutDetail += "</div>";
  1983. //render formula menu
  1984. arrFormula = getFormulaList(currGramma);
  1985. _txtOutDetail += '<div class="case_dropdown">';
  1986. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  1987. _txtOutDetail += '<div class="case_dropdown-content">';
  1988. newWord = removeFormula_B(orgMeaning);
  1989. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  1990. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  1991. for (var i in arrFormula) {
  1992. newWord = removeFormula_B(orgMeaning);
  1993. newWord = arrFormula[i].replace("~", newWord);
  1994. newWord = newWord.replace(/{/g, "[");
  1995. newWord = newWord.replace(/}/g, "]");
  1996. _txtOutDetail +=
  1997. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  1998. }
  1999. _txtOutDetail += "</div>";
  2000. _txtOutDetail += "</div>";
  2001. _txtOutDetail += "</div> ";
  2002. /*end of meaning*/
  2003. /*org begin 拆分*/
  2004. _txtOutDetail += "<div class='org' name='w_org'>";
  2005. _txtOutDetail += '<div class="case_dropdown">';
  2006. _txtOutDetail += "<p class='case_dropbtn' >";
  2007. let currOrg;
  2008. if (sOrg.length == 0) {
  2009. currOrg = "<span class='word_space_holder'>parts</span>";
  2010. } else {
  2011. currOrg = sOrg;
  2012. }
  2013. _txtOutDetail += currOrg;
  2014. _txtOutDetail += "</p>";
  2015. _txtOutDetail += '<div class="case_dropdown-content">';
  2016. _txtOutDetail += "<div id='parts_" + sId + "'>Loading</div>";
  2017. _txtOutDetail += "</div>";
  2018. _txtOutDetail += "</div>";
  2019. _txtOutDetail += "</div> ";
  2020. /*end of factors*/
  2021. /*part meaning begin*/
  2022. _txtOutDetail += "<div class='om' name='w_om'>";
  2023. _txtOutDetail += '<div class="case_dropdown">';
  2024. _txtOutDetail += "<p class='case_dropbtn' >";
  2025. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  2026. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  2027. var currDefualtFM = "";
  2028. var listFactorForFactorMean = sOrg.split("+");
  2029. for (iFactor in listFactorForFactorMean) {
  2030. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2031. }
  2032. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  2033. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  2034. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  2035. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  2036. if (currDefualtFM.slice(-1, -2) == "+") {
  2037. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  2038. }
  2039. currOM = "[a]" + currDefualtFM;
  2040. setNodeText(wordNode, "om", currOM);
  2041. } else {
  2042. currOM = sOm;
  2043. }
  2044. if (currOM.length == 0) {
  2045. currOM = "<span class='word_space_holder''>part mean</span>";
  2046. }
  2047. _txtOutDetail += currOM;
  2048. _txtOutDetail += "</p>";
  2049. _txtOutDetail += '<div class="case_dropdown-content">';
  2050. _txtOutDetail += "<div id='partmean_" + sId + "'></div>";
  2051. _txtOutDetail += "</div>";
  2052. _txtOutDetail += "</div>";
  2053. _txtOutDetail += "</div> ";
  2054. /*org meaning end*/
  2055. /*begin gramma*/
  2056. _txtOutDetail += "<div class='case'>";
  2057. _txtOutDetail += '<div class="case_dropdown">';
  2058. _txtOutDetail += "<p class='case_dropbtn' >";
  2059. var sLocalCase = getLocalGrammaStr(sCase);
  2060. var mArrGramma = sCase.split("#");
  2061. if (mArrGramma.length >= 2) {
  2062. mType = mArrGramma[0];
  2063. mGramma = mArrGramma[1];
  2064. mLocalType = sLocalCase.split("#")[0];
  2065. mLocalGramma = sLocalCase.split("#")[1];
  2066. } else {
  2067. mType = "";
  2068. mGramma = mArrGramma[0];
  2069. mLocalType = "";
  2070. mLocalGramma = sLocalCase.split("#")[0];
  2071. }
  2072. if (mType != "") {
  2073. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  2074. }
  2075. _txtOutDetail += cutString(mLocalGramma, 30);
  2076. if (mLocalType.length + mLocalGramma.length == 0) {
  2077. _txtOutDetail += "&nbsp;";
  2078. }
  2079. _txtOutDetail += "</p>";
  2080. _txtOutDetail += '<div class="case_dropdown-content">';
  2081. _txtOutDetail += "<div id='gramma_" + sId + "'></div>";
  2082. _txtOutDetail += "</div>";
  2083. _txtOutDetail += "</div>";
  2084. //连读词按钮
  2085. if (mType == ".un." || mType == ".comp.") {
  2086. nextElement = com_get_nextsibling(xmlElement);
  2087. if (nextElement != null) {
  2088. //下一个元素存在
  2089. if (getNodeText(nextElement, "un") == sId) {
  2090. //若有孩子則显示收起按鈕
  2091. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  2092. _txtOutDetail +=
  2093. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  2094. _txtOutDetail += "</button>";
  2095. var parentElement = document.getElementById("wb" + sId);
  2096. if (parentElement) {
  2097. parentElement.classList.add("un_parent");
  2098. }
  2099. } else {
  2100. //無kid展開按鈕
  2101. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2102. _txtOutDetail +=
  2103. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2104. _txtOutDetail += "</button> ";
  2105. }
  2106. } else {
  2107. //下一个元素不存在
  2108. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2109. _txtOutDetail +=
  2110. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2111. _txtOutDetail += "</button> ";
  2112. }
  2113. }
  2114. //连读词按钮 结束
  2115. //爷爷和父亲的关系 如pp
  2116. /*
  2117. if(wordGranfatherGramma.length>0 && wordGranfatherGramma.length<6){
  2118. _txtOutDetail += "<span class=\"tooltip\">«"+getLocalGrammaStr(wordGranfatherGramma)+"<span class=\"tooltiptext tooltip-bottom\">"+wordGranfather+"</span>"+"</span> ";
  2119. }
  2120. */
  2121. _txtOutDetail += "</div> ";
  2122. /*end of gramma*/
  2123. _txtOutDetail += "</div>";
  2124. _txtOutDetail += "</div>";
  2125. }
  2126. return _txtOutDetail;
  2127. }
  2128. function renderWordDetailByElement(xmlElement) {
  2129. return renderWordDetailByElement_edit_a(xmlElement);
  2130. if (xmlElement == null) {
  2131. return "";
  2132. }
  2133. wordNode = xmlElement;
  2134. var sPali = getNodeText(wordNode, "pali");
  2135. var sId = getNodeText(wordNode, "id");
  2136. var sReal = getNodeText(wordNode, "real");
  2137. var sMean = getNodeText(wordNode, "mean");
  2138. var sOrg = getNodeText(wordNode, "org");
  2139. var sOm = getNodeText(wordNode, "om");
  2140. var sCase = getNodeText(wordNode, "case");
  2141. var sType = getNodeText(wordNode, "type");
  2142. var sGramma = getNodeText(wordNode, "gramma");
  2143. var sParent = getNodeText(wordNode, "parent");
  2144. var sNote = getNodeText(wordNode, "note");
  2145. wordID = sId;
  2146. if (sCase == "") {
  2147. sCase = sType + "#" + sGramma;
  2148. }
  2149. var _txtOutDetail = "";
  2150. var _bgColor = "";
  2151. var _caseColor = "";
  2152. //标点符号
  2153. if (sReal.length <= 1) {
  2154. _txtOutDetail += "<div>";
  2155. /*id begin*/
  2156. _txtOutDetail += "<div class='ID'> </div>";
  2157. /*mean begin*/
  2158. _txtOutDetail += "<div class='mean'> </div>";
  2159. /*org begin*/
  2160. _txtOutDetail += "<div class='org'> </div>";
  2161. /*org mean begin*/
  2162. _txtOutDetail += "<div class='om'> </div>";
  2163. /*case begin*/
  2164. _txtOutDetail += "<div class='case'> </div>";
  2165. _txtOutDetail += "</div>";
  2166. return _txtOutDetail;
  2167. }
  2168. if (sMean == "?") {
  2169. _bgColor = " class='bookmarkcolorx' ";
  2170. }
  2171. strBookMarkColor = getNodeText(wordNode, "bmc");
  2172. if (strBookMarkColor.length > 2) {
  2173. var icolor = strBookMarkColor.substr(-1);
  2174. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2175. }
  2176. // Auto Match Begin
  2177. if (sCase == "?" && _bgColor == "") {
  2178. _caseColor = " class='bookmarkcolorx' ";
  2179. }
  2180. if (g_useMode == "read" || g_useMode == "translate") {
  2181. _bgColor = "";
  2182. _caseColor = "";
  2183. if (sOrg == "?") {
  2184. sOrg = " ";
  2185. }
  2186. if (sMean == "?") {
  2187. sMean = " ";
  2188. }
  2189. if (sCase == "?" || sCase == "?#?") {
  2190. sCase = " ";
  2191. }
  2192. }
  2193. if (g_useMode == "read") {
  2194. _txtOutDetail += "<div " + _bgColor + ">";
  2195. /*id begin*/
  2196. _txtOutDetail += "<p class='ID'>";
  2197. _txtOutDetail += sId + "&nbsp;";
  2198. _txtOutDetail += "</p>";
  2199. /*id end*/
  2200. /*meaning begin*/
  2201. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2202. showMean = showMean.replace(/}/g, "</span>");
  2203. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2204. showMean = showMean.replace(/\]/g, "</span>");
  2205. _txtOutDetail += "<p class='mean'>";
  2206. _txtOutDetail += showMean + "&nbsp;";
  2207. _txtOutDetail += "</p>";
  2208. /*meaning end*/
  2209. /*org begin*/
  2210. _txtOutDetail += "<p class='org'>";
  2211. _txtOutDetail += sOrg + "&nbsp;";
  2212. _txtOutDetail += "</p>";
  2213. /*org end*/
  2214. /*org meaning begin*/
  2215. _txtOutDetail += "<p class='om'>";
  2216. _txtOutDetail += sOm + "&nbsp;";
  2217. _txtOutDetail += "</p>";
  2218. /*org meaning end*/
  2219. /*grmma begin*/
  2220. _txtOutDetail += "<p class='case'>";
  2221. sCase = getLocalGrammaStr(sCase);
  2222. var mGramma = sCase.split("#");
  2223. if (mGramma.length >= 2) {
  2224. mType = sCase.split("#")[0];
  2225. mGramma = sCase.split("#")[1];
  2226. } else {
  2227. mType = "";
  2228. mGramma = sCase.split("#")[0];
  2229. }
  2230. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2231. if (mType != "") {
  2232. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2233. }
  2234. _txtOutDetail += mGramma;
  2235. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2236. /*grmma end*/
  2237. _txtOutDetail += "</div>";
  2238. }
  2239. //编辑模式开始
  2240. if (g_useMode == "edit") {
  2241. if (getNodeText(wordNode, "lock") == "true") {
  2242. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2243. } else {
  2244. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2245. }
  2246. _txtOutDetail += "<div " + _bgColor + ">";
  2247. /*id begin*/
  2248. _txtOutDetail += "<p class='ID'>";
  2249. _txtOutDetail += sId + "&nbsp;";
  2250. _txtOutDetail += "</p>";
  2251. /*id end*/
  2252. /*gramma*/
  2253. /*find in dict*/
  2254. var arrGramma = new Array();
  2255. var thisWord = getNodeText(wordNode, "real");
  2256. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2257. if (thisWord == g_DictWordList[iDict].Pali) {
  2258. if (
  2259. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2260. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2261. ) {
  2262. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2263. pushNewToList(arrGramma, arrCase);
  2264. }
  2265. }
  2266. }
  2267. if (sCase == "?" || sCase == "?#?") {
  2268. if (arrGramma.length > 0) {
  2269. setNodeText(xmlElement, "case", arrGramma[0]);
  2270. sCase = arrGramma[0];
  2271. } else {
  2272. setNodeText(xmlElement, "case", "?#?");
  2273. sCase = "?#?";
  2274. }
  2275. } else {
  2276. if (sCase.indexOf("#") == -1) {
  2277. sCase = "?#" + sCase;
  2278. setNodeText(xmlElement, "case", "?#" + sCase);
  2279. }
  2280. }
  2281. var currType = sCase.split("#")[0];
  2282. var currGramma = sCase.split("#")[1];
  2283. //end gramma
  2284. /*meaning*/
  2285. /*find in dict*/
  2286. var arrMeaning = new Array();
  2287. var currMeaning = "";
  2288. var currGrammaMeaning = "";
  2289. var wordParent = "";
  2290. var wordGramma0 = "";
  2291. //self meaning
  2292. var thisWord = getNodeText(wordNode, "real");
  2293. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2294. if (
  2295. thisWord == g_DictWordList[iDict].Pali &&
  2296. g_DictWordList[iDict].Type != ".root." &&
  2297. g_DictWordList[iDict].Type != ".suf." &&
  2298. g_DictWordList[iDict].Type != ".prf."
  2299. ) {
  2300. if (
  2301. wordParent == "" &&
  2302. g_DictWordList[iDict].Parent.length > 0 &&
  2303. g_DictWordList[iDict].Parent != thisWord
  2304. ) {
  2305. wordParent = g_DictWordList[iDict].Parent;
  2306. wordGramma0 = g_DictWordList[iDict].Gramma;
  2307. }
  2308. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2309. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2310. if (currGrammaMeaning == "") {
  2311. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2312. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2313. }
  2314. }
  2315. }
  2316. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2317. for (var i = 0; i < arrMean.length; i++) {
  2318. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2319. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2320. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2321. arrMeaning.push(
  2322. g_DictWordList[iDict].dictID +
  2323. "$" +
  2324. arrMeaning.length +
  2325. "$$" +
  2326. arrMean[i] +
  2327. "$" +
  2328. g_DictWordList[iDict].Language
  2329. );
  2330. }
  2331. }
  2332. }
  2333. }
  2334. }
  2335. var wordGramma1 = "";
  2336. //find in father
  2337. if (wordParent != "") {
  2338. //add parent infomation
  2339. if (sParent == "" || sParent == " ") {
  2340. setNodeText(wordNode, "parent", wordParent);
  2341. sParent = wordParent;
  2342. }
  2343. thisWord = wordParent;
  2344. wordParent = "";
  2345. wordGramma1 = "";
  2346. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2347. if (
  2348. thisWord == g_DictWordList[iDict].Pali &&
  2349. g_DictWordList[iDict].Type != ".v." &&
  2350. g_DictWordList[iDict].Type != ".n." &&
  2351. g_DictWordList[iDict].Type != ".ti." &&
  2352. g_DictWordList[iDict].Type != ".adj." &&
  2353. g_DictWordList[iDict].Type != ".pron." &&
  2354. g_DictWordList[iDict].Type != ".num."
  2355. ) {
  2356. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2357. if (wordParent == "") {
  2358. wordParent = g_DictWordList[iDict].Parent;
  2359. }
  2360. if (wordGramma1 == "") {
  2361. wordGramma1 = g_DictWordList[iDict].Gramma;
  2362. }
  2363. }
  2364. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2365. for (var i = 0; i < arrMean.length; i++) {
  2366. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2367. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2368. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2369. arrMeaning.push(
  2370. g_DictWordList[iDict].dictID +
  2371. "$" +
  2372. arrMeaning.length +
  2373. "$*$" +
  2374. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2375. "$" +
  2376. g_DictWordList[iDict].Language
  2377. );
  2378. }
  2379. }
  2380. }
  2381. }
  2382. }
  2383. }
  2384. //爷爷跟父亲的关系 比如 pp
  2385. wordGranfatherGramma = wordGramma1;
  2386. wordGranfather = wordParent;
  2387. //grandfather
  2388. var wordGramma2 = "";
  2389. if (wordParent != "") {
  2390. thisWord = wordParent;
  2391. wordParent = "";
  2392. wordGramma2 = "";
  2393. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2394. if (
  2395. thisWord == g_DictWordList[iDict].Pali &&
  2396. g_DictWordList[iDict].Type != ".v." &&
  2397. g_DictWordList[iDict].Type != ".n." &&
  2398. g_DictWordList[iDict].Type != ".ti." &&
  2399. g_DictWordList[iDict].Type != ".adj." &&
  2400. g_DictWordList[iDict].Type != ".pron." &&
  2401. g_DictWordList[iDict].Type != ".num."
  2402. ) {
  2403. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2404. if (wordParent == "") {
  2405. wordParent = g_DictWordList[iDict].Parent;
  2406. }
  2407. if (wordGramma2 == "") {
  2408. wordGramma2 = g_DictWordList[iDict].Gramma;
  2409. }
  2410. }
  2411. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2412. for (var i = 0; i < arrMean.length; i++) {
  2413. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2414. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2415. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2416. arrMeaning.push(
  2417. g_DictWordList[iDict].dictID +
  2418. "$" +
  2419. arrMeaning.length +
  2420. "$**$" +
  2421. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2422. "$" +
  2423. g_DictWordList[iDict].Language
  2424. );
  2425. }
  2426. }
  2427. }
  2428. }
  2429. }
  2430. }
  2431. arrMeaning.sort(sortMeanByDictOrder);
  2432. //arrMeaning.sort(sortMeanByLanguageOrder);
  2433. newMeanList = removeSameWordInArray(arrMeaning);
  2434. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2435. if (sMean == "?") {
  2436. //自动匹配一个意思
  2437. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2438. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2439. currMeaning = currGrammaMeaning;
  2440. } else {
  2441. if (newMeanList.length > 0) {
  2442. currMeaning = newMeanList[0].word;
  2443. } else {
  2444. currMeaning = sMean;
  2445. }
  2446. }
  2447. } else {
  2448. currMeaning = removeFormula(sMean);
  2449. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2450. }
  2451. orgMeaning = removeFormula(currMeaning);
  2452. if (sReal.length < 4) {
  2453. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2454. } else {
  2455. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2456. }
  2457. setNodeText(wordNode, "mean", currMeaning);
  2458. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2459. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2460. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2461. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2462. //渲染下拉菜单
  2463. _txtOutDetail += "<div class='mean'>";
  2464. _txtOutDetail += render_word_mean_menu(wordNode);
  2465. //render formula menu
  2466. arrFormula = getFormulaList(currGramma);
  2467. _txtOutDetail += '<div class="case_dropdown">';
  2468. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2469. _txtOutDetail += '<div class="case_dropdown-content">';
  2470. newWord = removeFormula_B(orgMeaning);
  2471. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2472. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2473. for (var i in arrFormula) {
  2474. newWord = removeFormula_B(orgMeaning);
  2475. newWord = arrFormula[i].replace("~", newWord);
  2476. newWord = newWord.replace(/{/g, "[");
  2477. newWord = newWord.replace(/}/g, "]");
  2478. _txtOutDetail +=
  2479. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2480. }
  2481. _txtOutDetail += "</div>";
  2482. _txtOutDetail += "</div>";
  2483. _txtOutDetail += "</div> ";
  2484. /*end of meaning*/
  2485. /*org begin 拆分*/
  2486. /*
  2487. _txtOutDetail += "<p class='org' name='w_org'>";
  2488. _txtOutDetail += sOrg + "&nbsp;";
  2489. _txtOutDetail += "</p> ";
  2490. */
  2491. /*find in dict*/
  2492. var currOrg = "";
  2493. var wordParent = "";
  2494. var arrOrg = new Array();
  2495. var thisWord = getNodeText(wordNode, "real");
  2496. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2497. if (thisWord == g_DictWordList[iDict].Pali) {
  2498. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2499. wordParent = g_DictWordList[iDict].Parent;
  2500. }
  2501. var currOrg = g_DictWordList[iDict].Factors;
  2502. if (currOrg.length > 0 && currOrg != "?") {
  2503. pushNewToList(arrOrg, currOrg);
  2504. //arrOrg.push(currOrg);
  2505. }
  2506. }
  2507. }
  2508. //father
  2509. if (wordParent != "") {
  2510. thisWord = wordParent;
  2511. wordParent = "";
  2512. wordGramma1 = "";
  2513. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2514. if (thisWord == g_DictWordList[iDict].Pali) {
  2515. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2516. if (wordParent == "") {
  2517. wordParent = g_DictWordList[iDict].Parent;
  2518. }
  2519. }
  2520. var currOrg = g_DictWordList[iDict].Factors;
  2521. if (currOrg.length > 0 && currOrg != "?") {
  2522. pushNewToList(arrOrg, currOrg);
  2523. //arrOrg.push(currOrg);
  2524. }
  2525. }
  2526. }
  2527. }
  2528. //grandfather
  2529. if (wordParent != "") {
  2530. thisWord = wordParent;
  2531. wordParent = "";
  2532. wordGramma2 = "";
  2533. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2534. if (thisWord == g_DictWordList[iDict].Pali) {
  2535. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2536. if (wordParent == "") {
  2537. wordParent = g_DictWordList[iDict].Parent;
  2538. }
  2539. }
  2540. var currOrg = g_DictWordList[iDict].Factors;
  2541. if (currOrg.length > 0 && currOrg != "?") {
  2542. pushNewToList(arrOrg, currOrg);
  2543. //arrOrg.push(currOrg);
  2544. }
  2545. }
  2546. }
  2547. }
  2548. _txtOutDetail += "<div class='org' name='w_org'>";
  2549. _txtOutDetail += '<div class="case_dropdown">';
  2550. _txtOutDetail += "<p class='case_dropbtn' >";
  2551. if (sOrg == "?") {
  2552. if (arrOrg.length > 0) {
  2553. currOrg = arrOrg[0];
  2554. } else {
  2555. currOrg = sOrg;
  2556. }
  2557. setNodeText(wordNode, "org", currOrg);
  2558. } else {
  2559. currOrg = sOrg;
  2560. }
  2561. _txtOutDetail += currOrg;
  2562. if (arrOrg.length > 0) {
  2563. _txtOutDetail += "<svg class='edit_icon'>";
  2564. _txtOutDetail += "<use xlink:href='svg/icon.svg#ic_down'></use>";
  2565. _txtOutDetail += "</svg>";
  2566. }
  2567. _txtOutDetail += "</p>";
  2568. _txtOutDetail += '<div class="case_dropdown-content">';
  2569. _txtOutDetail +=
  2570. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  2571. wordID +
  2572. '","org","")\'>' +
  2573. gLocal.gui.empty1 +
  2574. "</button>";
  2575. _txtOutDetail +=
  2576. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" +
  2577. wordID +
  2578. "\")'>" +
  2579. gLocal.gui.wordmap +
  2580. "</button>";
  2581. //新加 base 信息 vn
  2582. _txtOutDetail += '<div class="case_dropdown-org">';
  2583. _txtOutDetail += '<div class="case_dropdown-first">';
  2584. _txtOutDetail += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
  2585. _txtOutDetail += sParent + "</a>";
  2586. _txtOutDetail += "<span style='z-index:220' class='case_dropdown-title'>";
  2587. _txtOutDetail += gLocal.gui.more + "»</span>";
  2588. _txtOutDetail += "</div>";
  2589. for (i in arrOrg) {
  2590. _txtOutDetail +=
  2591. "<a onclick='fieldListChanged(\"" + wordID + '","org","' + arrOrg[i] + "\")'>" + arrOrg[i] + "</a>";
  2592. }
  2593. _txtOutDetail += "</div>";
  2594. _txtOutDetail += "</div>";
  2595. _txtOutDetail += "</div>";
  2596. _txtOutDetail += "</div> ";
  2597. /*end of factors*/
  2598. /*part meaning begin*/
  2599. listFactorForFactorMean = currOrg.split("+");
  2600. currDefualtFM = "";
  2601. for (iFactor in listFactorForFactorMean) {
  2602. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2603. }
  2604. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  2605. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  2606. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  2607. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  2608. if (currDefualtFM.slice(-1, -2) == "+") {
  2609. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  2610. }
  2611. /*find in dict*/
  2612. var currOM = "";
  2613. var wordParent = "";
  2614. var arrOM = new Array();
  2615. var thisWord = getNodeText(wordNode, "real");
  2616. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2617. if (thisWord == g_DictWordList[iDict].Pali) {
  2618. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2619. wordParent = g_DictWordList[iDict].Parent;
  2620. }
  2621. var currOM = g_DictWordList[iDict].FactorMean;
  2622. if (currOM.length > 0 && currOM != "?") {
  2623. pushNewToList(arrOM, currOM);
  2624. //arrOM.push(currOM);
  2625. }
  2626. }
  2627. }
  2628. /*
  2629. //father
  2630. if(wordParent!=""){
  2631. thisWord=wordParent;
  2632. wordParent="";
  2633. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  2634. if(thisWord==g_DictWordList[iDict].Pali){
  2635. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  2636. if(wordParent==""){
  2637. wordParent=g_DictWordList[iDict].Parent;
  2638. }
  2639. }
  2640. var currOM=g_DictWordList[iDict].FactorMean;
  2641. if(currOM.length>0 && currOM!="?"){
  2642. pushNewToList(arrOM,currOM);
  2643. }
  2644. }
  2645. }
  2646. }
  2647. //grandfather
  2648. if(wordParent!=""){
  2649. thisWord=wordParent;
  2650. wordParent="";
  2651. wordGramma2="";
  2652. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  2653. if(thisWord==g_DictWordList[iDict].Pali){
  2654. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  2655. if(wordParent==""){
  2656. wordParent=g_DictWordList[iDict].Parent;
  2657. }
  2658. }
  2659. var currOM=g_DictWordList[iDict].FactorMean;
  2660. if(currOM.length>0 && currOM!="?"){
  2661. pushNewToList(arrOM,currOM);
  2662. }
  2663. }
  2664. }
  2665. }
  2666. */
  2667. _txtOutDetail += "<div class='om' name='w_om'>";
  2668. _txtOutDetail += '<div class="case_dropdown">';
  2669. _txtOutDetail += "<p class='case_dropbtn' >";
  2670. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  2671. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  2672. if (arrOM.length > 0) {
  2673. currOM = arrOM[0];
  2674. } else {
  2675. currOM = "[a]" + currDefualtFM;
  2676. }
  2677. setNodeText(wordNode, "om", currOM);
  2678. } else {
  2679. currOM = sOm;
  2680. }
  2681. _txtOutDetail += currOM;
  2682. if (arrOM.length > 0) {
  2683. _txtOutDetail += " ▾";
  2684. }
  2685. _txtOutDetail += "</p>";
  2686. _txtOutDetail += '<div class="case_dropdown-content">';
  2687. _txtOutDetail +=
  2688. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  2689. wordID +
  2690. '","om","")\'>' +
  2691. gLocal.gui.empty1 +
  2692. "</button>";
  2693. _txtOutDetail +=
  2694. "<a onclick='fieldListChanged(\"" +
  2695. wordID +
  2696. '","om","[a]' +
  2697. currDefualtFM +
  2698. "\")'>[" +
  2699. gLocal.gui.auto +
  2700. "]" +
  2701. currDefualtFM +
  2702. "</a>";
  2703. for (i in arrOM) {
  2704. _txtOutDetail +=
  2705. "<a onclick='fieldListChanged(\"" + wordID + '","om","' + arrOM[i] + "\")'>" + arrOM[i] + "</a>";
  2706. }
  2707. _txtOutDetail += "</div>";
  2708. _txtOutDetail += "</div>";
  2709. _txtOutDetail += "</div> ";
  2710. /*org meaning end*/
  2711. /*begin gramma*/
  2712. _txtOutDetail += "<div class='case'>";
  2713. _txtOutDetail += '<div class="case_dropdown">';
  2714. _txtOutDetail += "<p class='case_dropbtn' >";
  2715. sLocalCase = getLocalGrammaStr(sCase);
  2716. var mArrGramma = sCase.split("#");
  2717. if (mArrGramma.length >= 2) {
  2718. mType = mArrGramma[0];
  2719. mGramma = mArrGramma[1];
  2720. mLocalType = sLocalCase.split("#")[0];
  2721. mLocalGramma = sLocalCase.split("#")[1];
  2722. } else {
  2723. mType = "";
  2724. mGramma = mArrGramma[0];
  2725. mLocalType = "";
  2726. mLocalGramma = sLocalCase.split("#")[0];
  2727. }
  2728. if (mType != "") {
  2729. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  2730. }
  2731. _txtOutDetail += cutString(mLocalGramma, 30);
  2732. _txtOutDetail += "</p>";
  2733. _txtOutDetail += '<div class="case_dropdown-content">';
  2734. for (i in arrGramma) {
  2735. _txtOutDetail +=
  2736. "<a onclick='fieldListChanged(\"" +
  2737. wordID +
  2738. '","case","' +
  2739. arrGramma[i] +
  2740. "\")'>" +
  2741. cutString(getLocalGrammaStr(arrGramma[i]), 30) +
  2742. "</a>";
  2743. }
  2744. _txtOutDetail += "</div>";
  2745. _txtOutDetail += "</div>";
  2746. //连读词按钮
  2747. if (mType == ".un." || mType == ".comp.") {
  2748. nextElement = com_get_nextsibling(xmlElement);
  2749. if (nextElement != null) {
  2750. //下一个元素存在
  2751. if (getNodeText(nextElement, "un") == sId) {
  2752. //若有孩子則显示收起按鈕
  2753. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  2754. _txtOutDetail +=
  2755. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  2756. _txtOutDetail += "</button>";
  2757. var parentElement = document.getElementById("wb" + sId);
  2758. if (parentElement) {
  2759. parentElement.classList.add("un_parent");
  2760. }
  2761. } else {
  2762. //無kid展開按鈕
  2763. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2764. _txtOutDetail +=
  2765. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2766. _txtOutDetail += "</button> ";
  2767. }
  2768. } else {
  2769. //下一个元素不存在
  2770. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2771. _txtOutDetail +=
  2772. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2773. _txtOutDetail += "</button> ";
  2774. }
  2775. }
  2776. //连读词按钮 结束
  2777. //爷爷和父亲的关系 如pp
  2778. if (wordGranfatherGramma.length > 0 && wordGranfatherGramma.length < 6) {
  2779. _txtOutDetail +=
  2780. '<span class="tooltip">«' +
  2781. getLocalGrammaStr(wordGranfatherGramma) +
  2782. '<span class="tooltiptext tooltip-bottom">' +
  2783. wordGranfather +
  2784. "</span>" +
  2785. "</span> ";
  2786. }
  2787. _txtOutDetail += "</div> ";
  2788. /*end of gramma*/
  2789. //Auto Match Finished
  2790. _txtOutDetail += "</div>";
  2791. }
  2792. return _txtOutDetail;
  2793. }
  2794. function renderWordNoteDivByParaNo(book, paragraph) {}
  2795. /*
  2796. paragraph word note
  2797. */
  2798. function renderWordNoteDivByElement(elementBlock) {
  2799. let output = "";
  2800. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  2801. let book = getNodeText(xmlParInfo, "book");
  2802. let paragraph = getNodeText(xmlParInfo, "paragraph");
  2803. let bId = getNodeText(xmlParInfo, "id");
  2804. let type = getNodeText(xmlParInfo, "type");
  2805. let allWord = elementBlock.getElementsByTagName("word");
  2806. let iNoteCounter = 0;
  2807. for (iWord = 0; iWord < allWord.length; iWord++) {
  2808. let oneNote = "";
  2809. let pali = getNodeText(allWord[iWord], "pali");
  2810. let sNote = getNodeText(allWord[iWord], "note");
  2811. if (sNote != "") {
  2812. oneNote += note_init(sNote);
  2813. }
  2814. let sRela = getNodeText(allWord[iWord], "rela");
  2815. if (sRela != "") {
  2816. oneNote += "<div>" + renderWordRelation(allWord[iWord]) + "</div>";
  2817. }
  2818. id = getNodeText(allWord[iWord], "id");
  2819. if (oneNote == "") {
  2820. //有内容
  2821. $("#wnote_root_" + id).html("");
  2822. } else {
  2823. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  2824. output += "<div>";
  2825. output += "<wnc wid='" + id + "'></wnc>";
  2826. output += "<strong>" + pali + ":</strong>";
  2827. output += oneNote;
  2828. output += "</div>";
  2829. }
  2830. }
  2831. return output;
  2832. }
  2833. function refreshWordNoteDiv(elementBlock) {
  2834. let html = renderWordNoteDivByElement(elementBlock);
  2835. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  2836. let book = getNodeText(xmlParInfo, "book");
  2837. let paragraph = getNodeText(xmlParInfo, "paragraph");
  2838. try {
  2839. if (html == "") {
  2840. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
  2841. } else {
  2842. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
  2843. }
  2844. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = html;
  2845. } catch (e) {
  2846. console.error(e.message);
  2847. console.error("wnote_" + book + "_" + (paragraph - 1));
  2848. }
  2849. }
  2850. function refreshWordNote(elementBlock) {
  2851. var output = "";
  2852. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  2853. book = getNodeText(xmlParInfo, "book");
  2854. paragraph = getNodeText(xmlParInfo, "paragraph");
  2855. bId = getNodeText(xmlParInfo, "id");
  2856. type = getNodeText(xmlParInfo, "type");
  2857. var allWord = elementBlock.getElementsByTagName("word");
  2858. var iNoteCounter = 0;
  2859. for (iWord = 0; iWord < allWord.length; iWord++) {
  2860. pali = getNodeText(allWord[iWord], "pali");
  2861. wnote = note_init(getNodeText(allWord[iWord], "note"));
  2862. id = getNodeText(allWord[iWord], "id");
  2863. var note = wnote;
  2864. if (note.length > 0 && note != "?") {
  2865. iNoteCounter++;
  2866. if (wnote.substring(0, 6) == "=term(") {
  2867. var termId = wnote.slice(6, -1);
  2868. //alert(arrTerm.length);
  2869. if (arrTerm[note]) {
  2870. note = "<term guid='" + termId + "' pos='wbw'>" + arrTerm[termId].note + "</term>";
  2871. } else {
  2872. note = "<term guid='" + termId + "' pos='wbw'></term>";
  2873. }
  2874. }
  2875. output += '<p><a href="#word_note_root_' + id + '" name="word_note_' + id + '">[' + iNoteCounter + "]</a>";
  2876. if (note.match("{") && note.match("}")) {
  2877. note = note.replace("{", "<strong>");
  2878. note = note.replace("}", "</strong>");
  2879. if (note.length > 100) {
  2880. shortNote = note.substring(0, 99);
  2881. otherNode = note.substring(100);
  2882. output +=
  2883. shortNote +
  2884. '<span class="full_note_handle">...<span class="full_note">' +
  2885. otherNode +
  2886. "</span></span>";
  2887. } else {
  2888. output += note;
  2889. }
  2890. } else {
  2891. if (note.length > 100) {
  2892. shortNote = note.substring(0, 99);
  2893. otherNode = note.substring(100);
  2894. output +=
  2895. shortNote +
  2896. '<span class="full_note_handle">...<span class="full_note">' +
  2897. otherNode +
  2898. "</span></span>";
  2899. } else {
  2900. output += "<strong>" + pali + ":</strong>" + note;
  2901. }
  2902. }
  2903. output += "</p>";
  2904. if (termId) {
  2905. document.getElementById("wnote_root_" + id).innerHTML =
  2906. "<a onclick=\"term_show_win('" +
  2907. termId +
  2908. '\')" name="word_note_root_' +
  2909. id +
  2910. '">[' +
  2911. iNoteCounter +
  2912. "]</a>";
  2913. } else {
  2914. document.getElementById("wnote_root_" + id).innerHTML =
  2915. '<a href="#word_note_' + id + '" name="word_note_root_' + id + '">[' + iNoteCounter + "]</a>";
  2916. }
  2917. } else {
  2918. noteRootObj = document.getElementById("wnote_root_" + id);
  2919. if (noteRootObj) {
  2920. document.getElementById("wnote_root_" + id).innerHTML = "";
  2921. }
  2922. }
  2923. }
  2924. if (output == "") {
  2925. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
  2926. } else {
  2927. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
  2928. }
  2929. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = output;
  2930. }
  2931. function updateWordNote(element) {
  2932. let paliword = getNodeText(element, "real");
  2933. let wnote = getNodeText(element, "note");
  2934. wnote = note_init(wnote);
  2935. let id = getNodeText(element, "id");
  2936. if (wnote == "") {
  2937. $("#wnote_root_" + id).html("");
  2938. $("#wnn_" + id).html("");
  2939. } else {
  2940. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  2941. let output = "";
  2942. output += "<wnc wid='" + id + "'></wnc>";
  2943. let head = "";
  2944. let content = "";
  2945. if (wnote.match("{") && wnote.match("}")) {
  2946. wnote = wnote.replace("{", "<strong>");
  2947. wnote = wnote.replace("}", "</strong>");
  2948. } else {
  2949. output += "<strong>" + paliword + ":</strong>";
  2950. }
  2951. output += wnote;
  2952. $("#wnn_" + id).html(output);
  2953. }
  2954. }
  2955. function updateWordCommentary(element) {}
  2956. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  2957. //返回 无
  2958. function updataWordBodyByElement(element) {
  2959. try {
  2960. var sId = getNodeText(wordNode, "id");
  2961. var sDetail = "detail" + sId;
  2962. var cDetail = document.getElementById(sDetail);
  2963. if (cDetail != null) {
  2964. cDetail.innerHTML = renderWordDetailByElement(element);
  2965. }
  2966. } catch (error) {
  2967. var_dump(error);
  2968. }
  2969. }
  2970. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  2971. //返回 无
  2972. function modifyWordDetailByWordId(wordId) {
  2973. try {
  2974. var sDetail = "detail" + wordId;
  2975. var cDetail = document.getElementById(sDetail);
  2976. if (cDetail != null) {
  2977. cDetail.innerHTML = renderWordDetailById(wordId);
  2978. }
  2979. } catch (error) {
  2980. var_dump(error);
  2981. }
  2982. }
  2983. //根据xmlDocument 对象中的单词GUID返回单词块字符串(不含Pali)
  2984. //返回 字符串
  2985. function renderWordDetailById(wordID) {
  2986. var mXML = gXmlBookDataBody.getElementsByTagName("word");
  2987. var wordIndex = getWordIndex(wordID);
  2988. return renderWordDetailByElement(mXML[wordIndex]);
  2989. }
  2990. function reloadPar(parIndex) {
  2991. bookId = gArrayDocParagraph[parIndex].book;
  2992. parNo = gArrayDocParagraph[parIndex].paragraph;
  2993. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  2994. if (htmlBlock.style.display != "none") {
  2995. return false;
  2996. }
  2997. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  2998. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  2999. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  3000. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  3001. currBookId = getNodeText(xmlParInfo, "book");
  3002. currParNo = getNodeText(xmlParInfo, "paragraph");
  3003. if (bookId == currBookId && currParNo == parNo) {
  3004. insertBlockToHtml(allBlock[iBlock]);
  3005. }
  3006. }
  3007. return true;
  3008. }
  3009. function removePar(parIndex) {
  3010. bookId = gArrayDocParagraph[parIndex].book;
  3011. parNo = gArrayDocParagraph[parIndex].paragraph;
  3012. if (gCurrModifyWindowParNo == parIndex) {
  3013. //关闭单词修改窗口
  3014. closeModifyWindow();
  3015. }
  3016. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3017. if (htmlBlock) {
  3018. htmlBlock.style.display = "none";
  3019. document.getElementById("heading_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3020. document.getElementById("wblock_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3021. document.getElementById("tran_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3022. document.getElementById("wnote_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3023. document.getElementById("note_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3024. }
  3025. }
  3026. function setView(topParIndex) {
  3027. var parInOnePage = 3;
  3028. gCurrTopParagraph = topParIndex;
  3029. gVisibleParBegin = topParIndex - parInOnePage;
  3030. gVisibleParEnd = parInOnePage * 2;
  3031. if (gVisibleParBegin < 0) {
  3032. gVisibleParBegin = 0;
  3033. }
  3034. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3035. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3036. }
  3037. }
  3038. function isParInView(parIndex) {
  3039. if (parIndex >= gVisibleParBegin && parIndex <= gVisibleParEnd) {
  3040. return true;
  3041. } else {
  3042. return false;
  3043. }
  3044. }
  3045. function refresh_Dispaly_Cap() {
  3046. var new_par_length = gPalitext_length / gtext_max_length;
  3047. for (refresh_i in allTextLen_array) {
  3048. gNewArrayDocParagraph.push(allTextLen_array[refresh_i].length / gtext_max_length);
  3049. }
  3050. }
  3051. function prev_page() {
  3052. //向上翻页
  3053. gVisibleParBeginOld = gVisibleParBegin;
  3054. gVisibleParEndOld = gVisibleParEnd;
  3055. if (g_allparlen_array[gVisibleParEnd - 1] - g_allparlen_array[gVisibleParBegin - 1] <= gDisplayCapacity) {
  3056. gVisibleParBegin -= 1;
  3057. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin - 1] > gDisplayCapacity) {
  3058. gVisibleParBegin -= 1;
  3059. gVisibleParEnd -= 1;
  3060. }
  3061. if (gVisibleParBegin < 0) {
  3062. //如果到顶,则恢复原始值
  3063. gVisibleParBegin = 0;
  3064. //gVisibleParEnd=gDisplayCapacity;
  3065. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3066. //如果到底,则锁死最大值
  3067. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3068. }
  3069. }
  3070. updataView();
  3071. }
  3072. function next_page() {
  3073. //向下翻页
  3074. gVisibleParBeginOld = gVisibleParBegin;
  3075. gVisibleParEndOld = gVisibleParEnd;
  3076. if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] <= gDisplayCapacity) {
  3077. gVisibleParEnd += 1;
  3078. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] > gDisplayCapacity) {
  3079. gVisibleParBegin += 1;
  3080. gVisibleParEnd += 1;
  3081. }
  3082. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3083. //如果到底
  3084. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3085. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3086. if (gVisibleParBegin < 0) {
  3087. gVisibleParBegin = 0;
  3088. }
  3089. }
  3090. updataView();
  3091. }
  3092. function setNewView(newBegin, newEnd) {
  3093. gVisibleParBeginOld = gVisibleParBegin;
  3094. gVisibleParEndOld = gVisibleParEnd;
  3095. gVisibleParBegin = newBegin;
  3096. gVisibleParEnd = newEnd;
  3097. if (gVisibleParBegin < 0) {
  3098. gVisibleParBegin = 0;
  3099. //gVisibleParEnd=gDisplayCapacity;
  3100. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3101. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3102. }
  3103. }
  3104. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3105. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3106. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3107. if (gVisibleParBegin < 0) {
  3108. gVisibleParBegin = 0;
  3109. }
  3110. }
  3111. updataView();
  3112. }
  3113. function updataView() {
  3114. var topNewDivArray = Array(); //在顶端新加入的块列表
  3115. for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  3116. if (isParInView(iPar)) {
  3117. isLoadNew = reloadPar(iPar);
  3118. if (isLoadNew) {
  3119. if (iPar < gVisibleParBeginOld) {
  3120. topNewDivArray.push(iPar);
  3121. }
  3122. }
  3123. } else {
  3124. removePar(iPar);
  3125. }
  3126. }
  3127. word_mouse_event();
  3128. //console.log("updataview");
  3129. console.log(topNewDivArray.toString());
  3130. }
  3131. function render_word_mean_menu2(spell) {
  3132. var wReal = spell;
  3133. var output = "<div>";
  3134. for (var iDict = 0; iDict < mDict[spell].length; iDict++) {
  3135. output += "<div>";
  3136. output += "<span>dict_name</span>";
  3137. var meanGroup = partList2[i].mean.split("$");
  3138. for (var iMean = 0; iMean < meanGroup.length; iMean++) {
  3139. output +=
  3140. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3141. wId +
  3142. '","mean","' +
  3143. meanGroup[iMean] +
  3144. "\")'>" +
  3145. meanGroup[iMean] +
  3146. "</span>";
  3147. }
  3148. output += "</div>";
  3149. }
  3150. output += "</div>";
  3151. return;
  3152. var sWord = new Array(wReal);
  3153. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3154. for (var iWord in sWord) {
  3155. output += '<div class="case_dropdown-first">';
  3156. output +=
  3157. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3158. sWord[iWord] +
  3159. "\")'>";
  3160. output += sWord[iWord] + "</a>";
  3161. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3162. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3163. output += '</span><div class="case_dropdown-detail">';
  3164. var partList = render_get_word_mean_list(sWord[iWord]);
  3165. var L_width_mean = 0;
  3166. var partList2 = repeat_combine(partList);
  3167. //计算字符长度并控制
  3168. for (var i in partList2) {
  3169. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3170. if (L_width_mean < L_width / 1.7) {
  3171. L_width_mean = L_width / 1.7;
  3172. }
  3173. }
  3174. for (var i in partList2) {
  3175. var meanGroup = partList2[i].mean.split("$");
  3176. var htmlMean = "";
  3177. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3178. output +=
  3179. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3180. //output += "<a ><div id='div_dictname_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_dictname+"em; display:flex'>"
  3181. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3182. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3183. output += getLocalDictname(partList2[i].dict) + "</span>";
  3184. output += "</div>";
  3185. output +=
  3186. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3187. //output += "<div id='div_type_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_type+"em; display:flex'>"
  3188. output +=
  3189. "<span id='span_type_" +
  3190. wId +
  3191. "_" +
  3192. iWord +
  3193. "_" +
  3194. i +
  3195. "' style='height: 1.5em;' class='wm_wordtype'>" +
  3196. getLocalGrammaStr(partList2[i].type) +
  3197. "</span>";
  3198. for (var iMean in meanGroup) {
  3199. if (meanGroup[iMean] != "") {
  3200. htmlMean +=
  3201. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3202. wId +
  3203. '","mean","' +
  3204. meanGroup[iMean] +
  3205. "\")'>" +
  3206. meanGroup[iMean] +
  3207. "</span>";
  3208. }
  3209. }
  3210. output += "</div><div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3211. output += "</a>";
  3212. }
  3213. output += "</div></div>";
  3214. }
  3215. output += "</div></div></div>";
  3216. return output;
  3217. }
  3218. function render_word_mean_menu(xElement) {
  3219. var wMean = getNodeText(xElement, "mean");
  3220. var wReal = getNodeText(xElement, "real");
  3221. var wId = getNodeText(xElement, "id");
  3222. var renderMeaning = wMean.replace(/{/g, "<span class='grm_add_mean'>");
  3223. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  3224. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  3225. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  3226. var output = "";
  3227. output += '<div class="case_dropdown">';
  3228. output += "<p class='case_dropbtn' >";
  3229. output += renderMeaning;
  3230. output += "</p>";
  3231. output += '<div class="case_dropdown-content">';
  3232. output +=
  3233. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3234. wId +
  3235. '","mean","")\'>' +
  3236. gLocal.gui.empty1 +
  3237. '</button><div class="case_dropdown-org">';
  3238. var sWord = new Array(wReal);
  3239. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3240. for (var iWord in sWord) {
  3241. output += '<div class="case_dropdown-first">';
  3242. output +=
  3243. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3244. sWord[iWord] +
  3245. "\")'>";
  3246. output += sWord[iWord] + "</a>";
  3247. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3248. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3249. output += "</span>";
  3250. output += '<div class="case_dropdown-detail">';
  3251. var partList = render_get_word_mean_list(sWord[iWord]);
  3252. var L_width_mean = 0;
  3253. var partList2 = repeat_combine(partList);
  3254. for (var i in partList2) {
  3255. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3256. if (L_width_mean < L_width / 1.7) {
  3257. L_width_mean = L_width / 1.7;
  3258. }
  3259. }
  3260. for (var i in partList2) {
  3261. var meanGroup = partList2[i].mean.split("$");
  3262. var htmlMean = "";
  3263. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3264. output +=
  3265. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3266. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3267. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3268. output += getLocalDictname(partList2[i].dict) + "</span>";
  3269. output += "</div>";
  3270. output +=
  3271. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3272. output +=
  3273. "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>";
  3274. if (partList2[i].type == ".n:base.") {
  3275. output += getLocalGrammaStr(partList2[i].gramma);
  3276. } else {
  3277. output += getLocalGrammaStr(partList2[i].type);
  3278. }
  3279. output += "</span>";
  3280. for (var iMean in meanGroup) {
  3281. if (meanGroup[iMean] != "") {
  3282. htmlMean +=
  3283. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3284. wId +
  3285. '","mean","' +
  3286. meanGroup[iMean] +
  3287. "\")'>" +
  3288. meanGroup[iMean] +
  3289. "</span>";
  3290. }
  3291. }
  3292. output += "</div>";
  3293. output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3294. output += "</a>";
  3295. }
  3296. output += "</div></div>";
  3297. }
  3298. output += "</div></div></div>";
  3299. return output;
  3300. }
  3301. function render_get_word_mean_list(sWord) {
  3302. var wReal = sWord;
  3303. var output = Array();
  3304. for (var x in g_DictWordList) {
  3305. if (g_DictWordList[x].Pali == wReal || g_DictWordList[x].Real == wReal) {
  3306. if (dict_language_enable.indexOf(g_DictWordList[x].Language) >= 0) {
  3307. if (
  3308. g_DictWordList[x].Mean != "" &&
  3309. g_DictWordList[x].Type != ".part." &&
  3310. g_DictWordList[x].Type != ".root." &&
  3311. g_DictWordList[x].Type != ".suf." &&
  3312. g_DictWordList[x].Type != ".pfx."
  3313. ) {
  3314. var newPart = Object();
  3315. newPart.dict = g_DictWordList[x].dictname;
  3316. newPart.mean = g_DictWordList[x].Mean;
  3317. newPart.type = g_DictWordList[x].Type;
  3318. var bIsExist = false;
  3319. for (var iBuffer in output) {
  3320. if (
  3321. output[iBuffer].dict == newPart.dict &&
  3322. output[iBuffer].type == newPart.type &&
  3323. output[iBuffer].mean == newPart.mean
  3324. ) {
  3325. bIsExist = true;
  3326. break;
  3327. }
  3328. if (newPart.dict == "wbw") {
  3329. if (output[iBuffer].dict == newPart.dict && output[iBuffer].type == newPart.type) {
  3330. output[iBuffer].mean += "$" + newPart.mean;
  3331. bIsExist = true;
  3332. break;
  3333. }
  3334. }
  3335. }
  3336. if (!bIsExist) {
  3337. output.push(newPart);
  3338. }
  3339. }
  3340. }
  3341. }
  3342. }
  3343. return output;
  3344. }
  3345. function render_get_word_parent_list(sWord) {
  3346. var wReal = sWord;
  3347. var output = Array();
  3348. for (var x in g_DictWordList) {
  3349. if (g_DictWordList[x].Pali == wReal) {
  3350. {
  3351. if (g_DictWordList[x].Parent != "" && g_DictWordList[x].Parent != sWord) {
  3352. var newPart = g_DictWordList[x].Parent;
  3353. var bIsExist = false;
  3354. for (var iBuffer in output) {
  3355. if (output[iBuffer] == newPart) {
  3356. bIsExist = true;
  3357. break;
  3358. }
  3359. }
  3360. if (!bIsExist) {
  3361. output.push(newPart);
  3362. }
  3363. }
  3364. }
  3365. }
  3366. }
  3367. return output;
  3368. }
  3369. function repeat_combine(list) {
  3370. var list_new = new Array();
  3371. for (var repeat_combine_i = 0; repeat_combine_i < list.length; repeat_combine_i++) {
  3372. var repeat_string = new Object();
  3373. var repeat_combine_j = 0;
  3374. repeat_string.dict = list[repeat_combine_i].dict;
  3375. repeat_string.type = list[repeat_combine_i].type;
  3376. repeat_string.mean = list[repeat_combine_i].mean;
  3377. for (repeat_combine_j = repeat_combine_i + 1; repeat_combine_j < list.length; repeat_combine_j++) {
  3378. if (
  3379. list[repeat_combine_j].dict == list[repeat_combine_i].dict &&
  3380. list[repeat_combine_j].type == list[repeat_combine_i].type
  3381. ) {
  3382. repeat_string.mean = repeat_string.mean + "$" + list[repeat_combine_j].mean;
  3383. repeat_string.mean = repeat_string.mean.replace(/\$\$/g, "$");
  3384. repeat_string.mean = repeat_string.mean.replace(/\$ /g, "$");
  3385. repeat_string.mean = repeat_string.mean.replace(/ \$/g, "$");
  3386. repeat_combine_i = repeat_combine_j;
  3387. }
  3388. }
  3389. repeat_string.mean = "#" + repeat_string.mean + "#";
  3390. repeat_string.mean = repeat_string.mean.replace(/ #/g, "");
  3391. repeat_string.mean = repeat_string.mean.replace(/# /g, "");
  3392. repeat_string.mean = repeat_string.mean.replace(/\$#/g, "");
  3393. repeat_string.mean = repeat_string.mean.replace(/#\$/g, "");
  3394. repeat_string.mean = repeat_string.mean.replace(/ /g, "");
  3395. repeat_string.mean = repeat_string.mean.replace(/#/g, "");
  3396. list_new.push(repeat_string);
  3397. }
  3398. return list_new;
  3399. }
  3400. function show_pop_note(wordid) {
  3401. let html = $("wnc[wid='" + wordid + "']")
  3402. .parent()
  3403. .html();
  3404. $("#word_note_pop_content").html(
  3405. html
  3406. /*note_init(doc_word("#" + wordid).val("note"))*/
  3407. );
  3408. $("#word_note_pop").show("500");
  3409. }
  3410. function refreshNoteNumber() {
  3411. $("wnh").each(function (index, element) {
  3412. let id = $(this).attr("wid");
  3413. //$(this).html("<a href='#word_note_"+id+"' name=\"word_note_root_"+id+"\">"+(index+1)+"</a>");
  3414. $(this).html("<span onclick=\"show_pop_note('" + id + "')\">" + (index + 1) + "</span>");
  3415. });
  3416. $("wnc").each(function (index, element) {
  3417. let id = $(this).attr("wid");
  3418. $(this).html("<a href='#word_note_root_" + id + "' name=\"word_note_" + id + '">[' + (index + 1) + "]</a>");
  3419. });
  3420. note_refresh_new();
  3421. }