render.js 120 KB

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