render.js 133 KB

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