render.js 135 KB

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