render.js 139 KB

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