render.js 136 KB

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