render.js 133 KB

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