render.js 137 KB

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