render.js 140 KB

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