2
0

render.js 140 KB

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