render.js 135 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168
  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 += "<span style='flex: 7;display: flex;'>";
  1082. output += "<div style='background-color: silver;'>";
  1083. //句子编号
  1084. output += "<span style='font-size: large; font-weight: bolder;' title=" + gLocal.gui.text_num + ">";
  1085. output += sentIdString;
  1086. output += "</span>";
  1087. //功能按钮
  1088. //拷贝到剪贴板
  1089. output +=
  1090. "<button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1091. sentIdStringLink +
  1092. "')\" title=" +
  1093. gLocal.gui.copy_to_clipboard +
  1094. ">";
  1095. output +=
  1096. '<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>';
  1097. output += "</button>";
  1098. //在阅读器中打开
  1099. let reader_open_link = "";
  1100. if (_display_sbs == 0) {
  1101. //逐段模式
  1102. reader_open_link = "../reader/?view=para&book=" + abook + "&para=" + aparagraph;
  1103. } else {
  1104. //逐句模式
  1105. reader_open_link =
  1106. "../reader/?view=sent&book=" + abook + "&para=" + aparagraph + "&begin=" + iBegin + "&end=" + iEnd;
  1107. }
  1108. output +=
  1109. "<button class='icon_btn' onclick=\"window.open('" +
  1110. reader_open_link +
  1111. "')\" target='_blank' title='" +
  1112. gLocal.gui.scan_in_reader +
  1113. "'>";
  1114. output +=
  1115. '<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>';
  1116. output += "</button>";
  1117. //关系图
  1118. output +=
  1119. "<button class='icon_btn' title='" +
  1120. gLocal.gui.relational_map +
  1121. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1122. abook +
  1123. "','" +
  1124. aparagraph +
  1125. "','" +
  1126. iBegin +
  1127. "','" +
  1128. iEnd +
  1129. "')\">" +
  1130. '<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>' +
  1131. "</button>";
  1132. //拷贝词意到剪贴板
  1133. output +=
  1134. "<button class='icon_btn' title='" +
  1135. "copy meaning" +
  1136. "' class='rel_map' onclick=\"sent_copy_meaning('" +
  1137. abook +
  1138. "','" +
  1139. aparagraph +
  1140. "','" +
  1141. iBegin +
  1142. "','" +
  1143. iEnd +
  1144. "')\">" +
  1145. '<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>' +
  1146. "</button>";
  1147. //功能按钮结束
  1148. output += "</div>";
  1149. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1150. output += "</span>";
  1151. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1152. output += "</div>";
  1153. return output;
  1154. }
  1155. var arr_par_sent_num = new Array();
  1156. var g_arr_Para_ID = new Array();
  1157. function renderWordParBlockInner(elementBlock) {
  1158. var output = "<div style='display:block;width:100%'>";
  1159. var Note_Mark = 0;
  1160. var sent_gramma_i = 0;
  1161. var word_length_count = 0;
  1162. var sent_num = 0;
  1163. var arr_Para_ID = new Array();
  1164. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1165. let book = getNodeText(xmlParInfo, "book");
  1166. let paragraph = getNodeText(xmlParInfo, "paragraph");
  1167. let par_num = paragraph - 1;
  1168. let type = getNodeText(xmlParInfo, "type");
  1169. let allWord = elementBlock.getElementsByTagName("word");
  1170. output += "<div class='sent_wbw_trans'>";
  1171. output += render_sent_tool_bar(elementBlock, 0);
  1172. output += "<div class='sent_wbw'>";
  1173. let sent_begin = 0;
  1174. let wID;
  1175. let word_id;
  1176. for (let iWord = 0; iWord < allWord.length; iWord++) {
  1177. wID = getNodeText(allWord[iWord], "id");
  1178. let wPali = getNodeText(allWord[iWord], "pali");
  1179. let wReal = getNodeText(allWord[iWord], "real");
  1180. let wType = getNodeText(allWord[iWord], "type");
  1181. let wGramma = getNodeText(allWord[iWord], "gramma");
  1182. let wCase = getNodeText(allWord[iWord], "case");
  1183. let wMean = getNodeText(allWord[iWord], "mean");
  1184. let wParent = getNodeText(allWord[iWord], "parent");
  1185. let wUn = getNodeText(allWord[iWord], "un");
  1186. let wStyle = getNodeText(allWord[iWord], "style");
  1187. let wEnter = getNodeText(allWord[iWord], "enter");
  1188. if ((wType == "" || wType == "?") && wCase != "") {
  1189. wType = wCase.split("#")[0];
  1190. }
  1191. word_id = parseInt(wID.split("-")[2]);
  1192. if (sent_begin == 0) {
  1193. sent_begin = word_id;
  1194. }
  1195. //渲染单词块
  1196. //word div class
  1197. let strMouseEvent = ' onmouseover="on_word_mouse_enter()" onmouseout="on_word_mouse_leave()"';
  1198. if (wType == ".ctl." && wGramma == ".a.") {
  1199. //output += "<div><a name='"+wPali+"'></a></div>";
  1200. output +=
  1201. '<div id="wb' +
  1202. wID +
  1203. "\" class='ctrl sent_gramma_" +
  1204. (sent_gramma_i % 3) +
  1205. "'> <a name='" +
  1206. wPali +
  1207. "'></a>";
  1208. } else if (Note_Mark == 1) {
  1209. output +=
  1210. '<div id="wb' +
  1211. wID +
  1212. "\" class='word org_note sent_gramma_" +
  1213. (sent_gramma_i % 3) +
  1214. "'> <a name='" +
  1215. wPali +
  1216. "'></a>";
  1217. } else {
  1218. if (wReal == "") {
  1219. output +=
  1220. '<div id="wb' + wID + '" class="word_punc un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //符號
  1221. } else {
  1222. if (wType == ".un.") {
  1223. output +=
  1224. '<div id="wb' + wID + '" class="word un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //粘音詞
  1225. } else if (wType == ".comp.") {
  1226. output +=
  1227. '<div id="wb' + wID + '" class="word comp_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //複合詞
  1228. } else {
  1229. output += '<div id="wb' + wID + '" class="word sent_gramma_' + (sent_gramma_i % 3) + '" >'; //普通
  1230. }
  1231. }
  1232. }
  1233. //head div class
  1234. output += " <div id='ws_" + wID + "' class='word_head_shell' >";
  1235. if (wUn.length > 0) {
  1236. output += " <div class='word_head un_pali' id=\"whead_" + wID + '">';
  1237. } else {
  1238. output += " <div class='word_head' id=\"whead_" + wID + '">';
  1239. }
  1240. output += renderWordHeadInner(allWord[iWord]);
  1241. output += " </div>";
  1242. output += " </div>";
  1243. output += ' <div id="detail' + wID + '" class="wbody">';
  1244. output += renderWordBodyInner(allWord[iWord]);
  1245. output += " </div>";
  1246. output += "</div>";
  1247. //渲染单词块结束
  1248. word_length_count += wPali.length;
  1249. if (iWord >= 1) {
  1250. var pre_pali_spell = getNodeText(allWord[iWord - 1], "pali");
  1251. var pre_pali_type = getNodeText(allWord[iWord - 1], "type");
  1252. var pre_pali_Gramma = getNodeText(allWord[iWord - 1], "gramma");
  1253. var pre_pali_Case = getNodeText(allWord[iWord - 1], "case");
  1254. if (pre_pali_type == "" && pre_pali_Case != "") {
  1255. pre_pali_type = pre_pali_Case.split("#")[0];
  1256. }
  1257. if (pre_pali_Case != "" && pre_pali_Case.lastIndexOf("$") != -1) {
  1258. var pre_case_array = pre_pali_Case.split("$");
  1259. pre_pali_Case = pre_case_array[pre_case_array.length - 1];
  1260. }
  1261. }
  1262. if (iWord + 2 <= allWord.length) {
  1263. var next_pali_spell = getNodeText(allWord[iWord + 1], "pali");
  1264. var next_pali_type = getNodeText(allWord[iWord + 1], "type");
  1265. var next_pali_Gramma = getNodeText(allWord[iWord + 1], "gramma");
  1266. var next_pali_Case = getNodeText(allWord[iWord + 1], "case");
  1267. if (next_pali_type == "" && next_pali_Case != "") {
  1268. next_pali_type = next_pali_Case.split("#")[0];
  1269. }
  1270. if (next_pali_Case != "" && next_pali_Case.lastIndexOf("$") != -1) {
  1271. var next_case_array = next_pali_Case.split("$");
  1272. next_pali_Case = next_case_array[next_case_array.length - 1];
  1273. }
  1274. }
  1275. if (next_pali_spell == "(") {
  1276. Note_Mark = 1;
  1277. } else if (pre_pali_spell == ")" && Note_Mark == 1) {
  1278. Note_Mark = 0;
  1279. } else {
  1280. }
  1281. if (wEnter == 1) {
  1282. //句子末尾
  1283. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1284. if (_display_sbs == 1) {
  1285. //逐句显示模式
  1286. output += "</div>"; //逐句逐词译块结束
  1287. //逐句翻译块开始
  1288. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1289. output += "<div class='translate_sent_head'>";
  1290. output += "<div class='translate_sent_head_toolbar' style='display:none;'>";
  1291. output += "<span></span>";
  1292. output +=
  1293. "<span onclick=\"show_tran_net('" +
  1294. book +
  1295. "','" +
  1296. paragraph +
  1297. "','" +
  1298. sent_begin +
  1299. "','" +
  1300. word_id +
  1301. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1302. //
  1303. output += "</div>";
  1304. output += "<div class='translate_sent_head_content'>";
  1305. //句子预览
  1306. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1307. if (_my_channal != null) {
  1308. for (const iterator of _my_channal) {
  1309. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1310. }
  1311. }
  1312. //句子预览结束
  1313. output += "</div>";
  1314. output +=
  1315. "<div class='trans_text_content' pcds='sent-net' book='" +
  1316. book +
  1317. "' para='" +
  1318. paragraph +
  1319. "' begin='" +
  1320. sent_begin +
  1321. "' end=''>";
  1322. output += "</div>";
  1323. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1324. output += "</div>";
  1325. output += "</div>";
  1326. output += "</div>";
  1327. //逐句翻译块内容结束
  1328. output += "<div class='translate_sent_foot'>";
  1329. output += "</div>";
  1330. output += "</div>";
  1331. //逐句翻译块结束
  1332. output += "</div>"; //逐句块结束
  1333. sent_begin = word_id + 1;
  1334. //下一个逐句块开始
  1335. output += "<div class='sent_wbw_trans'>";
  1336. //output += output += render_sent_tool_bar(elementBlock,word_id);
  1337. let nextBegin = word_id + 1;
  1338. let nextEnd = 0;
  1339. for (let j = iWord + 1; j < allWord.length; j++) {
  1340. let aID = getNodeText(allWord[j], "id");
  1341. let aEnter = getNodeText(allWord[j], "enter");
  1342. let arrId = aID.split("-");
  1343. iWordId = parseInt(arrId[2]);
  1344. if (aEnter == 1) {
  1345. nextEnd = iWordId;
  1346. break;
  1347. }
  1348. }
  1349. if (nextEnd == 0) {
  1350. nextEnd = iWordId;
  1351. }
  1352. output += "<div class='sent_wbw_trans_bar'>";
  1353. let sentIdString = book + "-" + paragraph + "-" + nextBegin + "-" + nextEnd;
  1354. let sentIdStringLink = "{{" + sentIdString + "}}";
  1355. output +=
  1356. "<span style='flex: 7;display: flex;'><div style='background-color: silver;'><span style='font-size: large; font-weight: bolder;' title=" +
  1357. gLocal.gui.text_num +
  1358. ">" +
  1359. sentIdString +
  1360. "</span><button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1361. sentIdStringLink +
  1362. "')\" title=" +
  1363. gLocal.gui.copy_to_clipboard +
  1364. ">";
  1365. output +=
  1366. '<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>';
  1367. output += "</button>";
  1368. output +=
  1369. "<button class='icon_btn' onclick=\"window.open('../reader/?view=sent&book=" +
  1370. book +
  1371. "&para=" +
  1372. paragraph +
  1373. "&begin=" +
  1374. nextBegin +
  1375. "&end=" +
  1376. nextEnd +
  1377. "')\" target='_blank' title='" +
  1378. gLocal.gui.scan_in_reader +
  1379. "'>";
  1380. output +=
  1381. '<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>';
  1382. output += "</button>";
  1383. output +=
  1384. "<button class='icon_btn' title='" +
  1385. gLocal.gui.relational_map +
  1386. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1387. book +
  1388. "','" +
  1389. paragraph +
  1390. "','" +
  1391. nextBegin +
  1392. "','" +
  1393. nextEnd +
  1394. "')\">" +
  1395. '<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>' +
  1396. "</button>";
  1397. //拷贝词意到剪贴板
  1398. output +=
  1399. "<button class='icon_btn' title='" +
  1400. "copy meaning" +
  1401. "' class='rel_map' onclick=\"sent_copy_meaning('" +
  1402. book +
  1403. "','" +
  1404. paragraph +
  1405. "','" +
  1406. nextBegin +
  1407. "','" +
  1408. nextEnd +
  1409. "')\">" +
  1410. '<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>' +
  1411. "</button>";
  1412. output += "</div>";
  1413. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1414. output += "</span>";
  1415. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1416. output += "</div>";
  1417. output += "<div class='sent_wbw'>";
  1418. }
  1419. sent_num += 1;
  1420. word_length_count = 0;
  1421. sent_gramma_i = 0;
  1422. arr_Para_ID.push(wID);
  1423. }
  1424. } //循環結束
  1425. output += "</div>";
  1426. //逐句翻译块开始
  1427. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1428. output += "<div class='translate_sent_head'>";
  1429. output += "<div class='translate_sent_head_toolbar'>";
  1430. output += "<span></span>";
  1431. output +=
  1432. "<span onclick=\"show_tran_net('" +
  1433. book +
  1434. "','" +
  1435. paragraph +
  1436. "','" +
  1437. sent_begin +
  1438. "','" +
  1439. word_id +
  1440. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1441. output += "</div>";
  1442. output += "<div class='translate_sent_head_content'>";
  1443. //逐句译文开始
  1444. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1445. if (_my_channal != null) {
  1446. for (const iterator of _my_channal) {
  1447. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1448. }
  1449. }
  1450. output += "</div>";
  1451. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1452. output += "</div>";
  1453. //逐句翻译块内容结束
  1454. output += "<div class='translate_sent_foot'>";
  1455. output += "</div>";
  1456. output += "</div>";
  1457. //逐句翻译块结束
  1458. output += "</div>";
  1459. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1460. arr_Para_ID.push(wID);
  1461. arr_par_sent_num.push(sent_ID);
  1462. g_arr_Para_ID[par_num] = arr_Para_ID;
  1463. return output;
  1464. }
  1465. //根据relation 绘制关系图
  1466. function sent_copy_meaning(book, para, begin, end) {
  1467. let wordId = 0;
  1468. let output = "";
  1469. for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
  1470. output += doc_word("#p" + book + "-" + para + "-" + wordId).val("mean");
  1471. }
  1472. copy_to_clipboard(output);
  1473. }
  1474. //根据relation 绘制关系图
  1475. function sent_show_rel_map(book, para, begin, end) {
  1476. let wordId = 0;
  1477. let memind = "graph LR\n";
  1478. let pali_text = "";
  1479. for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
  1480. let rel = doc_word("#p" + book + "-" + para + "-" + wordId).val("rela");
  1481. let pali = doc_word("#p" + book + "-" + para + "-" + wordId).val("real");
  1482. let type = doc_word("#p" + book + "-" + para + "-" + wordId).val("type");
  1483. if (type != ".ctl.") {
  1484. pali_text += pali + " ";
  1485. }
  1486. let wid = "p" + book + "-" + para + "-" + wordId;
  1487. if (rel != "") {
  1488. let relaData = JSON.parse(rel);
  1489. for (const iterator of relaData) {
  1490. let strRel = iterator.relation;
  1491. let dest = iterator.dest_spell;
  1492. let type = doc_word("#" + iterator.dest_id).val("case");
  1493. if (type.indexOf(".v.") >= 0) {
  1494. dest = iterator.dest_id + "[/" + dest + "/]";
  1495. } else {
  1496. dest = iterator.dest_id + "[" + dest + "]";
  1497. }
  1498. if (strRel.indexOf("SV") >= 0 || strRel.indexOf("-P") >= 0) {
  1499. memind += wid + "(" + pali + ")" + " ==> |" + strRel + "|" + dest + "\n";
  1500. } else if (strRel.indexOf("OV") >= 0 || strRel.indexOf("-S") >= 0) {
  1501. memind += dest + " ==> |" + strRel + "|" + wid + "(" + pali + ")" + "\n";
  1502. } else {
  1503. memind += wid + "(" + pali + ")" + " -- " + strRel + " --> " + dest + "\n";
  1504. }
  1505. }
  1506. }
  1507. }
  1508. let graph = mermaid.render("graphDiv", memind);
  1509. document.querySelector("#term_body_parent").innerHTML = '<div class="win_body_inner" id="term_body"></div>'; //清空之前的记录
  1510. document.querySelector("#term_body").outerHTML =
  1511. "<h3 style='padding: 0 1em;'>" + pali_text + "</h3>" + document.querySelector("#term_body").outerHTML;
  1512. document.querySelector("#term_body").innerHTML = graph;
  1513. document.querySelector("#term_win").style.display = "flex";
  1514. document.querySelector(".win_body").style.display = "block";
  1515. }
  1516. //句子编辑块
  1517. function render_tran_sent_block(book, para, begin, end, channal = 0, readonly = true) {
  1518. let usent_count = _user_sent_buffer.getSentNum(book, para, begin, end);
  1519. let netSent = doc_msg_get_trans(book, para, begin, end);
  1520. let sender = "";
  1521. let sChannalName = "";
  1522. let sent_text = "";
  1523. let sent_lang = "en";
  1524. let objSent;
  1525. let thischannal;
  1526. let shell_class = "";
  1527. if (channal == 0) {
  1528. //百家言
  1529. shell_class += " channel_0";
  1530. if (netSent.length > 0) {
  1531. sender = netSent[netSent.length - 1].sender;
  1532. sent_text += netSent[netSent.length - 1].data.text;
  1533. } else if (usent_count > 0) {
  1534. sender = _user_sent_buffer.getSentText(book, para, begin, end)[0].nickname;
  1535. sChannalName = "channal name";
  1536. sent_text += _user_sent_buffer.getSentText(book, para, begin, end)[0].text;
  1537. }
  1538. } else {
  1539. sender = "通道的名字";
  1540. shell_class += " mychannel";
  1541. objSent = _user_sent_buffer.getSentText(book, para, begin, end, channal);
  1542. thischannal = channal_getById(channal);
  1543. if (objSent == false) {
  1544. objSent = new Object();
  1545. objSent.text = "";
  1546. objSent.language = thischannal.lang;
  1547. objSent.id = "";
  1548. objSent.tag = "[]";
  1549. objSent.author = "{}";
  1550. sent_text = "";
  1551. } else {
  1552. sent_text = objSent.text;
  1553. }
  1554. sent_lang = objSent.language;
  1555. }
  1556. let output = "";
  1557. if (readonly == true) {
  1558. shell_class += " readonly";
  1559. }
  1560. output += "<div class='trans_text_block " + shell_class + "' channel_id='" + channal + "'>";
  1561. output += "<div class='trans_text_info' >";
  1562. if (channal == 0) {
  1563. output += "<span class='author'>" + sender + "</span><span>[滤]</span>";
  1564. } else {
  1565. output += "<span style='width: 100%;display: contents;'>";
  1566. output += "<span>";
  1567. if (thischannal) {
  1568. output += thischannal.name + "-" + thischannal.lang;
  1569. } else {
  1570. output += "未知的频道名";
  1571. }
  1572. output += "</span>";
  1573. output +=
  1574. "<span style='margin-left: auto;' class='send_status' id='send_" +
  1575. book +
  1576. "_" +
  1577. para +
  1578. "_" +
  1579. begin +
  1580. "_" +
  1581. end +
  1582. "_" +
  1583. channal +
  1584. "'></span>";
  1585. }
  1586. output += "</span><span></span>";
  1587. output += "</div>";
  1588. let id = "tran_pre_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1589. output += "<div class='trans_text_content' tid = '" + id;
  1590. if (channal == 0) {
  1591. output += "' pcds='sent-net-all' ";
  1592. } else {
  1593. output += "' pcds='sent-net' ";
  1594. }
  1595. output +=
  1596. " book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' channal='" + channal + "'>";
  1597. if (readonly) {
  1598. output += note_init(term_std_str_to_tran(sent_text, channal, getCookie("userid"), sent_lang));
  1599. } else {
  1600. output += "<span id='" + id + "' ";
  1601. output += "onclick=\"sent_edit_click('";
  1602. output += book + "','" + para + "','" + begin + "','" + end + "','" + channal + "',)\">";
  1603. if (objSent.text == null || objSent.text == "") {
  1604. output += "<span style='color:gray;'>";
  1605. output += "<svg class='icon' style='fill: var(--detail-color);'>";
  1606. output += "<use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
  1607. output += "</span>";
  1608. } else {
  1609. output += note_init(term_std_str_to_tran(objSent.text, channal, getCookie("userid"), sent_lang));
  1610. }
  1611. output += "</span>";
  1612. }
  1613. output += "</div>";
  1614. //句子预览结束
  1615. //编辑框开始
  1616. if (readonly == false) {
  1617. output += "<div style='display:none;'>";
  1618. let id = book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1619. output += "<textarea id='trans_sent_edit_" + id + "' ";
  1620. output += " onkeyup = \"updateTranslationPreview('" + id + "',this)\" ";
  1621. output +=
  1622. " onchange=\"trans_text_save('" +
  1623. book +
  1624. "','" +
  1625. para +
  1626. "','" +
  1627. begin +
  1628. "','" +
  1629. end +
  1630. "','" +
  1631. channal +
  1632. "')\"";
  1633. output += "class='trans_sent_edit' style='background-color: #f8f8fa;color: black;border-color: silver;' ";
  1634. output += "sent_id='" + objSent.id + "' ";
  1635. output += "book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' ";
  1636. output +=
  1637. " channal='" +
  1638. channal +
  1639. "' author='" +
  1640. objSent.author +
  1641. "' lang='" +
  1642. objSent.language +
  1643. "' tag='" +
  1644. objSent.tag +
  1645. "' >";
  1646. output += objSent.text;
  1647. output += "</textarea>";
  1648. output += "<div class='trans_text_info' style='justify-content: flex-end;'>";
  1649. output += "<span></span>";
  1650. output += "<button class='icon_btn' ";
  1651. output +=
  1652. "onclick=\"trans_text_save('" +
  1653. book +
  1654. "','" +
  1655. para +
  1656. "','" +
  1657. begin +
  1658. "','" +
  1659. end +
  1660. "','" +
  1661. channal +
  1662. "')\" ";
  1663. output +=
  1664. "title=" +
  1665. gLocal.gui.draft +
  1666. ">" +
  1667. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#ic_save"></use></svg>';
  1668. output += "</button>";
  1669. output += "<button class='icon_btn' ";
  1670. output +=
  1671. "onclick=\"trans_text_send('" +
  1672. book +
  1673. "','" +
  1674. para +
  1675. "','" +
  1676. begin +
  1677. "','" +
  1678. end +
  1679. "','" +
  1680. channal +
  1681. "')\"";
  1682. output +=
  1683. " title=" +
  1684. gLocal.gui.send +
  1685. " disabled>" +
  1686. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#send_by_paper_plane"></use></svg>';
  1687. output += "</button>";
  1688. output += "</div>";
  1689. output += "</div>";
  1690. }
  1691. if (readonly) {
  1692. output += "<div class='trans_text_info'>" + "<span></span>" + "<span><span class='tools'>";
  1693. output +=
  1694. "<button class='icon_btn' title=" +
  1695. gLocal.gui.accept_copy +
  1696. ">" +
  1697. "<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>" +
  1698. "</button>";
  1699. if (channal == 0) {
  1700. //百家言 显示更多按钮
  1701. output +=
  1702. "<button class='icon_btn' onclick=\"show_tran_net('" +
  1703. book +
  1704. "','" +
  1705. para +
  1706. "','" +
  1707. begin +
  1708. "','" +
  1709. end +
  1710. "')\" title=" +
  1711. gLocal.gui.message +
  1712. ">" +
  1713. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="plugin/system_message/icon.svg#icon_message"></use></svg>' +
  1714. "</button>";
  1715. }
  1716. output += "</span><span>" + usent_count + "</span></span>";
  1717. output += "</div>";
  1718. }
  1719. output += "</div>";
  1720. return output;
  1721. }
  1722. function trans_text_save(book, para, begin, end, channal) {
  1723. let textarea = $("#trans_sent_edit_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal);
  1724. if (textarea) {
  1725. let objsent = new Object();
  1726. objsent.id = textarea.attr("sent_id");
  1727. objsent.book = book;
  1728. objsent.paragraph = para;
  1729. objsent.begin = begin;
  1730. objsent.end = end;
  1731. objsent.channal = channal;
  1732. objsent.author = textarea.attr("author");
  1733. objsent.lang = textarea.attr("lang");
  1734. objsent.text = textarea.val();
  1735. _user_sent_buffer.setSent(objsent);
  1736. }
  1737. }
  1738. function sent_edit_click(book, para, begin, end, channal) {
  1739. $(".trans_sent_edit").parent().hide(200);
  1740. $(
  1741. ".trans_sent_edit[book='" +
  1742. book +
  1743. "'][para='" +
  1744. para +
  1745. "'][begin='" +
  1746. begin +
  1747. "'][end='" +
  1748. end +
  1749. "'][channal='" +
  1750. channal +
  1751. "']"
  1752. )
  1753. .parent()
  1754. .show();
  1755. }
  1756. function magic_sentence_cut() {
  1757. var all_sent_array = document.getElementsByClassName("sent_wbw");
  1758. for (i_magic = 0; i_magic < all_sent_array.length; i_magic++) {
  1759. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1").length != 0) {
  1760. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1")[0].className += " sent_cut";
  1761. }
  1762. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2").length != 0) {
  1763. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2")[0].className += " sent_cut";
  1764. }
  1765. }
  1766. }
  1767. function updataWordHeadById(wordId) {
  1768. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1769. var iIndex = getWordIndex(wordId);
  1770. if (iIndex >= 0) {
  1771. $("#whead_" + wordId).html(renderWordHeadInner(xAllWord[iIndex]));
  1772. }
  1773. }
  1774. function updataWordHeadByIndex(wordIndex) {
  1775. if (wordIndex > 0) {
  1776. let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1777. let wordId = getNodeText(xAllWord[wordIndex], "id");
  1778. let obj = document.getElementById("whead_" + wordId);
  1779. if (obj) {
  1780. obj.innerHTML = renderWordHeadInner(xAllWord[wordIndex]);
  1781. }
  1782. }
  1783. }
  1784. function updateWordBodyById(wordId) {
  1785. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1786. var wordIndex = getWordIndex(wordId);
  1787. var obj = document.getElementById("detail" + wordId);
  1788. if (obj) {
  1789. obj.innerHTML = renderWordBodyInner(xAllWord[wordIndex]);
  1790. }
  1791. }
  1792. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  1793. //返回 无
  1794. function modifyWordDetailByWordIndex(wordIndex) {
  1795. xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1796. wordId = getNodeText(xAllWord[wordIndex], "id");
  1797. try {
  1798. var sDetail = "detail" + wordId;
  1799. var cDetail = document.getElementById(sDetail);
  1800. if (cDetail != null) {
  1801. cDetail.innerHTML = renderWordDetailByElement(xAllWord[wordIndex]);
  1802. }
  1803. } catch (error) {
  1804. debugOutput(error);
  1805. }
  1806. }
  1807. function renderWordHeadInner(element) {
  1808. var output = "";
  1809. var wid = getNodeText(element, "id");
  1810. var wpali = getNodeText(element, "pali");
  1811. var sParent = getNodeText(element, "parent");
  1812. var wId = getNodeText(element, "id");
  1813. var wNote = getNodeText(element, "note");
  1814. wStyle = "v_" + getNodeText(element, "style");
  1815. if (wStyle == "v_bld") {
  1816. if (wpali.indexOf("{") >= 0) {
  1817. wpali = wpali.replace("{", "<span class='v_bld'>");
  1818. wpali = wpali.replace("}", "</span>");
  1819. wStyle = "";
  1820. }
  1821. }
  1822. if (wNote.indexOf("{{") >= 0 && wNote.indexOf("}}") >= 0) {
  1823. wStyle += " note_ref";
  1824. }
  1825. if (wNote.substring(0, 6) == "=term(") {
  1826. wStyle += " term_word_head";
  1827. } else {
  1828. if (sParent.length > 0) {
  1829. if (term_lookup_my(sParent) != false) {
  1830. wStyle += " term_my";
  1831. } else {
  1832. if (term_lookup_all(sParent) != null) {
  1833. wStyle += " term_other";
  1834. }
  1835. }
  1836. }
  1837. }
  1838. var sign_count = 0;
  1839. var letter_count = 0;
  1840. for (i_sign in local_sign_str) {
  1841. if (wpali.lastIndexOf(local_sign_str[i_sign].id) != -1) {
  1842. sign_count += 1;
  1843. } //如果是标点或数字
  1844. else if (wpali.lastIndexOf(local_letter_str[i_sign].id) != -1) {
  1845. letter_count += 1;
  1846. } //如果有字母
  1847. }
  1848. if (sign_count != 0 && letter_count == 0) {
  1849. output += "<a name='w" + wId + "'>";
  1850. } else {
  1851. output += "<a name='w" + wId + "' onclick='on_word_click(\"" + wId + "\")'>";
  1852. }
  1853. if (wpali) output += '<span id="whead1_' + wid + '" class="whead paliword1 ' + wStyle + '">';
  1854. output += wpali;
  1855. output += "</span>";
  1856. output += "</a>";
  1857. if (wNote.length > 0) {
  1858. output += '<span id="wnote_root_' + wid + '"><wnh wid="' + wid + '">[1]</wnh></span>';
  1859. } else {
  1860. output += '<span id="wnote_root_' + wid + '"></span>';
  1861. }
  1862. var newMsg = msg_word_msg_num(wid);
  1863. if (newMsg > 0) {
  1864. output += "<span class='word_msg' onclick=\"word_msg_counter_click('" + wid + "')\">" + newMsg + "</span>";
  1865. }
  1866. output += '<span id="whead2_' + wid + '" class="whead paliword2 ' + wStyle + '">';
  1867. output += "</span>";
  1868. return output;
  1869. }
  1870. function renderWordBodyInner(element) {
  1871. return renderWordDetailByElement(element);
  1872. }
  1873. //新的渲染单词块函数
  1874. function renderWordDetailByElement_edit_a(xmlElement) {
  1875. if (xmlElement == null) {
  1876. return "";
  1877. }
  1878. var wordNode = xmlElement;
  1879. var sPali = getNodeText(wordNode, "pali");
  1880. var sId = getNodeText(wordNode, "id");
  1881. var sReal = getNodeText(wordNode, "real");
  1882. var sMean = getNodeText(wordNode, "mean");
  1883. var sOrg = getNodeText(wordNode, "org");
  1884. var sOm = getNodeText(wordNode, "om");
  1885. var sCase = getNodeText(wordNode, "case");
  1886. var sType = getNodeText(wordNode, "type");
  1887. var sGramma = getNodeText(wordNode, "gramma");
  1888. var sParent = getNodeText(wordNode, "parent");
  1889. var sParentGrammar = getNodeText(wordNode, "pg");
  1890. var sParent2 = getNodeText(wordNode, "parent2");
  1891. var sNote = getNodeText(wordNode, "note");
  1892. var sStatus = getNodeText(wordNode, "status");
  1893. if (sStatus == "") {
  1894. sStatus = 0;
  1895. }
  1896. var wordID = sId;
  1897. if (sCase == "") {
  1898. sCase = sType + "#" + sGramma;
  1899. }
  1900. var _txtOutDetail = "";
  1901. var _bgColor = "";
  1902. var status_bg_color = "status_bg_color_" + sStatus;
  1903. var _caseColor = "";
  1904. //标点符号
  1905. if (sReal.length <= 1) {
  1906. _txtOutDetail += "<div>";
  1907. /*id begin*/
  1908. _txtOutDetail += "<div class='ID'> </div>";
  1909. /*mean begin*/
  1910. _txtOutDetail += "<div class='mean'> </div>";
  1911. /*org begin*/
  1912. _txtOutDetail += "<div class='org'> </div>";
  1913. /*org mean begin*/
  1914. _txtOutDetail += "<div class='om'> </div>";
  1915. /*case begin*/
  1916. _txtOutDetail += "<div class='case'> </div>";
  1917. _txtOutDetail += "</div>";
  1918. return _txtOutDetail;
  1919. }
  1920. var strBookMarkColor = getNodeText(wordNode, "bmc");
  1921. if (strBookMarkColor.length > 2) {
  1922. var icolor = strBookMarkColor.substr(-1);
  1923. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  1924. }
  1925. // Auto Match Begin
  1926. if (sCase == "?" && _bgColor == "") {
  1927. _caseColor = " class='bookmarkcolorx' ";
  1928. }
  1929. if (g_useMode == "read" || g_useMode == "translate") {
  1930. _bgColor = "";
  1931. _caseColor = "";
  1932. if (sOrg == "?") {
  1933. sOrg = " ";
  1934. }
  1935. if (sMean == "?") {
  1936. sMean = " ";
  1937. }
  1938. if (sCase == "?" || sCase == "?#?") {
  1939. sCase = " ";
  1940. }
  1941. }
  1942. //编辑模式开始
  1943. {
  1944. /*gramma*/
  1945. /*find in dict*/
  1946. var arrGramma = new Array();
  1947. var thisWord = sReal;
  1948. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  1949. if (thisWord == g_DictWordList[iDict].Pali) {
  1950. if (
  1951. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  1952. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  1953. ) {
  1954. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  1955. pushNewToList(arrGramma, arrCase);
  1956. }
  1957. }
  1958. }
  1959. if (sCase == "?" || sCase == "?#?") {
  1960. if (arrGramma.length > 0) {
  1961. setNodeText(xmlElement, "case", arrGramma[0]);
  1962. sCase = arrGramma[0];
  1963. } else {
  1964. setNodeText(xmlElement, "case", "?#?");
  1965. sCase = "?#?";
  1966. }
  1967. } else {
  1968. if (sCase.indexOf("#") == -1) {
  1969. sCase = "?#" + sCase;
  1970. setNodeText(xmlElement, "case", "?#" + sCase);
  1971. }
  1972. }
  1973. var currType = sCase.split("#")[0];
  1974. var currGramma = sCase.split("#")[1];
  1975. //end gramma
  1976. if (getNodeText(wordNode, "lock") == "true") {
  1977. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  1978. } else {
  1979. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  1980. }
  1981. //状态颜色
  1982. _txtOutDetail += "<div class='" + status_bg_color + "'>";
  1983. //书签颜色
  1984. _txtOutDetail += "<div " + _bgColor + ">";
  1985. /*id begin*/
  1986. /*
  1987. _txtOutDetail += "<p class='ID'>";
  1988. _txtOutDetail += sId + "&nbsp;";
  1989. _txtOutDetail += "</p>";
  1990. */
  1991. /*id end*/
  1992. /*meaning*/
  1993. //格位公式开始
  1994. //去除格位公式
  1995. var currMeaning = removeFormula(sMean);
  1996. //currMeaning = getLocalFormulaStr(currGramma,currMeaning);
  1997. var orgMeaning = sMean;
  1998. //切割过长意思
  1999. if (sReal.length < 4) {
  2000. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, 24));
  2001. } else {
  2002. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, sReal.length * 6));
  2003. }
  2004. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2005. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2006. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2007. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2008. //格位公式结束
  2009. if (sMean.length == 0) {
  2010. renderMeaning = "<span class='word_space_holder'>meaning</span>";
  2011. }
  2012. //渲染下拉菜单
  2013. _txtOutDetail += "<div class='mean'>";
  2014. _txtOutDetail += '<div class="case_dropdown">';
  2015. _txtOutDetail += "<p class='case_dropbtn' >";
  2016. _txtOutDetail += renderMeaning;
  2017. _txtOutDetail += "</p>";
  2018. _txtOutDetail += "<div id='mean_" + wordID + '\' class="case_dropdown-content">';
  2019. _txtOutDetail += "</div>";
  2020. _txtOutDetail += "</div>";
  2021. //render formula menu
  2022. arrFormula = getFormulaList(currGramma);
  2023. _txtOutDetail += '<div class="case_dropdown">';
  2024. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2025. _txtOutDetail += '<div class="case_dropdown-content">';
  2026. newWord = removeFormula_B(orgMeaning);
  2027. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2028. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2029. for (var i in arrFormula) {
  2030. newWord = removeFormula_B(orgMeaning);
  2031. newWord = arrFormula[i].replace("~", newWord);
  2032. newWord = newWord.replace(/{/g, "[");
  2033. newWord = newWord.replace(/}/g, "]");
  2034. _txtOutDetail +=
  2035. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2036. }
  2037. _txtOutDetail += "</div>";
  2038. _txtOutDetail += "</div>";
  2039. _txtOutDetail += "</div> ";
  2040. /*end of meaning*/
  2041. /*org begin 拆分*/
  2042. _txtOutDetail += "<div class='org' name='w_org'>";
  2043. _txtOutDetail += '<div class="case_dropdown">';
  2044. _txtOutDetail += "<p class='case_dropbtn' >";
  2045. let currOrg;
  2046. if (sOrg.length == 0) {
  2047. currOrg = "<span class='word_space_holder'>parts</span>";
  2048. } else {
  2049. currOrg = sOrg;
  2050. }
  2051. _txtOutDetail += currOrg;
  2052. _txtOutDetail += "</p>";
  2053. _txtOutDetail += '<div class="case_dropdown-content">';
  2054. _txtOutDetail += "<div id='parts_" + sId + "'>Loading</div>";
  2055. _txtOutDetail += "</div>";
  2056. _txtOutDetail += "</div>";
  2057. _txtOutDetail += "</div> ";
  2058. /*end of factors*/
  2059. /*part meaning begin*/
  2060. _txtOutDetail += "<div class='om' name='w_om'>";
  2061. _txtOutDetail += '<div class="case_dropdown">';
  2062. _txtOutDetail += "<p class='case_dropbtn' >";
  2063. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  2064. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  2065. var currDefualtFM = "";
  2066. var listFactorForFactorMean = sOrg.split("+");
  2067. for (iFactor in listFactorForFactorMean) {
  2068. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2069. }
  2070. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  2071. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  2072. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  2073. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  2074. if (currDefualtFM.slice(-1, -2) == "+") {
  2075. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  2076. }
  2077. currOM = "[a]" + currDefualtFM;
  2078. setNodeText(wordNode, "om", currOM);
  2079. } else {
  2080. currOM = sOm;
  2081. }
  2082. if (currOM.length == 0) {
  2083. currOM = "<span class='word_space_holder''>part mean</span>";
  2084. }
  2085. _txtOutDetail += currOM;
  2086. _txtOutDetail += "</p>";
  2087. _txtOutDetail += '<div class="case_dropdown-content">';
  2088. _txtOutDetail += "<div id='partmean_" + sId + "'></div>";
  2089. _txtOutDetail += "</div>";
  2090. _txtOutDetail += "</div>";
  2091. _txtOutDetail += "</div> ";
  2092. /*org meaning end*/
  2093. /*begin gramma*/
  2094. _txtOutDetail += "<div class='case'>";
  2095. _txtOutDetail += '<div class="case_dropdown">';
  2096. _txtOutDetail += "<p class='case_dropbtn' >";
  2097. var sLocalCase = getLocalGrammaStr(sCase);
  2098. var mArrGramma = sCase.split("#");
  2099. if (mArrGramma.length >= 2) {
  2100. mType = mArrGramma[0];
  2101. mGramma = mArrGramma[1];
  2102. mLocalType = sLocalCase.split("#")[0];
  2103. mLocalGramma = sLocalCase.split("#")[1];
  2104. } else {
  2105. mType = "";
  2106. mGramma = mArrGramma[0];
  2107. mLocalType = "";
  2108. mLocalGramma = sLocalCase.split("#")[0];
  2109. }
  2110. if (mType != "") {
  2111. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  2112. }
  2113. _txtOutDetail += cutString(mLocalGramma, 30);
  2114. if (mLocalType.length + mLocalGramma.length == 0) {
  2115. _txtOutDetail += "&nbsp;";
  2116. }
  2117. _txtOutDetail += "</p>";
  2118. _txtOutDetail += '<div class="case_dropdown-content">';
  2119. _txtOutDetail += "<div id='gramma_" + sId + "'></div>";
  2120. _txtOutDetail += "</div>";
  2121. _txtOutDetail += "</div>";
  2122. //连读词按钮
  2123. if (mType == ".un." || mType == ".comp.") {
  2124. nextElement = com_get_nextsibling(xmlElement);
  2125. if (nextElement != null) {
  2126. //下一个元素存在
  2127. if (getNodeText(nextElement, "un") == sId) {
  2128. //若有孩子則显示收起按鈕
  2129. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  2130. _txtOutDetail +=
  2131. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  2132. _txtOutDetail += "</button>";
  2133. var parentElement = document.getElementById("wb" + sId);
  2134. if (parentElement) {
  2135. parentElement.classList.add("un_parent");
  2136. }
  2137. } else {
  2138. //無kid展開按鈕
  2139. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2140. _txtOutDetail +=
  2141. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2142. _txtOutDetail += "</button> ";
  2143. }
  2144. } else {
  2145. //下一个元素不存在
  2146. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2147. _txtOutDetail +=
  2148. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2149. _txtOutDetail += "</button> ";
  2150. }
  2151. }
  2152. //连读词按钮 结束
  2153. //爷爷和父亲的关系 如pp
  2154. /*
  2155. if(wordGranfatherGramma.length>0 && wordGranfatherGramma.length<6){
  2156. _txtOutDetail += "<span class=\"tooltip\">«"+getLocalGrammaStr(wordGranfatherGramma)+"<span class=\"tooltiptext tooltip-bottom\">"+wordGranfather+"</span>"+"</span> ";
  2157. }
  2158. */
  2159. _txtOutDetail += "</div> ";
  2160. /*end of gramma*/
  2161. _txtOutDetail += "</div>";
  2162. _txtOutDetail += "</div>";
  2163. }
  2164. return _txtOutDetail;
  2165. }
  2166. function renderWordDetailByElement(xmlElement) {
  2167. return renderWordDetailByElement_edit_a(xmlElement);
  2168. if (xmlElement == null) {
  2169. return "";
  2170. }
  2171. wordNode = xmlElement;
  2172. var sPali = getNodeText(wordNode, "pali");
  2173. var sId = getNodeText(wordNode, "id");
  2174. var sReal = getNodeText(wordNode, "real");
  2175. var sMean = getNodeText(wordNode, "mean");
  2176. var sOrg = getNodeText(wordNode, "org");
  2177. var sOm = getNodeText(wordNode, "om");
  2178. var sCase = getNodeText(wordNode, "case");
  2179. var sType = getNodeText(wordNode, "type");
  2180. var sGramma = getNodeText(wordNode, "gramma");
  2181. var sParent = getNodeText(wordNode, "parent");
  2182. var sNote = getNodeText(wordNode, "note");
  2183. wordID = sId;
  2184. if (sCase == "") {
  2185. sCase = sType + "#" + sGramma;
  2186. }
  2187. var _txtOutDetail = "";
  2188. var _bgColor = "";
  2189. var _caseColor = "";
  2190. //标点符号
  2191. if (sReal.length <= 1) {
  2192. _txtOutDetail += "<div>";
  2193. /*id begin*/
  2194. _txtOutDetail += "<div class='ID'> </div>";
  2195. /*mean begin*/
  2196. _txtOutDetail += "<div class='mean'> </div>";
  2197. /*org begin*/
  2198. _txtOutDetail += "<div class='org'> </div>";
  2199. /*org mean begin*/
  2200. _txtOutDetail += "<div class='om'> </div>";
  2201. /*case begin*/
  2202. _txtOutDetail += "<div class='case'> </div>";
  2203. _txtOutDetail += "</div>";
  2204. return _txtOutDetail;
  2205. }
  2206. if (sMean == "?") {
  2207. _bgColor = " class='bookmarkcolorx' ";
  2208. }
  2209. strBookMarkColor = getNodeText(wordNode, "bmc");
  2210. if (strBookMarkColor.length > 2) {
  2211. var icolor = strBookMarkColor.substr(-1);
  2212. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2213. }
  2214. // Auto Match Begin
  2215. if (sCase == "?" && _bgColor == "") {
  2216. _caseColor = " class='bookmarkcolorx' ";
  2217. }
  2218. if (g_useMode == "read" || g_useMode == "translate") {
  2219. _bgColor = "";
  2220. _caseColor = "";
  2221. if (sOrg == "?") {
  2222. sOrg = " ";
  2223. }
  2224. if (sMean == "?") {
  2225. sMean = " ";
  2226. }
  2227. if (sCase == "?" || sCase == "?#?") {
  2228. sCase = " ";
  2229. }
  2230. }
  2231. if (g_useMode == "read") {
  2232. _txtOutDetail += "<div " + _bgColor + ">";
  2233. /*id begin*/
  2234. _txtOutDetail += "<p class='ID'>";
  2235. _txtOutDetail += sId + "&nbsp;";
  2236. _txtOutDetail += "</p>";
  2237. /*id end*/
  2238. /*meaning begin*/
  2239. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2240. showMean = showMean.replace(/}/g, "</span>");
  2241. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2242. showMean = showMean.replace(/\]/g, "</span>");
  2243. _txtOutDetail += "<p class='mean'>";
  2244. _txtOutDetail += showMean + "&nbsp;";
  2245. _txtOutDetail += "</p>";
  2246. /*meaning end*/
  2247. /*org begin*/
  2248. _txtOutDetail += "<p class='org'>";
  2249. _txtOutDetail += sOrg + "&nbsp;";
  2250. _txtOutDetail += "</p>";
  2251. /*org end*/
  2252. /*org meaning begin*/
  2253. _txtOutDetail += "<p class='om'>";
  2254. _txtOutDetail += sOm + "&nbsp;";
  2255. _txtOutDetail += "</p>";
  2256. /*org meaning end*/
  2257. /*grmma begin*/
  2258. _txtOutDetail += "<p class='case'>";
  2259. sCase = getLocalGrammaStr(sCase);
  2260. var mGramma = sCase.split("#");
  2261. if (mGramma.length >= 2) {
  2262. mType = sCase.split("#")[0];
  2263. mGramma = sCase.split("#")[1];
  2264. } else {
  2265. mType = "";
  2266. mGramma = sCase.split("#")[0];
  2267. }
  2268. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2269. if (mType != "") {
  2270. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2271. }
  2272. _txtOutDetail += mGramma;
  2273. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2274. /*grmma end*/
  2275. _txtOutDetail += "</div>";
  2276. }
  2277. //编辑模式开始
  2278. if (g_useMode == "edit") {
  2279. if (getNodeText(wordNode, "lock") == "true") {
  2280. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2281. } else {
  2282. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2283. }
  2284. _txtOutDetail += "<div " + _bgColor + ">";
  2285. /*id begin*/
  2286. _txtOutDetail += "<p class='ID'>";
  2287. _txtOutDetail += sId + "&nbsp;";
  2288. _txtOutDetail += "</p>";
  2289. /*id end*/
  2290. /*gramma*/
  2291. /*find in dict*/
  2292. var arrGramma = new Array();
  2293. var thisWord = getNodeText(wordNode, "real");
  2294. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2295. if (thisWord == g_DictWordList[iDict].Pali) {
  2296. if (
  2297. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2298. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2299. ) {
  2300. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2301. pushNewToList(arrGramma, arrCase);
  2302. }
  2303. }
  2304. }
  2305. if (sCase == "?" || sCase == "?#?") {
  2306. if (arrGramma.length > 0) {
  2307. setNodeText(xmlElement, "case", arrGramma[0]);
  2308. sCase = arrGramma[0];
  2309. } else {
  2310. setNodeText(xmlElement, "case", "?#?");
  2311. sCase = "?#?";
  2312. }
  2313. } else {
  2314. if (sCase.indexOf("#") == -1) {
  2315. sCase = "?#" + sCase;
  2316. setNodeText(xmlElement, "case", "?#" + sCase);
  2317. }
  2318. }
  2319. var currType = sCase.split("#")[0];
  2320. var currGramma = sCase.split("#")[1];
  2321. //end gramma
  2322. /*meaning*/
  2323. /*find in dict*/
  2324. var arrMeaning = new Array();
  2325. var currMeaning = "";
  2326. var currGrammaMeaning = "";
  2327. var wordParent = "";
  2328. var wordGramma0 = "";
  2329. //self meaning
  2330. var thisWord = getNodeText(wordNode, "real");
  2331. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2332. if (
  2333. thisWord == g_DictWordList[iDict].Pali &&
  2334. g_DictWordList[iDict].Type != ".root." &&
  2335. g_DictWordList[iDict].Type != ".suf." &&
  2336. g_DictWordList[iDict].Type != ".prf."
  2337. ) {
  2338. if (
  2339. wordParent == "" &&
  2340. g_DictWordList[iDict].Parent.length > 0 &&
  2341. g_DictWordList[iDict].Parent != thisWord
  2342. ) {
  2343. wordParent = g_DictWordList[iDict].Parent;
  2344. wordGramma0 = g_DictWordList[iDict].Gramma;
  2345. }
  2346. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2347. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2348. if (currGrammaMeaning == "") {
  2349. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2350. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2351. }
  2352. }
  2353. }
  2354. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2355. for (var i = 0; i < arrMean.length; i++) {
  2356. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2357. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2358. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2359. arrMeaning.push(
  2360. g_DictWordList[iDict].dictID +
  2361. "$" +
  2362. arrMeaning.length +
  2363. "$$" +
  2364. arrMean[i] +
  2365. "$" +
  2366. g_DictWordList[iDict].Language
  2367. );
  2368. }
  2369. }
  2370. }
  2371. }
  2372. }
  2373. var wordGramma1 = "";
  2374. //find in father
  2375. if (wordParent != "") {
  2376. //add parent infomation
  2377. if (sParent == "" || sParent == " ") {
  2378. setNodeText(wordNode, "parent", wordParent);
  2379. sParent = wordParent;
  2380. }
  2381. thisWord = wordParent;
  2382. wordParent = "";
  2383. wordGramma1 = "";
  2384. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2385. if (
  2386. thisWord == g_DictWordList[iDict].Pali &&
  2387. g_DictWordList[iDict].Type != ".v." &&
  2388. g_DictWordList[iDict].Type != ".n." &&
  2389. g_DictWordList[iDict].Type != ".ti." &&
  2390. g_DictWordList[iDict].Type != ".adj." &&
  2391. g_DictWordList[iDict].Type != ".pron." &&
  2392. g_DictWordList[iDict].Type != ".num."
  2393. ) {
  2394. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2395. if (wordParent == "") {
  2396. wordParent = g_DictWordList[iDict].Parent;
  2397. }
  2398. if (wordGramma1 == "") {
  2399. wordGramma1 = g_DictWordList[iDict].Gramma;
  2400. }
  2401. }
  2402. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2403. for (var i = 0; i < arrMean.length; i++) {
  2404. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2405. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2406. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2407. arrMeaning.push(
  2408. g_DictWordList[iDict].dictID +
  2409. "$" +
  2410. arrMeaning.length +
  2411. "$*$" +
  2412. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2413. "$" +
  2414. g_DictWordList[iDict].Language
  2415. );
  2416. }
  2417. }
  2418. }
  2419. }
  2420. }
  2421. }
  2422. //爷爷跟父亲的关系 比如 pp
  2423. wordGranfatherGramma = wordGramma1;
  2424. wordGranfather = wordParent;
  2425. //grandfather
  2426. var wordGramma2 = "";
  2427. if (wordParent != "") {
  2428. thisWord = wordParent;
  2429. wordParent = "";
  2430. wordGramma2 = "";
  2431. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2432. if (
  2433. thisWord == g_DictWordList[iDict].Pali &&
  2434. g_DictWordList[iDict].Type != ".v." &&
  2435. g_DictWordList[iDict].Type != ".n." &&
  2436. g_DictWordList[iDict].Type != ".ti." &&
  2437. g_DictWordList[iDict].Type != ".adj." &&
  2438. g_DictWordList[iDict].Type != ".pron." &&
  2439. g_DictWordList[iDict].Type != ".num."
  2440. ) {
  2441. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2442. if (wordParent == "") {
  2443. wordParent = g_DictWordList[iDict].Parent;
  2444. }
  2445. if (wordGramma2 == "") {
  2446. wordGramma2 = g_DictWordList[iDict].Gramma;
  2447. }
  2448. }
  2449. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2450. for (var i = 0; i < arrMean.length; i++) {
  2451. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2452. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2453. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2454. arrMeaning.push(
  2455. g_DictWordList[iDict].dictID +
  2456. "$" +
  2457. arrMeaning.length +
  2458. "$**$" +
  2459. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2460. "$" +
  2461. g_DictWordList[iDict].Language
  2462. );
  2463. }
  2464. }
  2465. }
  2466. }
  2467. }
  2468. }
  2469. arrMeaning.sort(sortMeanByDictOrder);
  2470. //arrMeaning.sort(sortMeanByLanguageOrder);
  2471. newMeanList = removeSameWordInArray(arrMeaning);
  2472. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2473. if (sMean == "?") {
  2474. //自动匹配一个意思
  2475. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2476. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2477. currMeaning = currGrammaMeaning;
  2478. } else {
  2479. if (newMeanList.length > 0) {
  2480. currMeaning = newMeanList[0].word;
  2481. } else {
  2482. currMeaning = sMean;
  2483. }
  2484. }
  2485. } else {
  2486. currMeaning = removeFormula(sMean);
  2487. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2488. }
  2489. orgMeaning = removeFormula(currMeaning);
  2490. if (sReal.length < 4) {
  2491. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2492. } else {
  2493. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2494. }
  2495. setNodeText(wordNode, "mean", currMeaning);
  2496. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2497. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2498. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2499. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2500. //渲染下拉菜单
  2501. _txtOutDetail += "<div class='mean'>";
  2502. _txtOutDetail += render_word_mean_menu(wordNode);
  2503. //render formula menu
  2504. arrFormula = getFormulaList(currGramma);
  2505. _txtOutDetail += '<div class="case_dropdown">';
  2506. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2507. _txtOutDetail += '<div class="case_dropdown-content">';
  2508. newWord = removeFormula_B(orgMeaning);
  2509. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2510. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2511. for (var i in arrFormula) {
  2512. newWord = removeFormula_B(orgMeaning);
  2513. newWord = arrFormula[i].replace("~", newWord);
  2514. newWord = newWord.replace(/{/g, "[");
  2515. newWord = newWord.replace(/}/g, "]");
  2516. _txtOutDetail +=
  2517. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2518. }
  2519. _txtOutDetail += "</div>";
  2520. _txtOutDetail += "</div>";
  2521. _txtOutDetail += "</div> ";
  2522. /*end of meaning*/
  2523. /*org begin 拆分*/
  2524. /*
  2525. =======
  2526. return renderWordDetailByElement_edit_a(xmlElement);
  2527. if (xmlElement == null) {
  2528. return "";
  2529. }
  2530. wordNode = xmlElement;
  2531. var sPali = getNodeText(wordNode, "pali");
  2532. var sId = getNodeText(wordNode, "id");
  2533. var sReal = getNodeText(wordNode, "real");
  2534. var sMean = getNodeText(wordNode, "mean");
  2535. var sOrg = getNodeText(wordNode, "org");
  2536. var sOm = getNodeText(wordNode, "om");
  2537. var sCase = getNodeText(wordNode, "case");
  2538. var sType = getNodeText(wordNode, "type");
  2539. var sGramma = getNodeText(wordNode, "gramma");
  2540. var sParent = getNodeText(wordNode, "parent");
  2541. var sNote = getNodeText(wordNode, "note");
  2542. wordID = sId;
  2543. if (sCase == "") {
  2544. sCase = sType + "#" + sGramma;
  2545. }
  2546. var _txtOutDetail = "";
  2547. var _bgColor = "";
  2548. var _caseColor = "";
  2549. //标点符号
  2550. if (sReal.length <= 1) {
  2551. _txtOutDetail += "<div>";
  2552. /*id begin*/
  2553. _txtOutDetail += "<div class='ID'> </div>";
  2554. /*mean begin*/
  2555. _txtOutDetail += "<div class='mean'> </div>";
  2556. /*org begin*/
  2557. _txtOutDetail += "<div class='org'> </div>";
  2558. /*org mean begin*/
  2559. _txtOutDetail += "<div class='om'> </div>";
  2560. /*case begin*/
  2561. _txtOutDetail += "<div class='case'> </div>";
  2562. _txtOutDetail += "</div>";
  2563. return _txtOutDetail;
  2564. }
  2565. if (sMean == "?") {
  2566. _bgColor = " class='bookmarkcolorx' ";
  2567. }
  2568. strBookMarkColor = getNodeText(wordNode, "bmc");
  2569. if (strBookMarkColor.length > 2) {
  2570. var icolor = strBookMarkColor.substr(-1);
  2571. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2572. }
  2573. // Auto Match Begin
  2574. if (sCase == "?" && _bgColor == "") {
  2575. _caseColor = " class='bookmarkcolorx' ";
  2576. }
  2577. if (g_useMode == "read" || g_useMode == "translate") {
  2578. _bgColor = "";
  2579. _caseColor = "";
  2580. if (sOrg == "?") {
  2581. sOrg = " ";
  2582. }
  2583. if (sMean == "?") {
  2584. sMean = " ";
  2585. }
  2586. if (sCase == "?" || sCase == "?#?") {
  2587. sCase = " ";
  2588. }
  2589. }
  2590. if (g_useMode == "read") {
  2591. _txtOutDetail += "<div " + _bgColor + ">";
  2592. /*id begin*/
  2593. _txtOutDetail += "<p class='ID'>";
  2594. _txtOutDetail += sId + "&nbsp;";
  2595. _txtOutDetail += "</p>";
  2596. /*id end*/
  2597. /*meaning begin*/
  2598. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2599. showMean = showMean.replace(/}/g, "</span>");
  2600. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2601. showMean = showMean.replace(/\]/g, "</span>");
  2602. _txtOutDetail += "<p class='mean'>";
  2603. _txtOutDetail += showMean + "&nbsp;";
  2604. _txtOutDetail += "</p>";
  2605. /*meaning end*/
  2606. /*org begin*/
  2607. _txtOutDetail += "<p class='org'>";
  2608. _txtOutDetail += sOrg + "&nbsp;";
  2609. _txtOutDetail += "</p>";
  2610. /*org end*/
  2611. /*org meaning begin*/
  2612. _txtOutDetail += "<p class='om'>";
  2613. _txtOutDetail += sOm + "&nbsp;";
  2614. _txtOutDetail += "</p>";
  2615. /*org meaning end*/
  2616. /*grmma begin*/
  2617. _txtOutDetail += "<p class='case'>";
  2618. sCase = getLocalGrammaStr(sCase);
  2619. var mGramma = sCase.split("#");
  2620. if (mGramma.length >= 2) {
  2621. mType = sCase.split("#")[0];
  2622. mGramma = sCase.split("#")[1];
  2623. } else {
  2624. mType = "";
  2625. mGramma = sCase.split("#")[0];
  2626. }
  2627. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2628. if (mType != "") {
  2629. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2630. }
  2631. _txtOutDetail += mGramma;
  2632. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2633. /*grmma end*/
  2634. _txtOutDetail += "</div>";
  2635. }
  2636. //编辑模式开始
  2637. if (g_useMode == "edit") {
  2638. if (getNodeText(wordNode, "lock") == "true") {
  2639. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2640. } else {
  2641. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2642. }
  2643. _txtOutDetail += "<div " + _bgColor + ">";
  2644. /*id begin*/
  2645. _txtOutDetail += "<p class='ID'>";
  2646. _txtOutDetail += sId + "&nbsp;";
  2647. _txtOutDetail += "</p>";
  2648. /*id end*/
  2649. /*gramma*/
  2650. /*find in dict*/
  2651. var arrGramma = new Array();
  2652. var thisWord = getNodeText(wordNode, "real");
  2653. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2654. if (thisWord == g_DictWordList[iDict].Pali) {
  2655. if (
  2656. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2657. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2658. ) {
  2659. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2660. pushNewToList(arrGramma, arrCase);
  2661. }
  2662. }
  2663. }
  2664. if (sCase == "?" || sCase == "?#?") {
  2665. if (arrGramma.length > 0) {
  2666. setNodeText(xmlElement, "case", arrGramma[0]);
  2667. sCase = arrGramma[0];
  2668. } else {
  2669. setNodeText(xmlElement, "case", "?#?");
  2670. sCase = "?#?";
  2671. }
  2672. } else {
  2673. if (sCase.indexOf("#") == -1) {
  2674. sCase = "?#" + sCase;
  2675. setNodeText(xmlElement, "case", "?#" + sCase);
  2676. }
  2677. }
  2678. var currType = sCase.split("#")[0];
  2679. var currGramma = sCase.split("#")[1];
  2680. //end gramma
  2681. /*meaning*/
  2682. /*find in dict*/
  2683. var arrMeaning = new Array();
  2684. var currMeaning = "";
  2685. var currGrammaMeaning = "";
  2686. var wordParent = "";
  2687. var wordGramma0 = "";
  2688. //self meaning
  2689. var thisWord = getNodeText(wordNode, "real");
  2690. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2691. if (
  2692. thisWord == g_DictWordList[iDict].Pali &&
  2693. g_DictWordList[iDict].Type != ".root." &&
  2694. g_DictWordList[iDict].Type != ".suf." &&
  2695. g_DictWordList[iDict].Type != ".prf."
  2696. ) {
  2697. if (
  2698. wordParent == "" &&
  2699. g_DictWordList[iDict].Parent.length > 0 &&
  2700. g_DictWordList[iDict].Parent != thisWord
  2701. ) {
  2702. wordParent = g_DictWordList[iDict].Parent;
  2703. wordGramma0 = g_DictWordList[iDict].Gramma;
  2704. }
  2705. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2706. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2707. if (currGrammaMeaning == "") {
  2708. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2709. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2710. }
  2711. }
  2712. }
  2713. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2714. for (var i = 0; i < arrMean.length; i++) {
  2715. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2716. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2717. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2718. arrMeaning.push(
  2719. g_DictWordList[iDict].dictID +
  2720. "$" +
  2721. arrMeaning.length +
  2722. "$$" +
  2723. arrMean[i] +
  2724. "$" +
  2725. g_DictWordList[iDict].Language
  2726. );
  2727. }
  2728. }
  2729. }
  2730. }
  2731. }
  2732. var wordGramma1 = "";
  2733. //find in father
  2734. if (wordParent != "") {
  2735. //add parent infomation
  2736. if (sParent == "" || sParent == " ") {
  2737. setNodeText(wordNode, "parent", wordParent);
  2738. sParent = wordParent;
  2739. }
  2740. thisWord = wordParent;
  2741. wordParent = "";
  2742. wordGramma1 = "";
  2743. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2744. if (
  2745. thisWord == g_DictWordList[iDict].Pali &&
  2746. g_DictWordList[iDict].Type != ".v." &&
  2747. g_DictWordList[iDict].Type != ".n." &&
  2748. g_DictWordList[iDict].Type != ".ti." &&
  2749. g_DictWordList[iDict].Type != ".adj." &&
  2750. g_DictWordList[iDict].Type != ".pron." &&
  2751. g_DictWordList[iDict].Type != ".num."
  2752. ) {
  2753. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2754. if (wordParent == "") {
  2755. wordParent = g_DictWordList[iDict].Parent;
  2756. }
  2757. if (wordGramma1 == "") {
  2758. wordGramma1 = g_DictWordList[iDict].Gramma;
  2759. }
  2760. }
  2761. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2762. for (var i = 0; i < arrMean.length; i++) {
  2763. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2764. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2765. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2766. arrMeaning.push(
  2767. g_DictWordList[iDict].dictID +
  2768. "$" +
  2769. arrMeaning.length +
  2770. "$*$" +
  2771. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2772. "$" +
  2773. g_DictWordList[iDict].Language
  2774. );
  2775. }
  2776. }
  2777. }
  2778. }
  2779. }
  2780. }
  2781. //爷爷跟父亲的关系 比如 pp
  2782. wordGranfatherGramma = wordGramma1;
  2783. wordGranfather = wordParent;
  2784. //grandfather
  2785. var wordGramma2 = "";
  2786. if (wordParent != "") {
  2787. thisWord = wordParent;
  2788. wordParent = "";
  2789. wordGramma2 = "";
  2790. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2791. if (
  2792. thisWord == g_DictWordList[iDict].Pali &&
  2793. g_DictWordList[iDict].Type != ".v." &&
  2794. g_DictWordList[iDict].Type != ".n." &&
  2795. g_DictWordList[iDict].Type != ".ti." &&
  2796. g_DictWordList[iDict].Type != ".adj." &&
  2797. g_DictWordList[iDict].Type != ".pron." &&
  2798. g_DictWordList[iDict].Type != ".num."
  2799. ) {
  2800. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2801. if (wordParent == "") {
  2802. wordParent = g_DictWordList[iDict].Parent;
  2803. }
  2804. if (wordGramma2 == "") {
  2805. wordGramma2 = g_DictWordList[iDict].Gramma;
  2806. }
  2807. }
  2808. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2809. for (var i = 0; i < arrMean.length; i++) {
  2810. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2811. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2812. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2813. arrMeaning.push(
  2814. g_DictWordList[iDict].dictID +
  2815. "$" +
  2816. arrMeaning.length +
  2817. "$**$" +
  2818. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2819. "$" +
  2820. g_DictWordList[iDict].Language
  2821. );
  2822. }
  2823. }
  2824. }
  2825. }
  2826. }
  2827. }
  2828. arrMeaning.sort(sortMeanByDictOrder);
  2829. //arrMeaning.sort(sortMeanByLanguageOrder);
  2830. newMeanList = removeSameWordInArray(arrMeaning);
  2831. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2832. if (sMean == "?") {
  2833. //自动匹配一个意思
  2834. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2835. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2836. currMeaning = currGrammaMeaning;
  2837. } else {
  2838. if (newMeanList.length > 0) {
  2839. currMeaning = newMeanList[0].word;
  2840. } else {
  2841. currMeaning = sMean;
  2842. }
  2843. }
  2844. } else {
  2845. currMeaning = removeFormula(sMean);
  2846. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2847. }
  2848. orgMeaning = removeFormula(currMeaning);
  2849. if (sReal.length < 4) {
  2850. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2851. } else {
  2852. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2853. }
  2854. setNodeText(wordNode, "mean", currMeaning);
  2855. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2856. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2857. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2858. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2859. //渲染下拉菜单
  2860. _txtOutDetail += "<div class='mean'>";
  2861. _txtOutDetail += render_word_mean_menu(wordNode);
  2862. //render formula menu
  2863. arrFormula = getFormulaList(currGramma);
  2864. _txtOutDetail += '<div class="case_dropdown">';
  2865. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2866. _txtOutDetail += '<div class="case_dropdown-content">';
  2867. newWord = removeFormula_B(orgMeaning);
  2868. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2869. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2870. for (var i in arrFormula) {
  2871. newWord = removeFormula_B(orgMeaning);
  2872. newWord = arrFormula[i].replace("~", newWord);
  2873. newWord = newWord.replace(/{/g, "[");
  2874. newWord = newWord.replace(/}/g, "]");
  2875. _txtOutDetail +=
  2876. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2877. }
  2878. _txtOutDetail += "</div>";
  2879. _txtOutDetail += "</div>";
  2880. _txtOutDetail += "</div> ";
  2881. /*end of meaning*/
  2882. /*org begin 拆分*/
  2883. /*
  2884. >>>>>>> bc16896ae743d21de32c24d5ffe63b6be00a315c
  2885. _txtOutDetail += "<p class='org' name='w_org'>";
  2886. _txtOutDetail += sOrg + "&nbsp;";
  2887. _txtOutDetail += "</p> ";
  2888. */
  2889. /*find in dict*/
  2890. var currOrg = "";
  2891. var wordParent = "";
  2892. var arrOrg = new Array();
  2893. var thisWord = getNodeText(wordNode, "real");
  2894. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2895. if (thisWord == g_DictWordList[iDict].Pali) {
  2896. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2897. wordParent = g_DictWordList[iDict].Parent;
  2898. }
  2899. var currOrg = g_DictWordList[iDict].Factors;
  2900. if (currOrg.length > 0 && currOrg != "?") {
  2901. pushNewToList(arrOrg, currOrg);
  2902. //arrOrg.push(currOrg);
  2903. }
  2904. }
  2905. }
  2906. //father
  2907. if (wordParent != "") {
  2908. thisWord = wordParent;
  2909. wordParent = "";
  2910. wordGramma1 = "";
  2911. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2912. if (thisWord == g_DictWordList[iDict].Pali) {
  2913. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2914. if (wordParent == "") {
  2915. wordParent = g_DictWordList[iDict].Parent;
  2916. }
  2917. }
  2918. var currOrg = g_DictWordList[iDict].Factors;
  2919. if (currOrg.length > 0 && currOrg != "?") {
  2920. pushNewToList(arrOrg, currOrg);
  2921. //arrOrg.push(currOrg);
  2922. }
  2923. }
  2924. }
  2925. }
  2926. //grandfather
  2927. if (wordParent != "") {
  2928. thisWord = wordParent;
  2929. wordParent = "";
  2930. wordGramma2 = "";
  2931. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2932. if (thisWord == g_DictWordList[iDict].Pali) {
  2933. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2934. if (wordParent == "") {
  2935. wordParent = g_DictWordList[iDict].Parent;
  2936. }
  2937. }
  2938. var currOrg = g_DictWordList[iDict].Factors;
  2939. if (currOrg.length > 0 && currOrg != "?") {
  2940. pushNewToList(arrOrg, currOrg);
  2941. //arrOrg.push(currOrg);
  2942. }
  2943. }
  2944. }
  2945. }
  2946. _txtOutDetail += "<div class='org' name='w_org'>";
  2947. _txtOutDetail += '<div class="case_dropdown">';
  2948. _txtOutDetail += "<p class='case_dropbtn' >";
  2949. if (sOrg == "?") {
  2950. if (arrOrg.length > 0) {
  2951. currOrg = arrOrg[0];
  2952. } else {
  2953. currOrg = sOrg;
  2954. }
  2955. setNodeText(wordNode, "org", currOrg);
  2956. } else {
  2957. currOrg = sOrg;
  2958. }
  2959. _txtOutDetail += currOrg;
  2960. if (arrOrg.length > 0) {
  2961. _txtOutDetail += "<svg class='edit_icon'>";
  2962. _txtOutDetail += "<use xlink:href='svg/icon.svg#ic_down'></use>";
  2963. _txtOutDetail += "</svg>";
  2964. }
  2965. _txtOutDetail += "</p>";
  2966. _txtOutDetail += '<div class="case_dropdown-content">';
  2967. _txtOutDetail +=
  2968. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  2969. wordID +
  2970. '","org","")\'>' +
  2971. gLocal.gui.empty1 +
  2972. "</button>";
  2973. _txtOutDetail +=
  2974. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" +
  2975. wordID +
  2976. "\")'>" +
  2977. gLocal.gui.wordmap +
  2978. "</button>";
  2979. //新加 base 信息 vn
  2980. _txtOutDetail += '<div class="case_dropdown-org">';
  2981. _txtOutDetail += '<div class="case_dropdown-first">';
  2982. _txtOutDetail += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
  2983. _txtOutDetail += sParent + "</a>";
  2984. _txtOutDetail += "<span style='z-index:220' class='case_dropdown-title'>";
  2985. _txtOutDetail += gLocal.gui.more + "»</span>";
  2986. _txtOutDetail += "</div>";
  2987. for (i in arrOrg) {
  2988. _txtOutDetail +=
  2989. "<a onclick='fieldListChanged(\"" + wordID + '","org","' + arrOrg[i] + "\")'>" + arrOrg[i] + "</a>";
  2990. }
  2991. _txtOutDetail += "</div>";
  2992. _txtOutDetail += "</div>";
  2993. _txtOutDetail += "</div>";
  2994. _txtOutDetail += "</div> ";
  2995. /*end of factors*/
  2996. /*part meaning begin*/
  2997. listFactorForFactorMean = currOrg.split("+");
  2998. currDefualtFM = "";
  2999. for (iFactor in listFactorForFactorMean) {
  3000. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  3001. }
  3002. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  3003. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  3004. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  3005. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  3006. if (currDefualtFM.slice(-1, -2) == "+") {
  3007. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  3008. }
  3009. /*find in dict*/
  3010. var currOM = "";
  3011. var wordParent = "";
  3012. var arrOM = new Array();
  3013. var thisWord = getNodeText(wordNode, "real");
  3014. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3015. if (thisWord == g_DictWordList[iDict].Pali) {
  3016. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3017. wordParent = g_DictWordList[iDict].Parent;
  3018. }
  3019. var currOM = g_DictWordList[iDict].FactorMean;
  3020. if (currOM.length > 0 && currOM != "?") {
  3021. pushNewToList(arrOM, currOM);
  3022. //arrOM.push(currOM);
  3023. }
  3024. }
  3025. }
  3026. /*
  3027. //father
  3028. if(wordParent!=""){
  3029. thisWord=wordParent;
  3030. wordParent="";
  3031. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3032. if(thisWord==g_DictWordList[iDict].Pali){
  3033. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3034. if(wordParent==""){
  3035. wordParent=g_DictWordList[iDict].Parent;
  3036. }
  3037. }
  3038. var currOM=g_DictWordList[iDict].FactorMean;
  3039. if(currOM.length>0 && currOM!="?"){
  3040. pushNewToList(arrOM,currOM);
  3041. }
  3042. }
  3043. }
  3044. }
  3045. //grandfather
  3046. if(wordParent!=""){
  3047. thisWord=wordParent;
  3048. wordParent="";
  3049. wordGramma2="";
  3050. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3051. if(thisWord==g_DictWordList[iDict].Pali){
  3052. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3053. if(wordParent==""){
  3054. wordParent=g_DictWordList[iDict].Parent;
  3055. }
  3056. }
  3057. var currOM=g_DictWordList[iDict].FactorMean;
  3058. if(currOM.length>0 && currOM!="?"){
  3059. pushNewToList(arrOM,currOM);
  3060. }
  3061. }
  3062. }
  3063. }
  3064. */
  3065. _txtOutDetail += "<div class='om' name='w_om'>";
  3066. _txtOutDetail += '<div class="case_dropdown">';
  3067. _txtOutDetail += "<p class='case_dropbtn' >";
  3068. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  3069. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  3070. if (arrOM.length > 0) {
  3071. currOM = arrOM[0];
  3072. } else {
  3073. currOM = "[a]" + currDefualtFM;
  3074. }
  3075. setNodeText(wordNode, "om", currOM);
  3076. } else {
  3077. currOM = sOm;
  3078. }
  3079. _txtOutDetail += currOM;
  3080. if (arrOM.length > 0) {
  3081. _txtOutDetail += " ▾";
  3082. }
  3083. _txtOutDetail += "</p>";
  3084. _txtOutDetail += '<div class="case_dropdown-content">';
  3085. _txtOutDetail +=
  3086. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3087. wordID +
  3088. '","om","")\'>' +
  3089. gLocal.gui.empty1 +
  3090. "</button>";
  3091. _txtOutDetail +=
  3092. "<a onclick='fieldListChanged(\"" +
  3093. wordID +
  3094. '","om","[a]' +
  3095. currDefualtFM +
  3096. "\")'>[" +
  3097. gLocal.gui.auto +
  3098. "]" +
  3099. currDefualtFM +
  3100. "</a>";
  3101. for (i in arrOM) {
  3102. _txtOutDetail +=
  3103. "<a onclick='fieldListChanged(\"" + wordID + '","om","' + arrOM[i] + "\")'>" + arrOM[i] + "</a>";
  3104. }
  3105. _txtOutDetail += "</div>";
  3106. _txtOutDetail += "</div>";
  3107. _txtOutDetail += "</div> ";
  3108. /*org meaning end*/
  3109. /*begin gramma*/
  3110. _txtOutDetail += "<div class='case'>";
  3111. _txtOutDetail += '<div class="case_dropdown">';
  3112. _txtOutDetail += "<p class='case_dropbtn' >";
  3113. sLocalCase = getLocalGrammaStr(sCase);
  3114. var mArrGramma = sCase.split("#");
  3115. if (mArrGramma.length >= 2) {
  3116. mType = mArrGramma[0];
  3117. mGramma = mArrGramma[1];
  3118. mLocalType = sLocalCase.split("#")[0];
  3119. mLocalGramma = sLocalCase.split("#")[1];
  3120. } else {
  3121. mType = "";
  3122. mGramma = mArrGramma[0];
  3123. mLocalType = "";
  3124. mLocalGramma = sLocalCase.split("#")[0];
  3125. }
  3126. if (mType != "") {
  3127. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  3128. }
  3129. _txtOutDetail += cutString(mLocalGramma, 30);
  3130. _txtOutDetail += "</p>";
  3131. _txtOutDetail += '<div class="case_dropdown-content">';
  3132. for (i in arrGramma) {
  3133. _txtOutDetail +=
  3134. "<a onclick='fieldListChanged(\"" +
  3135. wordID +
  3136. '","case","' +
  3137. arrGramma[i] +
  3138. "\")'>" +
  3139. cutString(getLocalGrammaStr(arrGramma[i]), 30) +
  3140. "</a>";
  3141. }
  3142. _txtOutDetail += "</div>";
  3143. _txtOutDetail += "</div>";
  3144. //连读词按钮
  3145. if (mType == ".un." || mType == ".comp.") {
  3146. nextElement = com_get_nextsibling(xmlElement);
  3147. if (nextElement != null) {
  3148. //下一个元素存在
  3149. if (getNodeText(nextElement, "un") == sId) {
  3150. //若有孩子則显示收起按鈕
  3151. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  3152. _txtOutDetail +=
  3153. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  3154. _txtOutDetail += "</button>";
  3155. var parentElement = document.getElementById("wb" + sId);
  3156. if (parentElement) {
  3157. parentElement.classList.add("un_parent");
  3158. }
  3159. } else {
  3160. //無kid展開按鈕
  3161. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3162. _txtOutDetail +=
  3163. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3164. _txtOutDetail += "</button> ";
  3165. }
  3166. } else {
  3167. //下一个元素不存在
  3168. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3169. _txtOutDetail +=
  3170. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3171. _txtOutDetail += "</button> ";
  3172. }
  3173. }
  3174. //连读词按钮 结束
  3175. //爷爷和父亲的关系 如pp
  3176. if (wordGranfatherGramma.length > 0 && wordGranfatherGramma.length < 6) {
  3177. _txtOutDetail +=
  3178. '<span class="tooltip">«' +
  3179. getLocalGrammaStr(wordGranfatherGramma) +
  3180. '<span class="tooltiptext tooltip-bottom">' +
  3181. wordGranfather +
  3182. "</span>" +
  3183. "</span> ";
  3184. }
  3185. _txtOutDetail += "</div> ";
  3186. /*end of gramma*/
  3187. //Auto Match Finished
  3188. _txtOutDetail += "</div>";
  3189. }
  3190. return _txtOutDetail;
  3191. }
  3192. function renderWordNoteDivByParaNo(book, paragraph) {}
  3193. /*
  3194. paragraph word note
  3195. */
  3196. function renderWordNoteDivByElement(elementBlock) {
  3197. let output = "";
  3198. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3199. let book = getNodeText(xmlParInfo, "book");
  3200. let paragraph = getNodeText(xmlParInfo, "paragraph");
  3201. let bId = getNodeText(xmlParInfo, "id");
  3202. let type = getNodeText(xmlParInfo, "type");
  3203. let allWord = elementBlock.getElementsByTagName("word");
  3204. let iNoteCounter = 0;
  3205. for (iWord = 0; iWord < allWord.length; iWord++) {
  3206. let oneNote = "";
  3207. let pali = getNodeText(allWord[iWord], "pali");
  3208. let sNote = getNodeText(allWord[iWord], "note");
  3209. if (sNote != "") {
  3210. oneNote += note_init(sNote);
  3211. }
  3212. let sRela = getNodeText(allWord[iWord], "rela");
  3213. if (sRela != "") {
  3214. oneNote += "<div>" + renderWordRelation(allWord[iWord]) + "</div>";
  3215. }
  3216. id = getNodeText(allWord[iWord], "id");
  3217. if (oneNote == "") {
  3218. //有内容
  3219. $("#wnote_root_" + id).html("");
  3220. } else {
  3221. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3222. output += "<div>";
  3223. output += "<wnc wid='" + id + "'></wnc>";
  3224. output += "<strong>" + pali + ":</strong>";
  3225. output += oneNote;
  3226. output += "</div>";
  3227. }
  3228. }
  3229. return output;
  3230. }
  3231. function refreshWordNoteDiv(elementBlock) {
  3232. let html = renderWordNoteDivByElement(elementBlock);
  3233. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3234. let book = getNodeText(xmlParInfo, "book");
  3235. let paragraph = parseInt(getNodeText(xmlParInfo, "paragraph"));
  3236. let noteid = "wnote_" + book + "_" + (paragraph - 1);
  3237. try {
  3238. if (html == "") {
  3239. $("#" + noteid).hide();
  3240. } else {
  3241. $("#" + noteid).html(html);
  3242. $("#" + noteid).show();
  3243. }
  3244. } catch (e) {
  3245. console.error(e.message + noteid);
  3246. }
  3247. }
  3248. function refreshWordNote(elementBlock) {
  3249. var output = "";
  3250. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3251. book = getNodeText(xmlParInfo, "book");
  3252. paragraph = getNodeText(xmlParInfo, "paragraph");
  3253. bId = getNodeText(xmlParInfo, "id");
  3254. type = getNodeText(xmlParInfo, "type");
  3255. var allWord = elementBlock.getElementsByTagName("word");
  3256. var iNoteCounter = 0;
  3257. for (iWord = 0; iWord < allWord.length; iWord++) {
  3258. pali = getNodeText(allWord[iWord], "pali");
  3259. wnote = note_init(getNodeText(allWord[iWord], "note"));
  3260. id = getNodeText(allWord[iWord], "id");
  3261. var note = wnote;
  3262. if (note.length > 0 && note != "?") {
  3263. iNoteCounter++;
  3264. if (wnote.substring(0, 6) == "=term(") {
  3265. var termId = wnote.slice(6, -1);
  3266. //alert(arrTerm.length);
  3267. if (arrTerm[note]) {
  3268. note = "<term guid='" + termId + "' pos='wbw'>" + arrTerm[termId].note + "</term>";
  3269. } else {
  3270. note = "<term guid='" + termId + "' pos='wbw'></term>";
  3271. }
  3272. }
  3273. output += '<p><a href="#word_note_root_' + id + '" name="word_note_' + id + '">[' + iNoteCounter + "]</a>";
  3274. if (note.match("{") && note.match("}")) {
  3275. note = note.replace("{", "<strong>");
  3276. note = note.replace("}", "</strong>");
  3277. if (note.length > 100) {
  3278. shortNote = note.substring(0, 99);
  3279. otherNode = note.substring(100);
  3280. output +=
  3281. shortNote +
  3282. '<span class="full_note_handle">...<span class="full_note">' +
  3283. otherNode +
  3284. "</span></span>";
  3285. } else {
  3286. output += note;
  3287. }
  3288. } else {
  3289. if (note.length > 100) {
  3290. shortNote = note.substring(0, 99);
  3291. otherNode = note.substring(100);
  3292. output +=
  3293. shortNote +
  3294. '<span class="full_note_handle">...<span class="full_note">' +
  3295. otherNode +
  3296. "</span></span>";
  3297. } else {
  3298. output += "<strong>" + pali + ":</strong>" + note;
  3299. }
  3300. }
  3301. output += "</p>";
  3302. if (termId) {
  3303. document.getElementById("wnote_root_" + id).innerHTML =
  3304. "<a onclick=\"term_show_win('" +
  3305. termId +
  3306. '\')" name="word_note_root_' +
  3307. id +
  3308. '">[' +
  3309. iNoteCounter +
  3310. "]</a>";
  3311. } else {
  3312. document.getElementById("wnote_root_" + id).innerHTML =
  3313. '<a href="#word_note_' + id + '" name="word_note_root_' + id + '">[' + iNoteCounter + "]</a>";
  3314. }
  3315. } else {
  3316. noteRootObj = document.getElementById("wnote_root_" + id);
  3317. if (noteRootObj) {
  3318. document.getElementById("wnote_root_" + id).innerHTML = "";
  3319. }
  3320. }
  3321. }
  3322. if (output == "") {
  3323. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
  3324. } else {
  3325. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
  3326. }
  3327. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = output;
  3328. }
  3329. function updateWordNote(element) {
  3330. let paliword = getNodeText(element, "real");
  3331. let wnote = getNodeText(element, "note");
  3332. wnote = note_init(wnote);
  3333. let id = getNodeText(element, "id");
  3334. if (wnote == "") {
  3335. $("#wnote_root_" + id).html("");
  3336. $("#wnn_" + id).html("");
  3337. } else {
  3338. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3339. let output = "";
  3340. output += "<wnc wid='" + id + "'></wnc>";
  3341. let head = "";
  3342. let content = "";
  3343. if (wnote.match("{") && wnote.match("}")) {
  3344. wnote = wnote.replace("{", "<strong>");
  3345. wnote = wnote.replace("}", "</strong>");
  3346. } else {
  3347. output += "<strong>" + paliword + ":</strong>";
  3348. }
  3349. output += wnote;
  3350. $("#wnn_" + id).html(output);
  3351. }
  3352. }
  3353. function updateWordCommentary(element) {}
  3354. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3355. //返回 无
  3356. function updataWordBodyByElement(element) {
  3357. try {
  3358. var sId = getNodeText(wordNode, "id");
  3359. var sDetail = "detail" + sId;
  3360. var cDetail = document.getElementById(sDetail);
  3361. if (cDetail != null) {
  3362. cDetail.innerHTML = renderWordDetailByElement(element);
  3363. }
  3364. } catch (error) {
  3365. var_dump(error);
  3366. }
  3367. }
  3368. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3369. //返回 无
  3370. function modifyWordDetailByWordId(wordId) {
  3371. try {
  3372. var sDetail = "detail" + wordId;
  3373. var cDetail = document.getElementById(sDetail);
  3374. if (cDetail != null) {
  3375. cDetail.innerHTML = renderWordDetailById(wordId);
  3376. }
  3377. } catch (error) {
  3378. var_dump(error);
  3379. }
  3380. }
  3381. //根据xmlDocument 对象中的单词GUID返回单词块字符串(不含Pali)
  3382. //返回 字符串
  3383. function renderWordDetailById(wordID) {
  3384. var mXML = gXmlBookDataBody.getElementsByTagName("word");
  3385. var wordIndex = getWordIndex(wordID);
  3386. return renderWordDetailByElement(mXML[wordIndex]);
  3387. }
  3388. function reloadPar(parIndex) {
  3389. bookId = gArrayDocParagraph[parIndex].book;
  3390. parNo = gArrayDocParagraph[parIndex].paragraph;
  3391. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3392. if (htmlBlock.style.display != "none") {
  3393. return false;
  3394. }
  3395. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  3396. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  3397. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  3398. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  3399. currBookId = getNodeText(xmlParInfo, "book");
  3400. currParNo = getNodeText(xmlParInfo, "paragraph");
  3401. if (bookId == currBookId && currParNo == parNo) {
  3402. insertBlockToHtml(allBlock[iBlock]);
  3403. }
  3404. }
  3405. return true;
  3406. }
  3407. function removePar(parIndex) {
  3408. bookId = gArrayDocParagraph[parIndex].book;
  3409. parNo = gArrayDocParagraph[parIndex].paragraph;
  3410. if (gCurrModifyWindowParNo == parIndex) {
  3411. //关闭单词修改窗口
  3412. closeModifyWindow();
  3413. }
  3414. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3415. if (htmlBlock) {
  3416. htmlBlock.style.display = "none";
  3417. document.getElementById("heading_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3418. document.getElementById("wblock_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3419. document.getElementById("tran_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3420. document.getElementById("wnote_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3421. document.getElementById("note_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3422. }
  3423. }
  3424. function setView(topParIndex) {
  3425. var parInOnePage = 3;
  3426. gCurrTopParagraph = topParIndex;
  3427. gVisibleParBegin = topParIndex - parInOnePage;
  3428. gVisibleParEnd = parInOnePage * 2;
  3429. if (gVisibleParBegin < 0) {
  3430. gVisibleParBegin = 0;
  3431. }
  3432. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3433. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3434. }
  3435. }
  3436. function isParInView(parIndex) {
  3437. if (parIndex >= gVisibleParBegin && parIndex <= gVisibleParEnd) {
  3438. return true;
  3439. } else {
  3440. return false;
  3441. }
  3442. }
  3443. function refresh_Dispaly_Cap() {
  3444. var new_par_length = gPalitext_length / gtext_max_length;
  3445. for (refresh_i in allTextLen_array) {
  3446. gNewArrayDocParagraph.push(allTextLen_array[refresh_i].length / gtext_max_length);
  3447. }
  3448. }
  3449. function prev_page() {
  3450. //向上翻页
  3451. gVisibleParBeginOld = gVisibleParBegin;
  3452. gVisibleParEndOld = gVisibleParEnd;
  3453. if (g_allparlen_array[gVisibleParEnd - 1] - g_allparlen_array[gVisibleParBegin - 1] <= gDisplayCapacity) {
  3454. gVisibleParBegin -= 1;
  3455. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin - 1] > gDisplayCapacity) {
  3456. gVisibleParBegin -= 1;
  3457. gVisibleParEnd -= 1;
  3458. }
  3459. if (gVisibleParBegin < 0) {
  3460. //如果到顶,则恢复原始值
  3461. gVisibleParBegin = 0;
  3462. //gVisibleParEnd=gDisplayCapacity;
  3463. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3464. //如果到底,则锁死最大值
  3465. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3466. }
  3467. }
  3468. updataView();
  3469. }
  3470. function next_page() {
  3471. //向下翻页
  3472. gVisibleParBeginOld = gVisibleParBegin;
  3473. gVisibleParEndOld = gVisibleParEnd;
  3474. if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] <= gDisplayCapacity) {
  3475. gVisibleParEnd += 1;
  3476. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] > gDisplayCapacity) {
  3477. gVisibleParBegin += 1;
  3478. gVisibleParEnd += 1;
  3479. }
  3480. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3481. //如果到底
  3482. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3483. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3484. if (gVisibleParBegin < 0) {
  3485. gVisibleParBegin = 0;
  3486. }
  3487. }
  3488. updataView();
  3489. }
  3490. function setNewView(newBegin, newEnd) {
  3491. gVisibleParBeginOld = gVisibleParBegin;
  3492. gVisibleParEndOld = gVisibleParEnd;
  3493. gVisibleParBegin = newBegin;
  3494. gVisibleParEnd = newEnd;
  3495. if (gVisibleParBegin < 0) {
  3496. gVisibleParBegin = 0;
  3497. //gVisibleParEnd=gDisplayCapacity;
  3498. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3499. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3500. }
  3501. }
  3502. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3503. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3504. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3505. if (gVisibleParBegin < 0) {
  3506. gVisibleParBegin = 0;
  3507. }
  3508. }
  3509. updataView();
  3510. }
  3511. function updataView() {
  3512. var topNewDivArray = Array(); //在顶端新加入的块列表
  3513. for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  3514. if (isParInView(iPar)) {
  3515. isLoadNew = reloadPar(iPar);
  3516. if (isLoadNew) {
  3517. if (iPar < gVisibleParBeginOld) {
  3518. topNewDivArray.push(iPar);
  3519. }
  3520. }
  3521. } else {
  3522. removePar(iPar);
  3523. }
  3524. }
  3525. word_mouse_event();
  3526. //console.log("updataview");
  3527. console.log(topNewDivArray.toString());
  3528. }
  3529. function render_word_mean_menu2(spell) {
  3530. var wReal = spell;
  3531. var output = "<div>";
  3532. for (var iDict = 0; iDict < mDict[spell].length; iDict++) {
  3533. output += "<div>";
  3534. output += "<span>dict_name</span>";
  3535. var meanGroup = partList2[i].mean.split("$");
  3536. for (var iMean = 0; iMean < meanGroup.length; iMean++) {
  3537. output +=
  3538. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3539. wId +
  3540. '","mean","' +
  3541. meanGroup[iMean] +
  3542. "\")'>" +
  3543. meanGroup[iMean] +
  3544. "</span>";
  3545. }
  3546. output += "</div>";
  3547. }
  3548. output += "</div>";
  3549. return;
  3550. var sWord = new Array(wReal);
  3551. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3552. for (var iWord in sWord) {
  3553. output += '<div class="case_dropdown-first">';
  3554. output +=
  3555. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3556. sWord[iWord] +
  3557. "\")'>";
  3558. output += sWord[iWord] + "</a>";
  3559. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3560. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3561. output += '</span><div class="case_dropdown-detail">';
  3562. var partList = render_get_word_mean_list(sWord[iWord]);
  3563. var L_width_mean = 0;
  3564. var partList2 = repeat_combine(partList);
  3565. //计算字符长度并控制
  3566. for (var i in partList2) {
  3567. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3568. if (L_width_mean < L_width / 1.7) {
  3569. L_width_mean = L_width / 1.7;
  3570. }
  3571. }
  3572. for (var i in partList2) {
  3573. var meanGroup = partList2[i].mean.split("$");
  3574. var htmlMean = "";
  3575. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3576. output +=
  3577. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3578. //output += "<a ><div id='div_dictname_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_dictname+"em; display:flex'>"
  3579. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3580. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3581. output += getLocalDictname(partList2[i].dict) + "</span>";
  3582. output += "</div>";
  3583. output +=
  3584. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3585. //output += "<div id='div_type_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_type+"em; display:flex'>"
  3586. output +=
  3587. "<span id='span_type_" +
  3588. wId +
  3589. "_" +
  3590. iWord +
  3591. "_" +
  3592. i +
  3593. "' style='height: 1.5em;' class='wm_wordtype'>" +
  3594. getLocalGrammaStr(partList2[i].type) +
  3595. "</span>";
  3596. for (var iMean in meanGroup) {
  3597. if (meanGroup[iMean] != "") {
  3598. htmlMean +=
  3599. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3600. wId +
  3601. '","mean","' +
  3602. meanGroup[iMean] +
  3603. "\")'>" +
  3604. meanGroup[iMean] +
  3605. "</span>";
  3606. }
  3607. }
  3608. output += "</div><div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3609. output += "</a>";
  3610. }
  3611. output += "</div></div>";
  3612. }
  3613. output += "</div></div></div>";
  3614. return output;
  3615. }
  3616. function render_word_mean_menu(xElement) {
  3617. var wMean = getNodeText(xElement, "mean");
  3618. var wReal = getNodeText(xElement, "real");
  3619. var wId = getNodeText(xElement, "id");
  3620. var renderMeaning = wMean.replace(/{/g, "<span class='grm_add_mean'>");
  3621. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  3622. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  3623. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  3624. var output = "";
  3625. output += '<div class="case_dropdown">';
  3626. output += "<p class='case_dropbtn' >";
  3627. output += renderMeaning;
  3628. output += "</p>";
  3629. output += '<div class="case_dropdown-content">';
  3630. output +=
  3631. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3632. wId +
  3633. '","mean","")\'>' +
  3634. gLocal.gui.empty1 +
  3635. '</button><div class="case_dropdown-org">';
  3636. var sWord = new Array(wReal);
  3637. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3638. for (var iWord in sWord) {
  3639. output += '<div class="case_dropdown-first">';
  3640. output +=
  3641. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3642. sWord[iWord] +
  3643. "\")'>";
  3644. output += sWord[iWord] + "</a>";
  3645. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3646. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3647. output += "</span>";
  3648. output += '<div class="case_dropdown-detail">';
  3649. var partList = render_get_word_mean_list(sWord[iWord]);
  3650. var L_width_mean = 0;
  3651. var partList2 = repeat_combine(partList);
  3652. for (var i in partList2) {
  3653. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3654. if (L_width_mean < L_width / 1.7) {
  3655. L_width_mean = L_width / 1.7;
  3656. }
  3657. }
  3658. for (var i in partList2) {
  3659. var meanGroup = partList2[i].mean.split("$");
  3660. var htmlMean = "";
  3661. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3662. output +=
  3663. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3664. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3665. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3666. output += getLocalDictname(partList2[i].dict) + "</span>";
  3667. output += "</div>";
  3668. output +=
  3669. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3670. output +=
  3671. "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>";
  3672. if (partList2[i].type == ".n:base.") {
  3673. output += getLocalGrammaStr(partList2[i].gramma);
  3674. } else {
  3675. output += getLocalGrammaStr(partList2[i].type);
  3676. }
  3677. output += "</span>";
  3678. for (var iMean in meanGroup) {
  3679. if (meanGroup[iMean] != "") {
  3680. htmlMean +=
  3681. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3682. wId +
  3683. '","mean","' +
  3684. meanGroup[iMean] +
  3685. "\")'>" +
  3686. meanGroup[iMean] +
  3687. "</span>";
  3688. }
  3689. }
  3690. output += "</div>";
  3691. output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3692. output += "</a>";
  3693. }
  3694. output += "</div></div>";
  3695. }
  3696. output += "</div></div></div>";
  3697. return output;
  3698. }
  3699. function render_get_word_mean_list(sWord) {
  3700. var wReal = sWord;
  3701. var output = Array();
  3702. for (var x in g_DictWordList) {
  3703. if (g_DictWordList[x].Pali == wReal || g_DictWordList[x].Real == wReal) {
  3704. if (dict_language_enable.indexOf(g_DictWordList[x].Language) >= 0) {
  3705. if (
  3706. g_DictWordList[x].Mean != "" &&
  3707. g_DictWordList[x].Type != ".part." &&
  3708. g_DictWordList[x].Type != ".root." &&
  3709. g_DictWordList[x].Type != ".suf." &&
  3710. g_DictWordList[x].Type != ".pfx."
  3711. ) {
  3712. var newPart = Object();
  3713. newPart.dict = g_DictWordList[x].dictname;
  3714. newPart.mean = g_DictWordList[x].Mean;
  3715. newPart.type = g_DictWordList[x].Type;
  3716. var bIsExist = false;
  3717. for (var iBuffer in output) {
  3718. if (
  3719. output[iBuffer].dict == newPart.dict &&
  3720. output[iBuffer].type == newPart.type &&
  3721. output[iBuffer].mean == newPart.mean
  3722. ) {
  3723. bIsExist = true;
  3724. break;
  3725. }
  3726. if (newPart.dict == "wbw") {
  3727. if (output[iBuffer].dict == newPart.dict && output[iBuffer].type == newPart.type) {
  3728. output[iBuffer].mean += "$" + newPart.mean;
  3729. bIsExist = true;
  3730. break;
  3731. }
  3732. }
  3733. }
  3734. if (!bIsExist) {
  3735. output.push(newPart);
  3736. }
  3737. }
  3738. }
  3739. }
  3740. }
  3741. return output;
  3742. }
  3743. function render_get_word_parent_list(sWord) {
  3744. var wReal = sWord;
  3745. var output = Array();
  3746. for (var x in g_DictWordList) {
  3747. if (g_DictWordList[x].Pali == wReal) {
  3748. {
  3749. if (g_DictWordList[x].Parent != "" && g_DictWordList[x].Parent != sWord) {
  3750. var newPart = g_DictWordList[x].Parent;
  3751. var bIsExist = false;
  3752. for (var iBuffer in output) {
  3753. if (output[iBuffer] == newPart) {
  3754. bIsExist = true;
  3755. break;
  3756. }
  3757. }
  3758. if (!bIsExist) {
  3759. output.push(newPart);
  3760. }
  3761. }
  3762. }
  3763. }
  3764. }
  3765. return output;
  3766. }
  3767. function repeat_combine(list) {
  3768. var list_new = new Array();
  3769. for (var repeat_combine_i = 0; repeat_combine_i < list.length; repeat_combine_i++) {
  3770. var repeat_string = new Object();
  3771. var repeat_combine_j = 0;
  3772. repeat_string.dict = list[repeat_combine_i].dict;
  3773. repeat_string.type = list[repeat_combine_i].type;
  3774. repeat_string.mean = list[repeat_combine_i].mean;
  3775. for (repeat_combine_j = repeat_combine_i + 1; repeat_combine_j < list.length; repeat_combine_j++) {
  3776. if (
  3777. list[repeat_combine_j].dict == list[repeat_combine_i].dict &&
  3778. list[repeat_combine_j].type == list[repeat_combine_i].type
  3779. ) {
  3780. repeat_string.mean = repeat_string.mean + "$" + list[repeat_combine_j].mean;
  3781. repeat_string.mean = repeat_string.mean.replace(/\$\$/g, "$");
  3782. repeat_string.mean = repeat_string.mean.replace(/\$ /g, "$");
  3783. repeat_string.mean = repeat_string.mean.replace(/ \$/g, "$");
  3784. repeat_combine_i = repeat_combine_j;
  3785. }
  3786. }
  3787. repeat_string.mean = "#" + repeat_string.mean + "#";
  3788. repeat_string.mean = repeat_string.mean.replace(/ #/g, "");
  3789. repeat_string.mean = repeat_string.mean.replace(/# /g, "");
  3790. repeat_string.mean = repeat_string.mean.replace(/\$#/g, "");
  3791. repeat_string.mean = repeat_string.mean.replace(/#\$/g, "");
  3792. repeat_string.mean = repeat_string.mean.replace(/ /g, "");
  3793. repeat_string.mean = repeat_string.mean.replace(/#/g, "");
  3794. list_new.push(repeat_string);
  3795. }
  3796. return list_new;
  3797. }
  3798. function show_pop_note(wordid) {
  3799. let html = $("wnc[wid='" + wordid + "']")
  3800. .parent()
  3801. .html();
  3802. $("#word_note_pop_content").html(
  3803. html
  3804. /*note_init(doc_word("#" + wordid).val("note"))*/
  3805. );
  3806. $("#word_note_pop").show("500");
  3807. }
  3808. function refreshNoteNumber() {
  3809. $("wnh").each(function (index, element) {
  3810. let id = $(this).attr("wid");
  3811. //$(this).html("<a href='#word_note_"+id+"' name=\"word_note_root_"+id+"\">"+(index+1)+"</a>");
  3812. $(this).html("<span onclick=\"show_pop_note('" + id + "')\">" + (index + 1) + "</span>");
  3813. });
  3814. $("wnc").each(function (index, element) {
  3815. let id = $(this).attr("wid");
  3816. $(this).html("<a href='#word_note_root_" + id + "' name=\"word_note_" + id + '">[' + (index + 1) + "]</a>");
  3817. });
  3818. note_refresh_new();
  3819. }