render.js 137 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280
  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. //根据relation 绘制关系图
  1532. function sent_show_rel_map(book, para, begin, end) {
  1533. let memind = "graph LR\n";
  1534. let pali_text = "";
  1535. let idList = new Array();
  1536. $("#wbp" + book + "-" + para + "-" + begin)
  1537. .parent()
  1538. .children(".word")
  1539. .each(function (index, element) {
  1540. idList.push(this.id.slice(3));
  1541. });
  1542. for (const iterator_wid of idList) {
  1543. let rel = doc_word("#p" + iterator_wid).val("rela");
  1544. let pali = doc_word("#p" + iterator_wid).val("pali");
  1545. let real = doc_word("#p" + iterator_wid).val("real");
  1546. let type = doc_word("#p" + iterator_wid).val("type");
  1547. let meaning = doc_word("#p" + iterator_wid).val("mean");
  1548. if (type != ".ctl.") {
  1549. pali_text += pali + " ";
  1550. }
  1551. if (rel != "") {
  1552. let relaData = JSON.parse(rel);
  1553. let language = getCookie("language");
  1554. for (const iterator of relaData) {
  1555. let strRel = iterator.relation;
  1556. let relation_locstr = "";
  1557. for (let x in list_relation) {
  1558. if (list_relation[x].id == strRel && language == list_relation[x].language) {
  1559. relation_locstr = list_relation[x].note;
  1560. break;
  1561. }
  1562. }
  1563. let dest = iterator.dest_spell;
  1564. let type = doc_word("#p" + iterator.dest_id).val("case");
  1565. let meanDest = doc_word("#p" + iterator.dest_id).val("mean");
  1566. if (type.indexOf(".v.") >= 0) {
  1567. dest = iterator.dest_id + '(("' + dest + "<br>" + meanDest + '"))';
  1568. } else {
  1569. dest = iterator.dest_id + '["' + dest + "<br>" + meanDest + '"]';
  1570. }
  1571. memind +=
  1572. "p" +
  1573. iterator_wid +
  1574. '("' +
  1575. real +
  1576. "<br>" +
  1577. meaning +
  1578. '")--"' +
  1579. strRel +
  1580. "<br>" +
  1581. relation_locstr +
  1582. '" --> ' +
  1583. dest +
  1584. "\n";
  1585. }
  1586. }
  1587. }
  1588. let graph = mermaid.render("graphDiv", memind);
  1589. document.querySelector("#term_body_parent").innerHTML = '<div class="win_body_inner" id="term_body"></div>'; //清空之前的记录
  1590. document.querySelector("#term_body").outerHTML =
  1591. "<h3 style='padding: 0 1em;'>" + pali_text + "</h3>" + document.querySelector("#term_body").outerHTML;
  1592. document.querySelector("#term_body").innerHTML = graph;
  1593. document.querySelector("#term_win").style.display = "flex";
  1594. document.querySelector(".win_body").style.display = "block";
  1595. }
  1596. //句子编辑块
  1597. function render_tran_sent_block(book, para, begin, end, channal = 0, readonly = true) {
  1598. let usent_count = _user_sent_buffer.getSentNum(book, para, begin, end);
  1599. let netSent = doc_msg_get_trans(book, para, begin, end);
  1600. let sender = "";
  1601. let sChannalName = "";
  1602. let sent_text = "";
  1603. let sent_lang = "en";
  1604. let objSent;
  1605. let thischannal;
  1606. let shell_class = "";
  1607. if (channal == 0) {
  1608. //百家言
  1609. shell_class += " channel_0";
  1610. if (netSent.length > 0) {
  1611. sender = netSent[netSent.length - 1].sender;
  1612. sent_text += netSent[netSent.length - 1].data.text;
  1613. } else if (usent_count > 0) {
  1614. sender = _user_sent_buffer.getSentText(book, para, begin, end)[0].nickname;
  1615. sChannalName = "channal name";
  1616. sent_text += _user_sent_buffer.getSentText(book, para, begin, end)[0].text;
  1617. }
  1618. } else {
  1619. sender = "通道的名字";
  1620. shell_class += " mychannel";
  1621. objSent = _user_sent_buffer.getSentText(book, para, begin, end, channal);
  1622. thischannal = channal_getById(channal);
  1623. if (objSent == false) {
  1624. objSent = new Object();
  1625. objSent.text = "";
  1626. objSent.language = thischannal.lang;
  1627. objSent.id = "";
  1628. objSent.tag = "[]";
  1629. objSent.author = "{}";
  1630. sent_text = "";
  1631. } else {
  1632. sent_text = objSent.text;
  1633. }
  1634. sent_lang = objSent.language;
  1635. }
  1636. let output = "";
  1637. if (readonly == true) {
  1638. shell_class += " readonly";
  1639. }
  1640. output += "<div class='trans_text_block " + shell_class + "' channel_id='" + channal + "'>";
  1641. output += "<div class='trans_text_info' >";
  1642. if (channal == 0) {
  1643. output += "<span class='author'>" + sender + "</span>";
  1644. } else {
  1645. output += "<span style='width: 100%;display: contents;'>";
  1646. output += "<span>";
  1647. if (thischannal) {
  1648. output += "<b>" + thischannal.name + "</b>@";
  1649. if (parseInt(thischannal.power) >= 30) {
  1650. output += gLocal.gui.your;
  1651. } else {
  1652. output += thischannal.nickname;
  1653. }
  1654. } else {
  1655. output += "未知的频道名";
  1656. }
  1657. output += "-[" + thischannal.lang + "]";
  1658. output += "</span>";
  1659. output +=
  1660. "<span style='margin-left: auto;' class='send_status' id='send_" +
  1661. book +
  1662. "_" +
  1663. para +
  1664. "_" +
  1665. begin +
  1666. "_" +
  1667. end +
  1668. "_" +
  1669. channal +
  1670. "'></span>";
  1671. }
  1672. output += "</span><span></span>";
  1673. output += "</div>";
  1674. let id = "tran_pre_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1675. output += "<div class='trans_text_content' tid = '" + id;
  1676. if (channal == 0) {
  1677. output += "' pcds='sent-net-all' ";
  1678. } else {
  1679. output += "' pcds='sent-net' ";
  1680. }
  1681. output +=
  1682. " book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' channal='" + channal + "'>";
  1683. if (readonly) {
  1684. output += note_init(term_std_str_to_tran(sent_text, channal, getCookie("userid"), sent_lang));
  1685. } else {
  1686. output += "<span id='" + id + "' ";
  1687. output += "onclick=\"sent_edit_click('";
  1688. output += book + "','" + para + "','" + begin + "','" + end + "','" + channal + "',)\">";
  1689. if (objSent.text == null || objSent.text == "") {
  1690. output += "<span style='color:gray;'>";
  1691. output += "<svg class='icon' style='fill: var(--detail-color);'>";
  1692. output += "<use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
  1693. output += "</span>";
  1694. } else {
  1695. output += note_init(term_std_str_to_tran(objSent.text, channal, getCookie("userid"), sent_lang));
  1696. }
  1697. output += "</span>";
  1698. }
  1699. output += "</div>";
  1700. //句子预览结束
  1701. //编辑框开始
  1702. if (readonly == false) {
  1703. output += "<div style='display:none;'>";
  1704. let id = book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1705. output += "<textarea id='trans_sent_edit_" + id + "' ";
  1706. output += " onkeyup = \"updateTranslationPreview('" + id + "',this)\" ";
  1707. output +=
  1708. " onchange=\"trans_text_save('" +
  1709. book +
  1710. "','" +
  1711. para +
  1712. "','" +
  1713. begin +
  1714. "','" +
  1715. end +
  1716. "','" +
  1717. channal +
  1718. "')\"";
  1719. output += "class='trans_sent_edit' style='background-color: #f8f8fa;color: black;border-color: silver;' ";
  1720. output += "sent_id='" + objSent.id + "' ";
  1721. output += "book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' ";
  1722. output +=
  1723. " channal='" +
  1724. channal +
  1725. "' author='" +
  1726. objSent.author +
  1727. "' lang='" +
  1728. objSent.language +
  1729. "' tag='" +
  1730. objSent.tag +
  1731. "' >";
  1732. output += objSent.text;
  1733. output += "</textarea>";
  1734. output += "<div class='trans_text_info' style='justify-content: flex-end;'>";
  1735. output += "<span></span>";
  1736. output += "<button class='icon_btn' ";
  1737. output +=
  1738. "onclick=\"trans_text_save('" +
  1739. book +
  1740. "','" +
  1741. para +
  1742. "','" +
  1743. begin +
  1744. "','" +
  1745. end +
  1746. "','" +
  1747. channal +
  1748. "')\" ";
  1749. output +=
  1750. "title=" +
  1751. gLocal.gui.draft +
  1752. ">" +
  1753. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#ic_save"></use></svg>';
  1754. output += "</button>";
  1755. output += "<button class='icon_btn' ";
  1756. output +=
  1757. "onclick=\"trans_text_send('" +
  1758. book +
  1759. "','" +
  1760. para +
  1761. "','" +
  1762. begin +
  1763. "','" +
  1764. end +
  1765. "','" +
  1766. channal +
  1767. "')\"";
  1768. output +=
  1769. " title=" +
  1770. gLocal.gui.send +
  1771. " disabled>" +
  1772. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#send_by_paper_plane"></use></svg>';
  1773. output += "</button>";
  1774. output += "</div>";
  1775. output += "</div>";
  1776. }
  1777. if (readonly) {
  1778. output += "<div class='trans_text_info'>" + "<span></span>" + "<span><span class='tools'>";
  1779. output +=
  1780. "<button class='icon_btn' title=" +
  1781. gLocal.gui.accept_copy +
  1782. ">" +
  1783. "<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>" +
  1784. "</button>";
  1785. if (channal == 0) {
  1786. //百家言 显示更多按钮
  1787. output +=
  1788. "<button class='icon_btn' onclick=\"show_tran_net('" +
  1789. book +
  1790. "','" +
  1791. para +
  1792. "','" +
  1793. begin +
  1794. "','" +
  1795. end +
  1796. "')\" title=" +
  1797. gLocal.gui.message +
  1798. ">" +
  1799. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="plugin/system_message/icon.svg#icon_message"></use></svg>' +
  1800. "</button>";
  1801. }
  1802. output += "</span><span>" + usent_count + "</span></span>";
  1803. output += "</div>";
  1804. }
  1805. output += "</div>";
  1806. return output;
  1807. }
  1808. function trans_text_save(book, para, begin, end, channal) {
  1809. let textarea = $("#trans_sent_edit_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal);
  1810. if (textarea) {
  1811. let objsent = new Object();
  1812. objsent.id = textarea.attr("sent_id");
  1813. objsent.book = book;
  1814. objsent.paragraph = para;
  1815. objsent.begin = begin;
  1816. objsent.end = end;
  1817. objsent.channal = channal;
  1818. objsent.author = textarea.attr("author");
  1819. objsent.lang = textarea.attr("lang");
  1820. objsent.text = textarea.val();
  1821. _user_sent_buffer.setSent(objsent);
  1822. }
  1823. }
  1824. function sent_edit_click(book, para, begin, end, channal) {
  1825. $(".trans_sent_edit").parent().hide(200);
  1826. $(
  1827. ".trans_sent_edit[book='" +
  1828. book +
  1829. "'][para='" +
  1830. para +
  1831. "'][begin='" +
  1832. begin +
  1833. "'][end='" +
  1834. end +
  1835. "'][channal='" +
  1836. channal +
  1837. "']"
  1838. )
  1839. .parent()
  1840. .show();
  1841. }
  1842. function magic_sentence_cut() {
  1843. var all_sent_array = document.getElementsByClassName("sent_wbw");
  1844. for (i_magic = 0; i_magic < all_sent_array.length; i_magic++) {
  1845. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1").length != 0) {
  1846. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1")[0].className += " sent_cut";
  1847. }
  1848. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2").length != 0) {
  1849. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2")[0].className += " sent_cut";
  1850. }
  1851. }
  1852. }
  1853. function updataWordHeadById(wordId) {
  1854. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1855. var iIndex = getWordIndex(wordId);
  1856. if (iIndex >= 0) {
  1857. $("#whead_" + wordId).html(renderWordHeadInner(xAllWord[iIndex]));
  1858. }
  1859. }
  1860. function updataWordHeadByIndex(wordIndex) {
  1861. if (wordIndex > 0) {
  1862. let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1863. let wordId = getNodeText(xAllWord[wordIndex], "id");
  1864. let obj = document.getElementById("whead_" + wordId);
  1865. if (obj) {
  1866. obj.innerHTML = renderWordHeadInner(xAllWord[wordIndex]);
  1867. }
  1868. }
  1869. }
  1870. function updateWordBodyById(wordId) {
  1871. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1872. var wordIndex = getWordIndex(wordId);
  1873. var obj = document.getElementById("detail" + wordId);
  1874. if (obj) {
  1875. obj.innerHTML = renderWordBodyInner(xAllWord[wordIndex]);
  1876. }
  1877. }
  1878. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  1879. //返回 无
  1880. function modifyWordDetailByWordIndex(wordIndex) {
  1881. xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1882. wordId = getNodeText(xAllWord[wordIndex], "id");
  1883. try {
  1884. var sDetail = "detail" + wordId;
  1885. var cDetail = document.getElementById(sDetail);
  1886. if (cDetail != null) {
  1887. cDetail.innerHTML = renderWordDetailByElement(xAllWord[wordIndex]);
  1888. }
  1889. } catch (error) {
  1890. debugOutput(error);
  1891. }
  1892. }
  1893. function renderWordHeadInner(element) {
  1894. var output = "";
  1895. var wid = getNodeText(element, "id");
  1896. var wpali = getNodeText(element, "pali");
  1897. var sParent = getNodeText(element, "parent");
  1898. var wId = getNodeText(element, "id");
  1899. var wNote = getNodeText(element, "note");
  1900. wStyle = "v_" + getNodeText(element, "style");
  1901. if (wStyle == "v_bld") {
  1902. if (wpali.indexOf("{") >= 0) {
  1903. wpali = wpali.replace("{", "<span class='v_bld'>");
  1904. wpali = wpali.replace("}", "</span>");
  1905. wStyle = "";
  1906. }
  1907. }
  1908. if (wNote.indexOf("{{") >= 0 && wNote.indexOf("}}") >= 0) {
  1909. wStyle += " note_ref";
  1910. }
  1911. if (wNote.substring(0, 6) == "=term(") {
  1912. wStyle += " term_word_head";
  1913. } else {
  1914. if (sParent.length > 0) {
  1915. if (term_lookup_my(sParent) != false) {
  1916. wStyle += " term_my";
  1917. } else {
  1918. if (term_lookup_all(sParent) != null) {
  1919. wStyle += " term_other";
  1920. }
  1921. }
  1922. }
  1923. }
  1924. var sign_count = 0;
  1925. var letter_count = 0;
  1926. for (i_sign in local_sign_str) {
  1927. if (wpali.lastIndexOf(local_sign_str[i_sign].id) != -1) {
  1928. sign_count += 1;
  1929. } //如果是标点或数字
  1930. else if (wpali.lastIndexOf(local_letter_str[i_sign].id) != -1) {
  1931. letter_count += 1;
  1932. } //如果有字母
  1933. }
  1934. if (sign_count != 0 && letter_count == 0) {
  1935. output += "<a name='w" + wId + "'>";
  1936. } else {
  1937. output += "<a name='w" + wId + "' onclick='on_word_click(\"" + wId + "\")'>";
  1938. }
  1939. if (wpali) output += '<span id="whead1_' + wid + '" class="whead paliword1 ' + wStyle + '">';
  1940. output += wpali;
  1941. output += "</span>";
  1942. output += "</a>";
  1943. if (wNote.length > 0) {
  1944. output += '<span id="wnote_root_' + wid + '"><wnh wid="' + wid + '">[1]</wnh></span>';
  1945. } else {
  1946. output += '<span id="wnote_root_' + wid + '"></span>';
  1947. }
  1948. var newMsg = msg_word_msg_num(wid);
  1949. if (newMsg > 0) {
  1950. output += "<span class='word_msg' onclick=\"word_msg_counter_click('" + wid + "')\">" + newMsg + "</span>";
  1951. }
  1952. output += '<span id="whead2_' + wid + '" class="whead paliword2 ' + wStyle + '">';
  1953. output += "</span>";
  1954. return output;
  1955. }
  1956. function renderWordBodyInner(element) {
  1957. return renderWordDetailByElement(element);
  1958. }
  1959. //新的渲染单词块函数
  1960. function renderWordDetailByElement_edit_a(xmlElement) {
  1961. if (xmlElement == null) {
  1962. return "";
  1963. }
  1964. var wordNode = xmlElement;
  1965. var sPali = getNodeText(wordNode, "pali");
  1966. var sId = getNodeText(wordNode, "id");
  1967. var sReal = getNodeText(wordNode, "real");
  1968. var sMean = getNodeText(wordNode, "mean");
  1969. var sOrg = getNodeText(wordNode, "org");
  1970. var sOm = getNodeText(wordNode, "om");
  1971. var sCase = getNodeText(wordNode, "case");
  1972. var sType = getNodeText(wordNode, "type");
  1973. var sGramma = getNodeText(wordNode, "gramma");
  1974. var sParent = getNodeText(wordNode, "parent");
  1975. var sParentGrammar = getNodeText(wordNode, "pg");
  1976. var sParent2 = getNodeText(wordNode, "parent2");
  1977. var sNote = getNodeText(wordNode, "note");
  1978. var sStatus = getNodeText(wordNode, "status");
  1979. if (sStatus == "") {
  1980. sStatus = 0;
  1981. }
  1982. var wordID = sId;
  1983. if (sCase == "") {
  1984. sCase = sType + "#" + sGramma;
  1985. }
  1986. var _txtOutDetail = "";
  1987. var _bgColor = "";
  1988. var status_bg_color = "status_bg_color_" + sStatus;
  1989. var _caseColor = "";
  1990. //标点符号
  1991. if (sReal.length <= 1) {
  1992. _txtOutDetail += "<div>";
  1993. /*id begin*/
  1994. _txtOutDetail += "<div class='ID'> </div>";
  1995. /*mean begin*/
  1996. _txtOutDetail += "<div class='mean'> </div>";
  1997. /*org begin*/
  1998. _txtOutDetail += "<div class='org'> </div>";
  1999. /*org mean begin*/
  2000. _txtOutDetail += "<div class='om'> </div>";
  2001. /*case begin*/
  2002. _txtOutDetail += "<div class='case'> </div>";
  2003. _txtOutDetail += "</div>";
  2004. return _txtOutDetail;
  2005. }
  2006. var strBookMarkColor = getNodeText(wordNode, "bmc");
  2007. if (strBookMarkColor.length > 2) {
  2008. var icolor = strBookMarkColor.substr(-1);
  2009. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2010. }
  2011. // Auto Match Begin
  2012. if (sCase == "?" && _bgColor == "") {
  2013. _caseColor = " class='bookmarkcolorx' ";
  2014. }
  2015. if (g_useMode == "read" || g_useMode == "translate") {
  2016. _bgColor = "";
  2017. _caseColor = "";
  2018. if (sOrg == "?") {
  2019. sOrg = " ";
  2020. }
  2021. if (sMean == "?") {
  2022. sMean = " ";
  2023. }
  2024. if (sCase == "?" || sCase == "?#?") {
  2025. sCase = " ";
  2026. }
  2027. }
  2028. //编辑模式开始
  2029. {
  2030. /*gramma*/
  2031. /*find in dict*/
  2032. var arrGramma = new Array();
  2033. var thisWord = sReal;
  2034. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2035. if (thisWord == g_DictWordList[iDict].Pali) {
  2036. if (
  2037. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2038. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2039. ) {
  2040. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2041. pushNewToList(arrGramma, arrCase);
  2042. }
  2043. }
  2044. }
  2045. if (sCase == "?" || sCase == "?#?") {
  2046. if (arrGramma.length > 0) {
  2047. setNodeText(xmlElement, "case", arrGramma[0]);
  2048. sCase = arrGramma[0];
  2049. } else {
  2050. setNodeText(xmlElement, "case", "?#?");
  2051. sCase = "?#?";
  2052. }
  2053. } else {
  2054. if (sCase.indexOf("#") == -1) {
  2055. sCase = "?#" + sCase;
  2056. setNodeText(xmlElement, "case", "?#" + sCase);
  2057. }
  2058. }
  2059. var currType = sCase.split("#")[0];
  2060. var currGramma = sCase.split("#")[1];
  2061. //end gramma
  2062. if (getNodeText(wordNode, "lock") == "true") {
  2063. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2064. } else {
  2065. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2066. }
  2067. //状态颜色
  2068. _txtOutDetail += "<div class='" + status_bg_color + "'>";
  2069. //书签颜色
  2070. _txtOutDetail += "<div " + _bgColor + ">";
  2071. /*id begin*/
  2072. /*
  2073. _txtOutDetail += "<p class='ID'>";
  2074. _txtOutDetail += sId + "&nbsp;";
  2075. _txtOutDetail += "</p>";
  2076. */
  2077. /*id end*/
  2078. /*meaning*/
  2079. //格位公式开始
  2080. //去除格位公式
  2081. var currMeaning = removeFormula(sMean);
  2082. //currMeaning = getLocalFormulaStr(currGramma,currMeaning);
  2083. var orgMeaning = sMean;
  2084. //切割过长意思
  2085. if (sReal.length < 4) {
  2086. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, 24));
  2087. } else {
  2088. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, sReal.length * 6));
  2089. }
  2090. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2091. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2092. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2093. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2094. //格位公式结束
  2095. if (sMean.length == 0) {
  2096. renderMeaning = "<span class='word_space_holder'>meaning</span>";
  2097. }
  2098. //渲染下拉菜单
  2099. _txtOutDetail += "<div class='mean'>";
  2100. _txtOutDetail += '<div class="case_dropdown">';
  2101. _txtOutDetail += "<p class='case_dropbtn' >";
  2102. _txtOutDetail += renderMeaning;
  2103. _txtOutDetail += "</p>";
  2104. _txtOutDetail += "<div id='mean_" + wordID + '\' class="case_dropdown-content">';
  2105. _txtOutDetail += "</div>";
  2106. _txtOutDetail += "</div>";
  2107. //render formula menu
  2108. arrFormula = getFormulaList(currGramma);
  2109. _txtOutDetail += '<div class="case_dropdown">';
  2110. _txtOutDetail += "<svg class='edit_icon'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2111. _txtOutDetail += '<div class="case_dropdown-content">';
  2112. newWord = removeFormula_B(orgMeaning);
  2113. _txtOutDetail +=
  2114. "<a onclick='fieldListChanged(\"" +
  2115. wordID +
  2116. '","mean","[]' +
  2117. newWord +
  2118. "\")'>[" +
  2119. gLocal.gui.none +
  2120. "]</a>";
  2121. _txtOutDetail +=
  2122. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[" + gLocal.gui.auto + "]</a>";
  2123. for (var i in arrFormula) {
  2124. newWord = removeFormula_B(orgMeaning);
  2125. newWord = arrFormula[i].replace("~", newWord);
  2126. newWord = newWord.replace(/{/g, "[");
  2127. newWord = newWord.replace(/}/g, "]");
  2128. _txtOutDetail +=
  2129. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2130. }
  2131. _txtOutDetail += "</div>";
  2132. _txtOutDetail += "</div>";
  2133. _txtOutDetail += "</div> ";
  2134. /*end of meaning*/
  2135. /*org begin 拆分*/
  2136. _txtOutDetail += "<div class='org' name='w_org'>";
  2137. _txtOutDetail += '<div class="case_dropdown">';
  2138. _txtOutDetail += "<p class='case_dropbtn' >";
  2139. let currOrg;
  2140. if (sOrg.length == 0) {
  2141. currOrg = "<span class='word_space_holder'>parts</span>";
  2142. } else {
  2143. currOrg = sOrg;
  2144. }
  2145. _txtOutDetail += currOrg;
  2146. _txtOutDetail += "</p>";
  2147. _txtOutDetail += '<div class="case_dropdown-content">';
  2148. _txtOutDetail += "<div id='parts_" + sId + "'>Loading</div>";
  2149. _txtOutDetail += "</div>";
  2150. _txtOutDetail += "</div>";
  2151. _txtOutDetail += "</div> ";
  2152. /*end of factors*/
  2153. /*part meaning begin*/
  2154. _txtOutDetail += "<div class='om' name='w_om'>";
  2155. _txtOutDetail += '<div class="case_dropdown">';
  2156. _txtOutDetail += "<p class='case_dropbtn' >";
  2157. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  2158. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  2159. var currDefualtFM = "";
  2160. var listFactorForFactorMean = sOrg.split("+");
  2161. for (iFactor in listFactorForFactorMean) {
  2162. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2163. }
  2164. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  2165. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  2166. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  2167. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  2168. if (currDefualtFM.slice(-1, -2) == "+") {
  2169. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  2170. }
  2171. currOM = "[a]" + currDefualtFM;
  2172. setNodeText(wordNode, "om", currOM);
  2173. } else {
  2174. currOM = sOm;
  2175. }
  2176. if (currOM.length == 0) {
  2177. currOM = "<span class='word_space_holder''>part mean</span>";
  2178. }
  2179. _txtOutDetail += currOM;
  2180. _txtOutDetail += "</p>";
  2181. _txtOutDetail += '<div class="case_dropdown-content">';
  2182. _txtOutDetail += "<div id='partmean_" + sId + "'></div>";
  2183. _txtOutDetail += "</div>";
  2184. _txtOutDetail += "</div>";
  2185. _txtOutDetail += "</div> ";
  2186. /*org meaning end*/
  2187. /*begin gramma*/
  2188. _txtOutDetail += "<div class='case'>";
  2189. _txtOutDetail += '<div class="case_dropdown">';
  2190. _txtOutDetail += "<p class='case_dropbtn' >";
  2191. var sLocalCase = getLocalGrammaStr(sCase);
  2192. var mArrGramma = sCase.split("#");
  2193. if (mArrGramma.length >= 2) {
  2194. mType = mArrGramma[0];
  2195. mGramma = mArrGramma[1];
  2196. mLocalType = sLocalCase.split("#")[0];
  2197. mLocalGramma = sLocalCase.split("#")[1];
  2198. } else {
  2199. mType = "";
  2200. mGramma = mArrGramma[0];
  2201. mLocalType = "";
  2202. mLocalGramma = sLocalCase.split("#")[0];
  2203. }
  2204. if (mType != "") {
  2205. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  2206. }
  2207. _txtOutDetail += cutString(mLocalGramma, 30);
  2208. if (mLocalType.length + mLocalGramma.length == 0) {
  2209. _txtOutDetail += "&nbsp;";
  2210. }
  2211. _txtOutDetail += "</p>";
  2212. _txtOutDetail += '<div class="case_dropdown-content">';
  2213. _txtOutDetail += "<div id='gramma_" + sId + "'></div>";
  2214. _txtOutDetail += "</div>";
  2215. _txtOutDetail += "</div>";
  2216. //连读词按钮
  2217. if (mType == ".un." || mType == ".comp.") {
  2218. nextElement = com_get_nextsibling(xmlElement);
  2219. if (nextElement != null) {
  2220. //下一个元素存在
  2221. if (getNodeText(nextElement, "un") == sId) {
  2222. //若有孩子則显示收起按鈕
  2223. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  2224. _txtOutDetail +=
  2225. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  2226. _txtOutDetail += "</button>";
  2227. var parentElement = document.getElementById("wb" + sId);
  2228. if (parentElement) {
  2229. parentElement.classList.add("un_parent");
  2230. }
  2231. } else {
  2232. //無kid展開按鈕
  2233. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2234. _txtOutDetail +=
  2235. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2236. _txtOutDetail += "</button> ";
  2237. }
  2238. } else {
  2239. //下一个元素不存在
  2240. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2241. _txtOutDetail +=
  2242. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2243. _txtOutDetail += "</button> ";
  2244. }
  2245. }
  2246. //连读词按钮 结束
  2247. //爷爷和父亲的关系 如pp
  2248. /*
  2249. if(wordGranfatherGramma.length>0 && wordGranfatherGramma.length<6){
  2250. _txtOutDetail += "<span class=\"tooltip\">«"+getLocalGrammaStr(wordGranfatherGramma)+"<span class=\"tooltiptext tooltip-bottom\">"+wordGranfather+"</span>"+"</span> ";
  2251. }
  2252. */
  2253. _txtOutDetail += "</div> ";
  2254. /*end of gramma*/
  2255. _txtOutDetail += "</div>";
  2256. _txtOutDetail += "</div>";
  2257. }
  2258. return _txtOutDetail;
  2259. }
  2260. function renderWordDetailByElement(xmlElement) {
  2261. return renderWordDetailByElement_edit_a(xmlElement);
  2262. if (xmlElement == null) {
  2263. return "";
  2264. }
  2265. wordNode = xmlElement;
  2266. var sPali = getNodeText(wordNode, "pali");
  2267. var sId = getNodeText(wordNode, "id");
  2268. var sReal = getNodeText(wordNode, "real");
  2269. var sMean = getNodeText(wordNode, "mean");
  2270. var sOrg = getNodeText(wordNode, "org");
  2271. var sOm = getNodeText(wordNode, "om");
  2272. var sCase = getNodeText(wordNode, "case");
  2273. var sType = getNodeText(wordNode, "type");
  2274. var sGramma = getNodeText(wordNode, "gramma");
  2275. var sParent = getNodeText(wordNode, "parent");
  2276. var sNote = getNodeText(wordNode, "note");
  2277. wordID = sId;
  2278. if (sCase == "") {
  2279. sCase = sType + "#" + sGramma;
  2280. }
  2281. var _txtOutDetail = "";
  2282. var _bgColor = "";
  2283. var _caseColor = "";
  2284. //标点符号
  2285. if (sReal.length <= 1) {
  2286. _txtOutDetail += "<div>";
  2287. /*id begin*/
  2288. _txtOutDetail += "<div class='ID'> </div>";
  2289. /*mean begin*/
  2290. _txtOutDetail += "<div class='mean'> </div>";
  2291. /*org begin*/
  2292. _txtOutDetail += "<div class='org'> </div>";
  2293. /*org mean begin*/
  2294. _txtOutDetail += "<div class='om'> </div>";
  2295. /*case begin*/
  2296. _txtOutDetail += "<div class='case'> </div>";
  2297. _txtOutDetail += "</div>";
  2298. return _txtOutDetail;
  2299. }
  2300. if (sMean == "?") {
  2301. _bgColor = " class='bookmarkcolorx' ";
  2302. }
  2303. strBookMarkColor = getNodeText(wordNode, "bmc");
  2304. if (strBookMarkColor.length > 2) {
  2305. var icolor = strBookMarkColor.substr(-1);
  2306. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2307. }
  2308. // Auto Match Begin
  2309. if (sCase == "?" && _bgColor == "") {
  2310. _caseColor = " class='bookmarkcolorx' ";
  2311. }
  2312. if (g_useMode == "read" || g_useMode == "translate") {
  2313. _bgColor = "";
  2314. _caseColor = "";
  2315. if (sOrg == "?") {
  2316. sOrg = " ";
  2317. }
  2318. if (sMean == "?") {
  2319. sMean = " ";
  2320. }
  2321. if (sCase == "?" || sCase == "?#?") {
  2322. sCase = " ";
  2323. }
  2324. }
  2325. if (g_useMode == "read") {
  2326. _txtOutDetail += "<div " + _bgColor + ">";
  2327. /*id begin*/
  2328. _txtOutDetail += "<p class='ID'>";
  2329. _txtOutDetail += sId + "&nbsp;";
  2330. _txtOutDetail += "</p>";
  2331. /*id end*/
  2332. /*meaning begin*/
  2333. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2334. showMean = showMean.replace(/}/g, "</span>");
  2335. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2336. showMean = showMean.replace(/\]/g, "</span>");
  2337. _txtOutDetail += "<p class='mean'>";
  2338. _txtOutDetail += showMean + "&nbsp;";
  2339. _txtOutDetail += "</p>";
  2340. /*meaning end*/
  2341. /*org begin*/
  2342. _txtOutDetail += "<p class='org'>";
  2343. _txtOutDetail += sOrg + "&nbsp;";
  2344. _txtOutDetail += "</p>";
  2345. /*org end*/
  2346. /*org meaning begin*/
  2347. _txtOutDetail += "<p class='om'>";
  2348. _txtOutDetail += sOm + "&nbsp;";
  2349. _txtOutDetail += "</p>";
  2350. /*org meaning end*/
  2351. /*grmma begin*/
  2352. _txtOutDetail += "<p class='case'>";
  2353. sCase = getLocalGrammaStr(sCase);
  2354. var mGramma = sCase.split("#");
  2355. if (mGramma.length >= 2) {
  2356. mType = sCase.split("#")[0];
  2357. mGramma = sCase.split("#")[1];
  2358. } else {
  2359. mType = "";
  2360. mGramma = sCase.split("#")[0];
  2361. }
  2362. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2363. if (mType != "") {
  2364. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2365. }
  2366. _txtOutDetail += mGramma;
  2367. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2368. /*grmma end*/
  2369. _txtOutDetail += "</div>";
  2370. }
  2371. //编辑模式开始
  2372. if (g_useMode == "edit") {
  2373. if (getNodeText(wordNode, "lock") == "true") {
  2374. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2375. } else {
  2376. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2377. }
  2378. _txtOutDetail += "<div " + _bgColor + ">";
  2379. /*id begin*/
  2380. _txtOutDetail += "<p class='ID'>";
  2381. _txtOutDetail += sId + "&nbsp;";
  2382. _txtOutDetail += "</p>";
  2383. /*id end*/
  2384. /*gramma*/
  2385. /*find in dict*/
  2386. var arrGramma = new Array();
  2387. var thisWord = getNodeText(wordNode, "real");
  2388. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2389. if (thisWord == g_DictWordList[iDict].Pali) {
  2390. if (
  2391. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2392. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2393. ) {
  2394. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2395. pushNewToList(arrGramma, arrCase);
  2396. }
  2397. }
  2398. }
  2399. if (sCase == "?" || sCase == "?#?") {
  2400. if (arrGramma.length > 0) {
  2401. setNodeText(xmlElement, "case", arrGramma[0]);
  2402. sCase = arrGramma[0];
  2403. } else {
  2404. setNodeText(xmlElement, "case", "?#?");
  2405. sCase = "?#?";
  2406. }
  2407. } else {
  2408. if (sCase.indexOf("#") == -1) {
  2409. sCase = "?#" + sCase;
  2410. setNodeText(xmlElement, "case", "?#" + sCase);
  2411. }
  2412. }
  2413. var currType = sCase.split("#")[0];
  2414. var currGramma = sCase.split("#")[1];
  2415. //end gramma
  2416. /*meaning*/
  2417. /*find in dict*/
  2418. var arrMeaning = new Array();
  2419. var currMeaning = "";
  2420. var currGrammaMeaning = "";
  2421. var wordParent = "";
  2422. var wordGramma0 = "";
  2423. //self meaning
  2424. var thisWord = getNodeText(wordNode, "real");
  2425. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2426. if (
  2427. thisWord == g_DictWordList[iDict].Pali &&
  2428. g_DictWordList[iDict].Type != ".root." &&
  2429. g_DictWordList[iDict].Type != ".suf." &&
  2430. g_DictWordList[iDict].Type != ".prf."
  2431. ) {
  2432. if (
  2433. wordParent == "" &&
  2434. g_DictWordList[iDict].Parent.length > 0 &&
  2435. g_DictWordList[iDict].Parent != thisWord
  2436. ) {
  2437. wordParent = g_DictWordList[iDict].Parent;
  2438. wordGramma0 = g_DictWordList[iDict].Gramma;
  2439. }
  2440. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2441. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2442. if (currGrammaMeaning == "") {
  2443. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2444. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2445. }
  2446. }
  2447. }
  2448. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2449. for (var i = 0; i < arrMean.length; i++) {
  2450. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2451. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2452. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2453. arrMeaning.push(
  2454. g_DictWordList[iDict].dictID +
  2455. "$" +
  2456. arrMeaning.length +
  2457. "$$" +
  2458. arrMean[i] +
  2459. "$" +
  2460. g_DictWordList[iDict].Language
  2461. );
  2462. }
  2463. }
  2464. }
  2465. }
  2466. }
  2467. var wordGramma1 = "";
  2468. //find in father
  2469. if (wordParent != "") {
  2470. //add parent infomation
  2471. if (sParent == "" || sParent == " ") {
  2472. setNodeText(wordNode, "parent", wordParent);
  2473. sParent = wordParent;
  2474. }
  2475. thisWord = wordParent;
  2476. wordParent = "";
  2477. wordGramma1 = "";
  2478. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2479. if (
  2480. thisWord == g_DictWordList[iDict].Pali &&
  2481. g_DictWordList[iDict].Type != ".v." &&
  2482. g_DictWordList[iDict].Type != ".n." &&
  2483. g_DictWordList[iDict].Type != ".ti." &&
  2484. g_DictWordList[iDict].Type != ".adj." &&
  2485. g_DictWordList[iDict].Type != ".pron." &&
  2486. g_DictWordList[iDict].Type != ".num."
  2487. ) {
  2488. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2489. if (wordParent == "") {
  2490. wordParent = g_DictWordList[iDict].Parent;
  2491. }
  2492. if (wordGramma1 == "") {
  2493. wordGramma1 = g_DictWordList[iDict].Gramma;
  2494. }
  2495. }
  2496. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2497. for (var i = 0; i < arrMean.length; i++) {
  2498. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2499. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2500. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2501. arrMeaning.push(
  2502. g_DictWordList[iDict].dictID +
  2503. "$" +
  2504. arrMeaning.length +
  2505. "$*$" +
  2506. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2507. "$" +
  2508. g_DictWordList[iDict].Language
  2509. );
  2510. }
  2511. }
  2512. }
  2513. }
  2514. }
  2515. }
  2516. //爷爷跟父亲的关系 比如 pp
  2517. wordGranfatherGramma = wordGramma1;
  2518. wordGranfather = wordParent;
  2519. //grandfather
  2520. var wordGramma2 = "";
  2521. if (wordParent != "") {
  2522. thisWord = wordParent;
  2523. wordParent = "";
  2524. wordGramma2 = "";
  2525. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2526. if (
  2527. thisWord == g_DictWordList[iDict].Pali &&
  2528. g_DictWordList[iDict].Type != ".v." &&
  2529. g_DictWordList[iDict].Type != ".n." &&
  2530. g_DictWordList[iDict].Type != ".ti." &&
  2531. g_DictWordList[iDict].Type != ".adj." &&
  2532. g_DictWordList[iDict].Type != ".pron." &&
  2533. g_DictWordList[iDict].Type != ".num."
  2534. ) {
  2535. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2536. if (wordParent == "") {
  2537. wordParent = g_DictWordList[iDict].Parent;
  2538. }
  2539. if (wordGramma2 == "") {
  2540. wordGramma2 = g_DictWordList[iDict].Gramma;
  2541. }
  2542. }
  2543. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2544. for (var i = 0; i < arrMean.length; i++) {
  2545. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2546. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2547. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2548. arrMeaning.push(
  2549. g_DictWordList[iDict].dictID +
  2550. "$" +
  2551. arrMeaning.length +
  2552. "$**$" +
  2553. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2554. "$" +
  2555. g_DictWordList[iDict].Language
  2556. );
  2557. }
  2558. }
  2559. }
  2560. }
  2561. }
  2562. }
  2563. arrMeaning.sort(sortMeanByDictOrder);
  2564. //arrMeaning.sort(sortMeanByLanguageOrder);
  2565. newMeanList = removeSameWordInArray(arrMeaning);
  2566. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2567. if (sMean == "?") {
  2568. //自动匹配一个意思
  2569. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2570. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2571. currMeaning = currGrammaMeaning;
  2572. } else {
  2573. if (newMeanList.length > 0) {
  2574. currMeaning = newMeanList[0].word;
  2575. } else {
  2576. currMeaning = sMean;
  2577. }
  2578. }
  2579. } else {
  2580. currMeaning = removeFormula(sMean);
  2581. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2582. }
  2583. orgMeaning = removeFormula(currMeaning);
  2584. if (sReal.length < 4) {
  2585. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2586. } else {
  2587. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2588. }
  2589. setNodeText(wordNode, "mean", currMeaning);
  2590. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2591. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2592. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2593. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2594. //渲染下拉菜单
  2595. _txtOutDetail += "<div class='mean'>";
  2596. _txtOutDetail += render_word_mean_menu(wordNode);
  2597. //render formula menu
  2598. arrFormula = getFormulaList(currGramma);
  2599. _txtOutDetail += '<div class="case_dropdown">';
  2600. _txtOutDetail += "<svg class='edit_icon'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2601. _txtOutDetail += '<div class="case_dropdown-content">';
  2602. newWord = removeFormula_B(orgMeaning);
  2603. _txtOutDetail +=
  2604. "<a onclick='fieldListChanged(\"" +
  2605. wordID +
  2606. '","mean","[]' +
  2607. newWord +
  2608. "\")'>[" +
  2609. gLocal.gui.none +
  2610. "]</a>";
  2611. _txtOutDetail +=
  2612. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[" + gLocal.gui.auto + "]</a>";
  2613. for (var i in arrFormula) {
  2614. newWord = removeFormula_B(orgMeaning);
  2615. newWord = arrFormula[i].replace("~", newWord);
  2616. newWord = newWord.replace(/{/g, "[");
  2617. newWord = newWord.replace(/}/g, "]");
  2618. _txtOutDetail +=
  2619. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2620. }
  2621. _txtOutDetail += "</div>";
  2622. _txtOutDetail += "</div>";
  2623. _txtOutDetail += "</div> ";
  2624. /*end of meaning*/
  2625. /*org begin 拆分*/
  2626. /*
  2627. =======
  2628. return renderWordDetailByElement_edit_a(xmlElement);
  2629. if (xmlElement == null) {
  2630. return "";
  2631. }
  2632. wordNode = xmlElement;
  2633. var sPali = getNodeText(wordNode, "pali");
  2634. var sId = getNodeText(wordNode, "id");
  2635. var sReal = getNodeText(wordNode, "real");
  2636. var sMean = getNodeText(wordNode, "mean");
  2637. var sOrg = getNodeText(wordNode, "org");
  2638. var sOm = getNodeText(wordNode, "om");
  2639. var sCase = getNodeText(wordNode, "case");
  2640. var sType = getNodeText(wordNode, "type");
  2641. var sGramma = getNodeText(wordNode, "gramma");
  2642. var sParent = getNodeText(wordNode, "parent");
  2643. var sNote = getNodeText(wordNode, "note");
  2644. wordID = sId;
  2645. if (sCase == "") {
  2646. sCase = sType + "#" + sGramma;
  2647. }
  2648. var _txtOutDetail = "";
  2649. var _bgColor = "";
  2650. var _caseColor = "";
  2651. //标点符号
  2652. if (sReal.length <= 1) {
  2653. _txtOutDetail += "<div>";
  2654. /*id begin*/
  2655. _txtOutDetail += "<div class='ID'> </div>";
  2656. /*mean begin*/
  2657. _txtOutDetail += "<div class='mean'> </div>";
  2658. /*org begin*/
  2659. _txtOutDetail += "<div class='org'> </div>";
  2660. /*org mean begin*/
  2661. _txtOutDetail += "<div class='om'> </div>";
  2662. /*case begin*/
  2663. _txtOutDetail += "<div class='case'> </div>";
  2664. _txtOutDetail += "</div>";
  2665. return _txtOutDetail;
  2666. }
  2667. if (sMean == "?") {
  2668. _bgColor = " class='bookmarkcolorx' ";
  2669. }
  2670. strBookMarkColor = getNodeText(wordNode, "bmc");
  2671. if (strBookMarkColor.length > 2) {
  2672. var icolor = strBookMarkColor.substr(-1);
  2673. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2674. }
  2675. // Auto Match Begin
  2676. if (sCase == "?" && _bgColor == "") {
  2677. _caseColor = " class='bookmarkcolorx' ";
  2678. }
  2679. if (g_useMode == "read" || g_useMode == "translate") {
  2680. _bgColor = "";
  2681. _caseColor = "";
  2682. if (sOrg == "?") {
  2683. sOrg = " ";
  2684. }
  2685. if (sMean == "?") {
  2686. sMean = " ";
  2687. }
  2688. if (sCase == "?" || sCase == "?#?") {
  2689. sCase = " ";
  2690. }
  2691. }
  2692. if (g_useMode == "read") {
  2693. _txtOutDetail += "<div " + _bgColor + ">";
  2694. /*id begin*/
  2695. _txtOutDetail += "<p class='ID'>";
  2696. _txtOutDetail += sId + "&nbsp;";
  2697. _txtOutDetail += "</p>";
  2698. /*id end*/
  2699. /*meaning begin*/
  2700. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2701. showMean = showMean.replace(/}/g, "</span>");
  2702. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2703. showMean = showMean.replace(/\]/g, "</span>");
  2704. _txtOutDetail += "<p class='mean'>";
  2705. _txtOutDetail += showMean + "&nbsp;";
  2706. _txtOutDetail += "</p>";
  2707. /*meaning end*/
  2708. /*org begin*/
  2709. _txtOutDetail += "<p class='org'>";
  2710. _txtOutDetail += sOrg + "&nbsp;";
  2711. _txtOutDetail += "</p>";
  2712. /*org end*/
  2713. /*org meaning begin*/
  2714. _txtOutDetail += "<p class='om'>";
  2715. _txtOutDetail += sOm + "&nbsp;";
  2716. _txtOutDetail += "</p>";
  2717. /*org meaning end*/
  2718. /*grmma begin*/
  2719. _txtOutDetail += "<p class='case'>";
  2720. sCase = getLocalGrammaStr(sCase);
  2721. var mGramma = sCase.split("#");
  2722. if (mGramma.length >= 2) {
  2723. mType = sCase.split("#")[0];
  2724. mGramma = sCase.split("#")[1];
  2725. } else {
  2726. mType = "";
  2727. mGramma = sCase.split("#")[0];
  2728. }
  2729. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2730. if (mType != "") {
  2731. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2732. }
  2733. _txtOutDetail += mGramma;
  2734. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2735. /*grmma end*/
  2736. _txtOutDetail += "</div>";
  2737. }
  2738. //编辑模式开始
  2739. if (g_useMode == "edit") {
  2740. if (getNodeText(wordNode, "lock") == "true") {
  2741. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2742. } else {
  2743. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2744. }
  2745. _txtOutDetail += "<div " + _bgColor + ">";
  2746. /*id begin*/
  2747. _txtOutDetail += "<p class='ID'>";
  2748. _txtOutDetail += sId + "&nbsp;";
  2749. _txtOutDetail += "</p>";
  2750. /*id end*/
  2751. /*gramma*/
  2752. /*find in dict*/
  2753. var arrGramma = new Array();
  2754. var thisWord = getNodeText(wordNode, "real");
  2755. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2756. if (thisWord == g_DictWordList[iDict].Pali) {
  2757. if (
  2758. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2759. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2760. ) {
  2761. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2762. pushNewToList(arrGramma, arrCase);
  2763. }
  2764. }
  2765. }
  2766. if (sCase == "?" || sCase == "?#?") {
  2767. if (arrGramma.length > 0) {
  2768. setNodeText(xmlElement, "case", arrGramma[0]);
  2769. sCase = arrGramma[0];
  2770. } else {
  2771. setNodeText(xmlElement, "case", "?#?");
  2772. sCase = "?#?";
  2773. }
  2774. } else {
  2775. if (sCase.indexOf("#") == -1) {
  2776. sCase = "?#" + sCase;
  2777. setNodeText(xmlElement, "case", "?#" + sCase);
  2778. }
  2779. }
  2780. var currType = sCase.split("#")[0];
  2781. var currGramma = sCase.split("#")[1];
  2782. //end gramma
  2783. /*meaning*/
  2784. /*find in dict*/
  2785. var arrMeaning = new Array();
  2786. var currMeaning = "";
  2787. var currGrammaMeaning = "";
  2788. var wordParent = "";
  2789. var wordGramma0 = "";
  2790. //self meaning
  2791. var thisWord = getNodeText(wordNode, "real");
  2792. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2793. if (
  2794. thisWord == g_DictWordList[iDict].Pali &&
  2795. g_DictWordList[iDict].Type != ".root." &&
  2796. g_DictWordList[iDict].Type != ".suf." &&
  2797. g_DictWordList[iDict].Type != ".prf."
  2798. ) {
  2799. if (
  2800. wordParent == "" &&
  2801. g_DictWordList[iDict].Parent.length > 0 &&
  2802. g_DictWordList[iDict].Parent != thisWord
  2803. ) {
  2804. wordParent = g_DictWordList[iDict].Parent;
  2805. wordGramma0 = g_DictWordList[iDict].Gramma;
  2806. }
  2807. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2808. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2809. if (currGrammaMeaning == "") {
  2810. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2811. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2812. }
  2813. }
  2814. }
  2815. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2816. for (var i = 0; i < arrMean.length; i++) {
  2817. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2818. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2819. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2820. arrMeaning.push(
  2821. g_DictWordList[iDict].dictID +
  2822. "$" +
  2823. arrMeaning.length +
  2824. "$$" +
  2825. arrMean[i] +
  2826. "$" +
  2827. g_DictWordList[iDict].Language
  2828. );
  2829. }
  2830. }
  2831. }
  2832. }
  2833. }
  2834. var wordGramma1 = "";
  2835. //find in father
  2836. if (wordParent != "") {
  2837. //add parent infomation
  2838. if (sParent == "" || sParent == " ") {
  2839. setNodeText(wordNode, "parent", wordParent);
  2840. sParent = wordParent;
  2841. }
  2842. thisWord = wordParent;
  2843. wordParent = "";
  2844. wordGramma1 = "";
  2845. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2846. if (
  2847. thisWord == g_DictWordList[iDict].Pali &&
  2848. g_DictWordList[iDict].Type != ".v." &&
  2849. g_DictWordList[iDict].Type != ".n." &&
  2850. g_DictWordList[iDict].Type != ".ti." &&
  2851. g_DictWordList[iDict].Type != ".adj." &&
  2852. g_DictWordList[iDict].Type != ".pron." &&
  2853. g_DictWordList[iDict].Type != ".num."
  2854. ) {
  2855. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2856. if (wordParent == "") {
  2857. wordParent = g_DictWordList[iDict].Parent;
  2858. }
  2859. if (wordGramma1 == "") {
  2860. wordGramma1 = g_DictWordList[iDict].Gramma;
  2861. }
  2862. }
  2863. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2864. for (var i = 0; i < arrMean.length; i++) {
  2865. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2866. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2867. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2868. arrMeaning.push(
  2869. g_DictWordList[iDict].dictID +
  2870. "$" +
  2871. arrMeaning.length +
  2872. "$*$" +
  2873. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2874. "$" +
  2875. g_DictWordList[iDict].Language
  2876. );
  2877. }
  2878. }
  2879. }
  2880. }
  2881. }
  2882. }
  2883. //爷爷跟父亲的关系 比如 pp
  2884. wordGranfatherGramma = wordGramma1;
  2885. wordGranfather = wordParent;
  2886. //grandfather
  2887. var wordGramma2 = "";
  2888. if (wordParent != "") {
  2889. thisWord = wordParent;
  2890. wordParent = "";
  2891. wordGramma2 = "";
  2892. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2893. if (
  2894. thisWord == g_DictWordList[iDict].Pali &&
  2895. g_DictWordList[iDict].Type != ".v." &&
  2896. g_DictWordList[iDict].Type != ".n." &&
  2897. g_DictWordList[iDict].Type != ".ti." &&
  2898. g_DictWordList[iDict].Type != ".adj." &&
  2899. g_DictWordList[iDict].Type != ".pron." &&
  2900. g_DictWordList[iDict].Type != ".num."
  2901. ) {
  2902. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2903. if (wordParent == "") {
  2904. wordParent = g_DictWordList[iDict].Parent;
  2905. }
  2906. if (wordGramma2 == "") {
  2907. wordGramma2 = g_DictWordList[iDict].Gramma;
  2908. }
  2909. }
  2910. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2911. for (var i = 0; i < arrMean.length; i++) {
  2912. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2913. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2914. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2915. arrMeaning.push(
  2916. g_DictWordList[iDict].dictID +
  2917. "$" +
  2918. arrMeaning.length +
  2919. "$**$" +
  2920. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2921. "$" +
  2922. g_DictWordList[iDict].Language
  2923. );
  2924. }
  2925. }
  2926. }
  2927. }
  2928. }
  2929. }
  2930. arrMeaning.sort(sortMeanByDictOrder);
  2931. //arrMeaning.sort(sortMeanByLanguageOrder);
  2932. newMeanList = removeSameWordInArray(arrMeaning);
  2933. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2934. if (sMean == "?") {
  2935. //自动匹配一个意思
  2936. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2937. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2938. currMeaning = currGrammaMeaning;
  2939. } else {
  2940. if (newMeanList.length > 0) {
  2941. currMeaning = newMeanList[0].word;
  2942. } else {
  2943. currMeaning = sMean;
  2944. }
  2945. }
  2946. } else {
  2947. currMeaning = removeFormula(sMean);
  2948. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2949. }
  2950. orgMeaning = removeFormula(currMeaning);
  2951. if (sReal.length < 4) {
  2952. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2953. } else {
  2954. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2955. }
  2956. setNodeText(wordNode, "mean", currMeaning);
  2957. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2958. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2959. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2960. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2961. //渲染下拉菜单
  2962. _txtOutDetail += "<div class='mean'>";
  2963. _txtOutDetail += render_word_mean_menu(wordNode);
  2964. //render formula menu
  2965. arrFormula = getFormulaList(currGramma);
  2966. _txtOutDetail += '<div class="case_dropdown">';
  2967. _txtOutDetail += "<svg class='edit_icon'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2968. _txtOutDetail += '<div class="case_dropdown-content">';
  2969. newWord = removeFormula_B(orgMeaning);
  2970. _txtOutDetail +=
  2971. "<a onclick='fieldListChanged(\"" +
  2972. wordID +
  2973. '","mean","[]' +
  2974. newWord +
  2975. "\")'>[" +
  2976. gLocal.gui.none +
  2977. "]</a>";
  2978. _txtOutDetail +=
  2979. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[" + gLocal.gui.auto + "]</a>";
  2980. for (var i in arrFormula) {
  2981. newWord = removeFormula_B(orgMeaning);
  2982. newWord = arrFormula[i].replace("~", newWord);
  2983. newWord = newWord.replace(/{/g, "[");
  2984. newWord = newWord.replace(/}/g, "]");
  2985. _txtOutDetail +=
  2986. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2987. }
  2988. _txtOutDetail += "</div>";
  2989. _txtOutDetail += "</div>";
  2990. _txtOutDetail += "</div> ";
  2991. /*end of meaning*/
  2992. /*org begin 拆分*/
  2993. /*
  2994. >>>>>>> bc16896ae743d21de32c24d5ffe63b6be00a315c
  2995. _txtOutDetail += "<p class='org' name='w_org'>";
  2996. _txtOutDetail += sOrg + "&nbsp;";
  2997. _txtOutDetail += "</p> ";
  2998. */
  2999. /*find in dict*/
  3000. var currOrg = "";
  3001. var wordParent = "";
  3002. var arrOrg = new Array();
  3003. var thisWord = getNodeText(wordNode, "real");
  3004. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3005. if (thisWord == g_DictWordList[iDict].Pali) {
  3006. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3007. wordParent = g_DictWordList[iDict].Parent;
  3008. }
  3009. var currOrg = g_DictWordList[iDict].Factors;
  3010. if (currOrg.length > 0 && currOrg != "?") {
  3011. pushNewToList(arrOrg, currOrg);
  3012. //arrOrg.push(currOrg);
  3013. }
  3014. }
  3015. }
  3016. //father
  3017. if (wordParent != "") {
  3018. thisWord = wordParent;
  3019. wordParent = "";
  3020. wordGramma1 = "";
  3021. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3022. if (thisWord == g_DictWordList[iDict].Pali) {
  3023. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3024. if (wordParent == "") {
  3025. wordParent = g_DictWordList[iDict].Parent;
  3026. }
  3027. }
  3028. var currOrg = g_DictWordList[iDict].Factors;
  3029. if (currOrg.length > 0 && currOrg != "?") {
  3030. pushNewToList(arrOrg, currOrg);
  3031. //arrOrg.push(currOrg);
  3032. }
  3033. }
  3034. }
  3035. }
  3036. //grandfather
  3037. if (wordParent != "") {
  3038. thisWord = wordParent;
  3039. wordParent = "";
  3040. wordGramma2 = "";
  3041. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3042. if (thisWord == g_DictWordList[iDict].Pali) {
  3043. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3044. if (wordParent == "") {
  3045. wordParent = g_DictWordList[iDict].Parent;
  3046. }
  3047. }
  3048. var currOrg = g_DictWordList[iDict].Factors;
  3049. if (currOrg.length > 0 && currOrg != "?") {
  3050. pushNewToList(arrOrg, currOrg);
  3051. //arrOrg.push(currOrg);
  3052. }
  3053. }
  3054. }
  3055. }
  3056. _txtOutDetail += "<div class='org' name='w_org'>";
  3057. _txtOutDetail += '<div class="case_dropdown">';
  3058. _txtOutDetail += "<p class='case_dropbtn' >";
  3059. if (sOrg == "?") {
  3060. if (arrOrg.length > 0) {
  3061. currOrg = arrOrg[0];
  3062. } else {
  3063. currOrg = sOrg;
  3064. }
  3065. setNodeText(wordNode, "org", currOrg);
  3066. } else {
  3067. currOrg = sOrg;
  3068. }
  3069. _txtOutDetail += currOrg;
  3070. if (arrOrg.length > 0) {
  3071. _txtOutDetail += "<svg class='edit_icon'>";
  3072. _txtOutDetail += "<use xlink:href='svg/icon.svg#ic_down'></use>";
  3073. _txtOutDetail += "</svg>";
  3074. }
  3075. _txtOutDetail += "</p>";
  3076. _txtOutDetail += '<div class="case_dropdown-content">';
  3077. _txtOutDetail +=
  3078. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3079. wordID +
  3080. '","org","")\'>' +
  3081. gLocal.gui.empty1 +
  3082. "</button>";
  3083. _txtOutDetail +=
  3084. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" +
  3085. wordID +
  3086. "\")'>" +
  3087. gLocal.gui.wordmap +
  3088. "</button>";
  3089. //新加 base 信息 vn
  3090. _txtOutDetail += '<div class="case_dropdown-org">';
  3091. _txtOutDetail += '<div class="case_dropdown-first">';
  3092. _txtOutDetail += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
  3093. _txtOutDetail += sParent + "</a>";
  3094. _txtOutDetail += "<span style='z-index:220' class='case_dropdown-title'>";
  3095. _txtOutDetail += gLocal.gui.more + "»</span>";
  3096. _txtOutDetail += "</div>";
  3097. for (i in arrOrg) {
  3098. _txtOutDetail +=
  3099. "<a onclick='fieldListChanged(\"" + wordID + '","org","' + arrOrg[i] + "\")'>" + arrOrg[i] + "</a>";
  3100. }
  3101. _txtOutDetail += "</div>";
  3102. _txtOutDetail += "</div>";
  3103. _txtOutDetail += "</div>";
  3104. _txtOutDetail += "</div> ";
  3105. /*end of factors*/
  3106. /*part meaning begin*/
  3107. listFactorForFactorMean = currOrg.split("+");
  3108. currDefualtFM = "";
  3109. for (iFactor in listFactorForFactorMean) {
  3110. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  3111. }
  3112. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  3113. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  3114. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  3115. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  3116. if (currDefualtFM.slice(-1, -2) == "+") {
  3117. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  3118. }
  3119. /*find in dict*/
  3120. var currOM = "";
  3121. var wordParent = "";
  3122. var arrOM = new Array();
  3123. var thisWord = getNodeText(wordNode, "real");
  3124. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3125. if (thisWord == g_DictWordList[iDict].Pali) {
  3126. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3127. wordParent = g_DictWordList[iDict].Parent;
  3128. }
  3129. var currOM = g_DictWordList[iDict].FactorMean;
  3130. if (currOM.length > 0 && currOM != "?") {
  3131. pushNewToList(arrOM, currOM);
  3132. //arrOM.push(currOM);
  3133. }
  3134. }
  3135. }
  3136. /*
  3137. //father
  3138. if(wordParent!=""){
  3139. thisWord=wordParent;
  3140. wordParent="";
  3141. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3142. if(thisWord==g_DictWordList[iDict].Pali){
  3143. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3144. if(wordParent==""){
  3145. wordParent=g_DictWordList[iDict].Parent;
  3146. }
  3147. }
  3148. var currOM=g_DictWordList[iDict].FactorMean;
  3149. if(currOM.length>0 && currOM!="?"){
  3150. pushNewToList(arrOM,currOM);
  3151. }
  3152. }
  3153. }
  3154. }
  3155. //grandfather
  3156. if(wordParent!=""){
  3157. thisWord=wordParent;
  3158. wordParent="";
  3159. wordGramma2="";
  3160. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3161. if(thisWord==g_DictWordList[iDict].Pali){
  3162. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3163. if(wordParent==""){
  3164. wordParent=g_DictWordList[iDict].Parent;
  3165. }
  3166. }
  3167. var currOM=g_DictWordList[iDict].FactorMean;
  3168. if(currOM.length>0 && currOM!="?"){
  3169. pushNewToList(arrOM,currOM);
  3170. }
  3171. }
  3172. }
  3173. }
  3174. */
  3175. _txtOutDetail += "<div class='om' name='w_om'>";
  3176. _txtOutDetail += '<div class="case_dropdown">';
  3177. _txtOutDetail += "<p class='case_dropbtn' >";
  3178. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  3179. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  3180. if (arrOM.length > 0) {
  3181. currOM = arrOM[0];
  3182. } else {
  3183. currOM = "[a]" + currDefualtFM;
  3184. }
  3185. setNodeText(wordNode, "om", currOM);
  3186. } else {
  3187. currOM = sOm;
  3188. }
  3189. _txtOutDetail += currOM;
  3190. if (arrOM.length > 0) {
  3191. _txtOutDetail += " ▾";
  3192. }
  3193. _txtOutDetail += "</p>";
  3194. _txtOutDetail += '<div class="case_dropdown-content">';
  3195. _txtOutDetail +=
  3196. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3197. wordID +
  3198. '","om","")\'>' +
  3199. gLocal.gui.empty1 +
  3200. "</button>";
  3201. _txtOutDetail +=
  3202. "<a onclick='fieldListChanged(\"" +
  3203. wordID +
  3204. '","om","[a]' +
  3205. currDefualtFM +
  3206. "\")'>[" +
  3207. gLocal.gui.auto +
  3208. "]" +
  3209. currDefualtFM +
  3210. "</a>";
  3211. for (i in arrOM) {
  3212. _txtOutDetail +=
  3213. "<a onclick='fieldListChanged(\"" + wordID + '","om","' + arrOM[i] + "\")'>" + arrOM[i] + "</a>";
  3214. }
  3215. _txtOutDetail += "</div>";
  3216. _txtOutDetail += "</div>";
  3217. _txtOutDetail += "</div> ";
  3218. /*org meaning end*/
  3219. /*begin gramma*/
  3220. _txtOutDetail += "<div class='case'>";
  3221. _txtOutDetail += '<div class="case_dropdown">';
  3222. _txtOutDetail += "<p class='case_dropbtn' >";
  3223. sLocalCase = getLocalGrammaStr(sCase);
  3224. var mArrGramma = sCase.split("#");
  3225. if (mArrGramma.length >= 2) {
  3226. mType = mArrGramma[0];
  3227. mGramma = mArrGramma[1];
  3228. mLocalType = sLocalCase.split("#")[0];
  3229. mLocalGramma = sLocalCase.split("#")[1];
  3230. } else {
  3231. mType = "";
  3232. mGramma = mArrGramma[0];
  3233. mLocalType = "";
  3234. mLocalGramma = sLocalCase.split("#")[0];
  3235. }
  3236. if (mType != "") {
  3237. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  3238. }
  3239. _txtOutDetail += cutString(mLocalGramma, 30);
  3240. _txtOutDetail += "</p>";
  3241. _txtOutDetail += '<div class="case_dropdown-content">';
  3242. for (i in arrGramma) {
  3243. _txtOutDetail +=
  3244. "<a onclick='fieldListChanged(\"" +
  3245. wordID +
  3246. '","case","' +
  3247. arrGramma[i] +
  3248. "\")'>" +
  3249. cutString(getLocalGrammaStr(arrGramma[i]), 30) +
  3250. "</a>";
  3251. }
  3252. _txtOutDetail += "</div>";
  3253. _txtOutDetail += "</div>";
  3254. //连读词按钮
  3255. if (mType == ".un." || mType == ".comp.") {
  3256. nextElement = com_get_nextsibling(xmlElement);
  3257. if (nextElement != null) {
  3258. //下一个元素存在
  3259. if (getNodeText(nextElement, "un") == sId) {
  3260. //若有孩子則显示收起按鈕
  3261. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  3262. _txtOutDetail +=
  3263. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  3264. _txtOutDetail += "</button>";
  3265. var parentElement = document.getElementById("wb" + sId);
  3266. if (parentElement) {
  3267. parentElement.classList.add("un_parent");
  3268. }
  3269. } else {
  3270. //無kid展開按鈕
  3271. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3272. _txtOutDetail +=
  3273. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3274. _txtOutDetail += "</button> ";
  3275. }
  3276. } else {
  3277. //下一个元素不存在
  3278. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3279. _txtOutDetail +=
  3280. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3281. _txtOutDetail += "</button> ";
  3282. }
  3283. }
  3284. //连读词按钮 结束
  3285. //爷爷和父亲的关系 如pp
  3286. if (wordGranfatherGramma.length > 0 && wordGranfatherGramma.length < 6) {
  3287. _txtOutDetail +=
  3288. '<span class="tooltip">«' +
  3289. getLocalGrammaStr(wordGranfatherGramma) +
  3290. '<span class="tooltiptext tooltip-bottom">' +
  3291. wordGranfather +
  3292. "</span>" +
  3293. "</span> ";
  3294. }
  3295. _txtOutDetail += "</div> ";
  3296. /*end of gramma*/
  3297. //Auto Match Finished
  3298. _txtOutDetail += "</div>";
  3299. }
  3300. return _txtOutDetail;
  3301. }
  3302. function renderWordNoteDivByParaNo(book, paragraph) {}
  3303. /*
  3304. paragraph word note
  3305. */
  3306. function renderWordNoteDivByElement(elementBlock) {
  3307. let output = "";
  3308. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3309. let book = getNodeText(xmlParInfo, "book");
  3310. let paragraph = getNodeText(xmlParInfo, "paragraph");
  3311. let bId = getNodeText(xmlParInfo, "id");
  3312. let type = getNodeText(xmlParInfo, "type");
  3313. let allWord = elementBlock.getElementsByTagName("word");
  3314. let iNoteCounter = 0;
  3315. for (iWord = 0; iWord < allWord.length; iWord++) {
  3316. let oneNote = "";
  3317. let pali = getNodeText(allWord[iWord], "pali");
  3318. let sNote = getNodeText(allWord[iWord], "note");
  3319. if (sNote != "") {
  3320. oneNote += note_init(sNote);
  3321. }
  3322. let sRela = getNodeText(allWord[iWord], "rela");
  3323. if (sRela != "") {
  3324. oneNote += "<div>" + renderWordRelation(allWord[iWord]) + "</div>";
  3325. }
  3326. id = getNodeText(allWord[iWord], "id");
  3327. if (oneNote == "") {
  3328. //有内容
  3329. $("#wnote_root_" + id).html("");
  3330. } else {
  3331. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3332. output += "<div>";
  3333. output += "<wnc wid='" + id + "'></wnc>";
  3334. output += "<strong>" + pali + ":</strong>";
  3335. output += oneNote;
  3336. output += "</div>";
  3337. }
  3338. }
  3339. return output;
  3340. }
  3341. function refreshWordNoteDiv(elementBlock) {
  3342. let html = renderWordNoteDivByElement(elementBlock);
  3343. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3344. let book = getNodeText(xmlParInfo, "book");
  3345. let paragraph = parseInt(getNodeText(xmlParInfo, "paragraph"));
  3346. let noteid = "wnote_" + book + "_" + (paragraph - 1);
  3347. try {
  3348. if (html == "") {
  3349. $("#" + noteid).hide();
  3350. } else {
  3351. $("#" + noteid).html(html);
  3352. $("#" + noteid).show();
  3353. }
  3354. } catch (e) {
  3355. console.error(e.message + noteid);
  3356. }
  3357. }
  3358. function refreshWordNote(elementBlock) {
  3359. var output = "";
  3360. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3361. book = getNodeText(xmlParInfo, "book");
  3362. paragraph = getNodeText(xmlParInfo, "paragraph");
  3363. bId = getNodeText(xmlParInfo, "id");
  3364. type = getNodeText(xmlParInfo, "type");
  3365. var allWord = elementBlock.getElementsByTagName("word");
  3366. var iNoteCounter = 0;
  3367. for (iWord = 0; iWord < allWord.length; iWord++) {
  3368. pali = getNodeText(allWord[iWord], "pali");
  3369. wnote = note_init(getNodeText(allWord[iWord], "note"));
  3370. id = getNodeText(allWord[iWord], "id");
  3371. var note = wnote;
  3372. if (note.length > 0 && note != "?") {
  3373. iNoteCounter++;
  3374. if (wnote.substring(0, 6) == "=term(") {
  3375. var termId = wnote.slice(6, -1);
  3376. //alert(arrTerm.length);
  3377. if (arrTerm[note]) {
  3378. note = "<term guid='" + termId + "' pos='wbw'>" + arrTerm[termId].note + "</term>";
  3379. } else {
  3380. note = "<term guid='" + termId + "' pos='wbw'></term>";
  3381. }
  3382. }
  3383. output += '<p><a href="#word_note_root_' + id + '" name="word_note_' + id + '">[' + iNoteCounter + "]</a>";
  3384. if (note.match("{") && note.match("}")) {
  3385. note = note.replace("{", "<strong>");
  3386. note = note.replace("}", "</strong>");
  3387. if (note.length > 100) {
  3388. shortNote = note.substring(0, 99);
  3389. otherNode = note.substring(100);
  3390. output +=
  3391. shortNote +
  3392. '<span class="full_note_handle">...<span class="full_note">' +
  3393. otherNode +
  3394. "</span></span>";
  3395. } else {
  3396. output += note;
  3397. }
  3398. } else {
  3399. if (note.length > 100) {
  3400. shortNote = note.substring(0, 99);
  3401. otherNode = note.substring(100);
  3402. output +=
  3403. shortNote +
  3404. '<span class="full_note_handle">...<span class="full_note">' +
  3405. otherNode +
  3406. "</span></span>";
  3407. } else {
  3408. output += "<strong>" + pali + ":</strong>" + note;
  3409. }
  3410. }
  3411. output += "</p>";
  3412. if (termId) {
  3413. document.getElementById("wnote_root_" + id).innerHTML =
  3414. "<a onclick=\"term_show_win('" +
  3415. termId +
  3416. '\')" name="word_note_root_' +
  3417. id +
  3418. '">[' +
  3419. iNoteCounter +
  3420. "]</a>";
  3421. } else {
  3422. document.getElementById("wnote_root_" + id).innerHTML =
  3423. '<a href="#word_note_' + id + '" name="word_note_root_' + id + '">[' + iNoteCounter + "]</a>";
  3424. }
  3425. } else {
  3426. noteRootObj = document.getElementById("wnote_root_" + id);
  3427. if (noteRootObj) {
  3428. document.getElementById("wnote_root_" + id).innerHTML = "";
  3429. }
  3430. }
  3431. }
  3432. if (output == "") {
  3433. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
  3434. } else {
  3435. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
  3436. }
  3437. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = output;
  3438. }
  3439. function updateWordNote(element) {
  3440. let paliword = getNodeText(element, "real");
  3441. let wnote = getNodeText(element, "note");
  3442. wnote = note_init(wnote);
  3443. let id = getNodeText(element, "id");
  3444. if (wnote == "") {
  3445. $("#wnote_root_" + id).html("");
  3446. $("#wnn_" + id).html("");
  3447. } else {
  3448. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3449. let output = "";
  3450. output += "<wnc wid='" + id + "'></wnc>";
  3451. let head = "";
  3452. let content = "";
  3453. if (wnote.match("{") && wnote.match("}")) {
  3454. wnote = wnote.replace("{", "<strong>");
  3455. wnote = wnote.replace("}", "</strong>");
  3456. } else {
  3457. output += "<strong>" + paliword + ":</strong>";
  3458. }
  3459. output += wnote;
  3460. $("#wnn_" + id).html(output);
  3461. }
  3462. }
  3463. function updateWordCommentary(element) {}
  3464. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3465. //返回 无
  3466. function updataWordBodyByElement(element) {
  3467. try {
  3468. var sId = getNodeText(wordNode, "id");
  3469. var sDetail = "detail" + sId;
  3470. var cDetail = document.getElementById(sDetail);
  3471. if (cDetail != null) {
  3472. cDetail.innerHTML = renderWordDetailByElement(element);
  3473. }
  3474. } catch (error) {
  3475. var_dump(error);
  3476. }
  3477. }
  3478. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3479. //返回 无
  3480. function modifyWordDetailByWordId(wordId) {
  3481. try {
  3482. var sDetail = "detail" + wordId;
  3483. var cDetail = document.getElementById(sDetail);
  3484. if (cDetail != null) {
  3485. cDetail.innerHTML = renderWordDetailById(wordId);
  3486. }
  3487. } catch (error) {
  3488. var_dump(error);
  3489. }
  3490. }
  3491. //根据xmlDocument 对象中的单词GUID返回单词块字符串(不含Pali)
  3492. //返回 字符串
  3493. function renderWordDetailById(wordID) {
  3494. var mXML = gXmlBookDataBody.getElementsByTagName("word");
  3495. var wordIndex = getWordIndex(wordID);
  3496. return renderWordDetailByElement(mXML[wordIndex]);
  3497. }
  3498. function reloadPar(parIndex) {
  3499. bookId = gArrayDocParagraph[parIndex].book;
  3500. parNo = gArrayDocParagraph[parIndex].paragraph;
  3501. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3502. if (htmlBlock.style.display != "none") {
  3503. return false;
  3504. }
  3505. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  3506. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  3507. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  3508. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  3509. currBookId = getNodeText(xmlParInfo, "book");
  3510. currParNo = getNodeText(xmlParInfo, "paragraph");
  3511. if (bookId == currBookId && currParNo == parNo) {
  3512. insertBlockToHtml(allBlock[iBlock]);
  3513. }
  3514. }
  3515. return true;
  3516. }
  3517. function removePar(parIndex) {
  3518. bookId = gArrayDocParagraph[parIndex].book;
  3519. parNo = gArrayDocParagraph[parIndex].paragraph;
  3520. if (gCurrModifyWindowParNo == parIndex) {
  3521. //关闭单词修改窗口
  3522. closeModifyWindow();
  3523. }
  3524. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3525. if (htmlBlock) {
  3526. htmlBlock.style.display = "none";
  3527. document.getElementById("heading_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3528. document.getElementById("wblock_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3529. document.getElementById("tran_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3530. document.getElementById("wnote_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3531. document.getElementById("note_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3532. }
  3533. }
  3534. function setView(topParIndex) {
  3535. var parInOnePage = 3;
  3536. gCurrTopParagraph = topParIndex;
  3537. gVisibleParBegin = topParIndex - parInOnePage;
  3538. gVisibleParEnd = parInOnePage * 2;
  3539. if (gVisibleParBegin < 0) {
  3540. gVisibleParBegin = 0;
  3541. }
  3542. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3543. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3544. }
  3545. }
  3546. function isParInView(parIndex) {
  3547. if (parIndex >= gVisibleParBegin && parIndex <= gVisibleParEnd) {
  3548. return true;
  3549. } else {
  3550. return false;
  3551. }
  3552. }
  3553. function refresh_Dispaly_Cap() {
  3554. var new_par_length = gPalitext_length / gtext_max_length;
  3555. for (refresh_i in allTextLen_array) {
  3556. gNewArrayDocParagraph.push(allTextLen_array[refresh_i].length / gtext_max_length);
  3557. }
  3558. }
  3559. function prev_page() {
  3560. //向上翻页
  3561. gVisibleParBeginOld = gVisibleParBegin;
  3562. gVisibleParEndOld = gVisibleParEnd;
  3563. if (g_allparlen_array[gVisibleParEnd - 1] - g_allparlen_array[gVisibleParBegin - 1] <= gDisplayCapacity) {
  3564. gVisibleParBegin -= 1;
  3565. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin - 1] > gDisplayCapacity) {
  3566. gVisibleParBegin -= 1;
  3567. gVisibleParEnd -= 1;
  3568. }
  3569. if (gVisibleParBegin < 0) {
  3570. //如果到顶,则恢复原始值
  3571. gVisibleParBegin = 0;
  3572. //gVisibleParEnd=gDisplayCapacity;
  3573. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3574. //如果到底,则锁死最大值
  3575. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3576. }
  3577. }
  3578. updataView();
  3579. }
  3580. function next_page() {
  3581. //向下翻页
  3582. gVisibleParBeginOld = gVisibleParBegin;
  3583. gVisibleParEndOld = gVisibleParEnd;
  3584. if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] <= gDisplayCapacity) {
  3585. gVisibleParEnd += 1;
  3586. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] > gDisplayCapacity) {
  3587. gVisibleParBegin += 1;
  3588. gVisibleParEnd += 1;
  3589. }
  3590. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3591. //如果到底
  3592. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3593. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3594. if (gVisibleParBegin < 0) {
  3595. gVisibleParBegin = 0;
  3596. }
  3597. }
  3598. updataView();
  3599. }
  3600. function setNewView(newBegin, newEnd) {
  3601. gVisibleParBeginOld = gVisibleParBegin;
  3602. gVisibleParEndOld = gVisibleParEnd;
  3603. gVisibleParBegin = newBegin;
  3604. gVisibleParEnd = newEnd;
  3605. if (gVisibleParBegin < 0) {
  3606. gVisibleParBegin = 0;
  3607. //gVisibleParEnd=gDisplayCapacity;
  3608. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3609. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3610. }
  3611. }
  3612. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3613. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3614. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3615. if (gVisibleParBegin < 0) {
  3616. gVisibleParBegin = 0;
  3617. }
  3618. }
  3619. updataView();
  3620. }
  3621. function updataView() {
  3622. var topNewDivArray = Array(); //在顶端新加入的块列表
  3623. for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  3624. if (isParInView(iPar)) {
  3625. isLoadNew = reloadPar(iPar);
  3626. if (isLoadNew) {
  3627. if (iPar < gVisibleParBeginOld) {
  3628. topNewDivArray.push(iPar);
  3629. }
  3630. }
  3631. } else {
  3632. removePar(iPar);
  3633. }
  3634. }
  3635. word_mouse_event();
  3636. //console.log("updataview");
  3637. console.log(topNewDivArray.toString());
  3638. }
  3639. function render_word_mean_menu2(spell) {
  3640. var wReal = spell;
  3641. var output = "<div>";
  3642. for (var iDict = 0; iDict < mDict[spell].length; iDict++) {
  3643. output += "<div>";
  3644. output += "<span>dict_name</span>";
  3645. var meanGroup = partList2[i].mean.split("$");
  3646. for (var iMean = 0; iMean < meanGroup.length; iMean++) {
  3647. output +=
  3648. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3649. wId +
  3650. '","mean","' +
  3651. meanGroup[iMean] +
  3652. "\")'>" +
  3653. meanGroup[iMean] +
  3654. "</span>";
  3655. }
  3656. output += "</div>";
  3657. }
  3658. output += "</div>";
  3659. return;
  3660. var sWord = new Array(wReal);
  3661. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3662. for (var iWord in sWord) {
  3663. output += '<div class="case_dropdown-first">';
  3664. output +=
  3665. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3666. sWord[iWord] +
  3667. "\")'>";
  3668. output += sWord[iWord] + "</a>";
  3669. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3670. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3671. output += '</span><div class="case_dropdown-detail">';
  3672. var partList = render_get_word_mean_list(sWord[iWord]);
  3673. var L_width_mean = 0;
  3674. var partList2 = repeat_combine(partList);
  3675. //计算字符长度并控制
  3676. for (var i in partList2) {
  3677. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3678. if (L_width_mean < L_width / 1.7) {
  3679. L_width_mean = L_width / 1.7;
  3680. }
  3681. }
  3682. for (var i in partList2) {
  3683. var meanGroup = partList2[i].mean.split("$");
  3684. var htmlMean = "";
  3685. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3686. output +=
  3687. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3688. //output += "<a ><div id='div_dictname_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_dictname+"em; display:flex'>"
  3689. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3690. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3691. output += getLocalDictname(partList2[i].dict) + "</span>";
  3692. output += "</div>";
  3693. output +=
  3694. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3695. //output += "<div id='div_type_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_type+"em; display:flex'>"
  3696. output +=
  3697. "<span id='span_type_" +
  3698. wId +
  3699. "_" +
  3700. iWord +
  3701. "_" +
  3702. i +
  3703. "' style='height: 1.5em;' class='wm_wordtype'>" +
  3704. getLocalGrammaStr(partList2[i].type) +
  3705. "</span>";
  3706. for (var iMean in meanGroup) {
  3707. if (meanGroup[iMean] != "") {
  3708. htmlMean +=
  3709. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3710. wId +
  3711. '","mean","' +
  3712. meanGroup[iMean] +
  3713. "\")'>" +
  3714. meanGroup[iMean] +
  3715. "</span>";
  3716. }
  3717. }
  3718. output += "</div><div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3719. output += "</a>";
  3720. }
  3721. output += "</div></div>";
  3722. }
  3723. output += "</div></div></div>";
  3724. return output;
  3725. }
  3726. function render_word_mean_menu(xElement) {
  3727. var wMean = getNodeText(xElement, "mean");
  3728. var wReal = getNodeText(xElement, "real");
  3729. var wId = getNodeText(xElement, "id");
  3730. var renderMeaning = wMean.replace(/{/g, "<span class='grm_add_mean'>");
  3731. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  3732. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  3733. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  3734. var output = "";
  3735. output += '<div class="case_dropdown">';
  3736. output += "<p class='case_dropbtn' >";
  3737. output += renderMeaning;
  3738. output += "</p>";
  3739. output += '<div class="case_dropdown-content">';
  3740. output +=
  3741. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3742. wId +
  3743. '","mean","")\'>' +
  3744. gLocal.gui.empty1 +
  3745. '</button><div class="case_dropdown-org">';
  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>";
  3758. output += '<div class="case_dropdown-detail">';
  3759. var partList = render_get_word_mean_list(sWord[iWord]);
  3760. var L_width_mean = 0;
  3761. var partList2 = repeat_combine(partList);
  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 += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3775. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3776. output += getLocalDictname(partList2[i].dict) + "</span>";
  3777. output += "</div>";
  3778. output +=
  3779. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3780. output +=
  3781. "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>";
  3782. if (partList2[i].type == ".n:base.") {
  3783. output += getLocalGrammaStr(partList2[i].gramma);
  3784. } else {
  3785. output += getLocalGrammaStr(partList2[i].type);
  3786. }
  3787. output += "</span>";
  3788. for (var iMean in meanGroup) {
  3789. if (meanGroup[iMean] != "") {
  3790. htmlMean +=
  3791. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3792. wId +
  3793. '","mean","' +
  3794. meanGroup[iMean] +
  3795. "\")'>" +
  3796. meanGroup[iMean] +
  3797. "</span>";
  3798. }
  3799. }
  3800. output += "</div>";
  3801. output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3802. output += "</a>";
  3803. }
  3804. output += "</div></div>";
  3805. }
  3806. output += "</div></div></div>";
  3807. return output;
  3808. }
  3809. function render_get_word_mean_list(sWord) {
  3810. var wReal = sWord;
  3811. var output = Array();
  3812. for (var x in g_DictWordList) {
  3813. if (g_DictWordList[x].Pali == wReal || g_DictWordList[x].Real == wReal) {
  3814. if (dict_language_enable.indexOf(g_DictWordList[x].Language) >= 0) {
  3815. if (
  3816. g_DictWordList[x].Mean != "" &&
  3817. g_DictWordList[x].Type != ".part." &&
  3818. g_DictWordList[x].Type != ".root." &&
  3819. g_DictWordList[x].Type != ".suf." &&
  3820. g_DictWordList[x].Type != ".pfx."
  3821. ) {
  3822. var newPart = Object();
  3823. newPart.dict = g_DictWordList[x].dictname;
  3824. newPart.mean = g_DictWordList[x].Mean;
  3825. newPart.type = g_DictWordList[x].Type;
  3826. var bIsExist = false;
  3827. for (var iBuffer in output) {
  3828. if (
  3829. output[iBuffer].dict == newPart.dict &&
  3830. output[iBuffer].type == newPart.type &&
  3831. output[iBuffer].mean == newPart.mean
  3832. ) {
  3833. bIsExist = true;
  3834. break;
  3835. }
  3836. if (newPart.dict == "wbw") {
  3837. if (output[iBuffer].dict == newPart.dict && output[iBuffer].type == newPart.type) {
  3838. output[iBuffer].mean += "$" + newPart.mean;
  3839. bIsExist = true;
  3840. break;
  3841. }
  3842. }
  3843. }
  3844. if (!bIsExist) {
  3845. output.push(newPart);
  3846. }
  3847. }
  3848. }
  3849. }
  3850. }
  3851. return output;
  3852. }
  3853. function render_get_word_parent_list(sWord) {
  3854. var wReal = sWord;
  3855. var output = Array();
  3856. for (var x in g_DictWordList) {
  3857. if (g_DictWordList[x].Pali == wReal) {
  3858. {
  3859. if (g_DictWordList[x].Parent != "" && g_DictWordList[x].Parent != sWord) {
  3860. var newPart = g_DictWordList[x].Parent;
  3861. var bIsExist = false;
  3862. for (var iBuffer in output) {
  3863. if (output[iBuffer] == newPart) {
  3864. bIsExist = true;
  3865. break;
  3866. }
  3867. }
  3868. if (!bIsExist) {
  3869. output.push(newPart);
  3870. }
  3871. }
  3872. }
  3873. }
  3874. }
  3875. return output;
  3876. }
  3877. function repeat_combine(list) {
  3878. var list_new = new Array();
  3879. for (var repeat_combine_i = 0; repeat_combine_i < list.length; repeat_combine_i++) {
  3880. var repeat_string = new Object();
  3881. var repeat_combine_j = 0;
  3882. repeat_string.dict = list[repeat_combine_i].dict;
  3883. repeat_string.type = list[repeat_combine_i].type;
  3884. repeat_string.mean = list[repeat_combine_i].mean;
  3885. for (repeat_combine_j = repeat_combine_i + 1; repeat_combine_j < list.length; repeat_combine_j++) {
  3886. if (
  3887. list[repeat_combine_j].dict == list[repeat_combine_i].dict &&
  3888. list[repeat_combine_j].type == list[repeat_combine_i].type
  3889. ) {
  3890. repeat_string.mean = repeat_string.mean + "$" + list[repeat_combine_j].mean;
  3891. repeat_string.mean = repeat_string.mean.replace(/\$\$/g, "$");
  3892. repeat_string.mean = repeat_string.mean.replace(/\$ /g, "$");
  3893. repeat_string.mean = repeat_string.mean.replace(/ \$/g, "$");
  3894. repeat_combine_i = repeat_combine_j;
  3895. }
  3896. }
  3897. repeat_string.mean = "#" + repeat_string.mean + "#";
  3898. repeat_string.mean = repeat_string.mean.replace(/ #/g, "");
  3899. repeat_string.mean = repeat_string.mean.replace(/# /g, "");
  3900. repeat_string.mean = repeat_string.mean.replace(/\$#/g, "");
  3901. repeat_string.mean = repeat_string.mean.replace(/#\$/g, "");
  3902. repeat_string.mean = repeat_string.mean.replace(/ /g, "");
  3903. repeat_string.mean = repeat_string.mean.replace(/#/g, "");
  3904. list_new.push(repeat_string);
  3905. }
  3906. return list_new;
  3907. }
  3908. function show_pop_note(wordid) {
  3909. let html = $("wnc[wid='" + wordid + "']")
  3910. .parent()
  3911. .html();
  3912. $("#word_note_pop_content").html(
  3913. html
  3914. /*note_init(doc_word("#" + wordid).val("note"))*/
  3915. );
  3916. $("#word_note_pop").show("500");
  3917. }
  3918. function refreshNoteNumber() {
  3919. $("wnh").each(function (index, element) {
  3920. let id = $(this).attr("wid");
  3921. //$(this).html("<a href='#word_note_"+id+"' name=\"word_note_root_"+id+"\">"+(index+1)+"</a>");
  3922. $(this).html("<span onclick=\"show_pop_note('" + id + "')\">" + (index + 1) + "</span>");
  3923. });
  3924. $("wnc").each(function (index, element) {
  3925. let id = $(this).attr("wid");
  3926. $(this).html("<a href='#word_note_root_" + id + "' name=\"word_note_" + id + '">[' + (index + 1) + "]</a>");
  3927. });
  3928. note_refresh_new();
  3929. }