render.js 141 KB

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