render.js 137 KB

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