render.js 137 KB

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